Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need -mlongcalls option for compiling libstdc++ #159

Open
balazsracz opened this issue May 9, 2016 · 1 comment
Open

need -mlongcalls option for compiling libstdc++ #159

balazsracz opened this issue May 9, 2016 · 1 comment

Comments

@balazsracz
Copy link

Hi,

When trying to use libstdc++ for pretty much anything (e.g. instantiate an std::string object), we run into call0 relocation errors:

/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libstdc++.a(string-inst.o): In function std::char_traits<char>::copy(char*, char const*, unsigned int)': /opt/esp/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:230:(.text._ZNSs7_M_copyEPcPKcj[std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_copy(char*, char const*, unsigned int)]+0x11): dangerous relocation: call0: call target out of range: memcpy /opt/esp/esp-open-sdk/xtensa-lx106-elf/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libstdc++.a(string-inst.o): In functionstd::char_traits::move(char_, char const_, unsigned int)':
/opt/esp/esp-open-sdk/crosstool-NG/.build/xtensa-lx106-elf/build/build-cc-final/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:230:(.text.ZNSs7_M_moveEPcPKcj[std::basic_string<char, std::char_traits, std::allocator >::M_move(char, char const, unsigned int)]+0x11): dangerous relocation: call0: call target out of range: memmove

It seems that the libstdc++ library that the crosstool-NG builds is compiled without the -mlongcalls option. Since the default linker scripts define the libc functions like memcpy memmove etc to be versions in the built-in ROM, they are by the memory map more than 512KB away from both the .iram_seg as well as the .irom_seg memory region.

This means that the libstdc++ does not link when placed into iram and also does not link when placed into the irom.

The workaround is to recompile it with -mlongcalls or stop using the ROM builtins for C library functions. Both of these require various levels and intrusiveness of patches.

It would be nice if the libstdc++ (and maybe other libraries too?) would be compiled with -mlongcalls from the start and then the users would not need to patch after the fact.

thanks,
Balazs

@jcmvbkbc
Copy link
Contributor

jcmvbkbc commented May 9, 2016

Please see this pull request: #146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants