gcc - Strange linking behaviour with weak symbols (ARM-EABI unwinding routines __cxa_begin_cleanup) -


i've got problem our arm-eabi toolchain and/or libstdc++.

when compile , link simple c++ library consisting of files test.cpp, testclass.cpp, testclass.h unwinding support routines __cxa_begin_cleanup weak-referenced library, objdump -t showing them as

00000000  w   d  *und*  00000000 __cxa_begin_cleanup 00000000  w   d  *und*  00000000 __cxa_call_unexpected 

__cxa_begin_cleanup implemented in libsupc++, our library linked with, function not linked library. why?

if code library changed , std::string used (prepared in comments in test.cpp), function __cxa_begin_cleanup linked resulting binary , objdump -t won't show them anymore.

there similar issue here, mentioned linker options --start-group , --end-group didn't help.

can help?

the arm-eabi toolchain consists of: gcc 6.3.0 binutils 2.27 newlib 2.4.0

commandline:

arm-eabi-gcc.exe test.cpp testclass.cpp -fpic -o0 -lstdc++ -lsupc++ -o a.out 

source:

test.cpp

#include <string> #include "testclass.h"  int bur_heap_size = 0;  //std::string str1;  int fun () {    testclass obj1; //   str1 = "blabla";    return 0; } 

testclass.cpp

#include "testclass.h"  testclass::testclass(){    public_member = 1;} testclass::~testclass(){} int testclass::publicmethodgetpublicmember(){    return public_member;} 

testclass.h

#ifndef testclass_h_ #define testclass_h_  class testclass {     public:     testclass();     ~testclass();     int publicmethodgetpublicmember();     public:     int public_member; };  #endif 

see elf standard p. 1-18:

when link editor searches archive libraries, extracts archive members contain definitions of undefined global symbols. member’s definition may either global or weak symbol. the link editor not extract archive members resolve undefined weak symbols. unresolved weak symbols have 0 value.

this means example above, no object extracted library, because of weak-declaration. usage of std::string leads extraction of object, satisfies used weak-symbols.

to "solve" this, possible use linker option -u symbol:

force symbol entered in output file undefined symbol. doing may, example, trigger linking of additional modules standard libraries.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -