Make error of dangerous relocation: call8: call target out of range

hacrwang
Posts: 3
Joined: Thu Apr 06, 2017 1:29 pm

Make error of dangerous relocation: call8: call target out of range

Postby hacrwang » Thu Apr 06, 2017 1:37 pm

Hi,

I am using ESP32 SDK to write a sample app, using esp-idf + esp-idf-template, but I got error like

/home/dev/esp/myapp/main/libsample.a(Json.cxx.o): In function `rapidjson::CrtAllocator::Malloc(unsigned int)':
Json.cxx:(.text._ZN9rapidjson12CrtAllocator6MallocEj[rapidjson::CrtAllocator::Malloc(unsigned int)]+0xf): dangerous relocation: call8: call target out of range: malloc

What I have done in the component.mk is that
CXXFLAGS += -std=c++11
COMPONENT_ADD_LDFLAGS += -lsample -L$(COMPONENT_PATH)

I found the compiler option "-mlongcalls" had already been set in project.mk
COMMON_FLAGS = \
-ffunction-sections -fdata-sections \
-fstrict-volatile-bitfields \
-mlongcalls

What is the solution to fix this call8 error? Anyone can give your hints? thanks.

BR
Hacr

ESP_igrr
Posts: 1521
Joined: Tue Dec 01, 2015 8:37 am

Re: Make error of dangerous relocation: call8: call target out of range

Postby ESP_igrr » Thu Apr 06, 2017 1:45 pm

What is the -lsample library and how it is compiled?

hacrwang
Posts: 3
Joined: Thu Apr 06, 2017 1:29 pm

Re: Make error of dangerous relocation: call8: call target out of range

Postby hacrwang » Thu Apr 06, 2017 1:51 pm

libsample.a is another library which I use xtensa-esp32-elf as cross compile tool to build and create a static library.

ESP_igrr
Posts: 1521
Joined: Tue Dec 01, 2015 8:37 am

Re: Make error of dangerous relocation: call8: call target out of range

Postby ESP_igrr » Fri Apr 07, 2017 2:36 am

So it means you aren't using mlongcalls flag when compiling the source files for that library.
You should add -mlongcalls to your CFLAGS and CXXFLAGS at that stage.

hacrwang
Posts: 3
Joined: Thu Apr 06, 2017 1:29 pm

Re: Make error of dangerous relocation: call8: call target out of range

Postby hacrwang » Fri Apr 07, 2017 5:48 am

Oh, great, I also find my mistake :) thanks!

Who is online

Users browsing this forum: No registered users and 19 guests