Page 1 of 1

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

Posted: Thu Apr 06, 2017 1:37 pm
by hacrwang
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

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

Posted: Thu Apr 06, 2017 1:45 pm
by ESP_igrr
What is the -lsample library and how it is compiled?

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

Posted: Thu Apr 06, 2017 1:51 pm
by hacrwang
libsample.a is another library which I use xtensa-esp32-elf as cross compile tool to build and create a static library.

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

Posted: Fri Apr 07, 2017 2:36 am
by ESP_igrr
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.

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

Posted: Fri Apr 07, 2017 5:48 am
by hacrwang
Oh, great, I also find my mistake :) thanks!