This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Strange linking behaviour in conjunction with ARM-EABI unwinding routines (__cxa_begin_cleanup)


Hello,

we've got a problem with our toolchain and/or libstdc++ and because I think, this confusion could probably be explained by a linker expert, I am asking here for your help.
We are not sure, if this is an error, but me an my colleagues were not able understand this behaviour.

The problem:
When I compile and link a simple C++-library consisting of the files
test.cpp, TestClass.cpp, TestClass.h
some unwinding support routines like '__cxa_begin_cleanup' are weak-referenced from the 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' is implemented in libsupc++, which our library is linked with, but the function is not linked into the library.
Why?
If the code from the library is changed and a std::string is used (prepared in comments in test.cpp), the function '__cxa_begin_cleanup' will be linked to the resulting binary and 'objdump -T' won't show them anymore.


Can anyone 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


Thanks in advance,
regards
Thomas Schmid

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]