This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Strange linking behaviour in conjunction with ARM-EABI unwinding routines (__cxa_begin_cleanup)
- From: "Thomas Schmid via binutils" <binutils at sourceware dot org>
- To: "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 12 Sep 2017 07:35:56 +0000 (UTC)
- Subject: Strange linking behaviour in conjunction with ARM-EABI unwinding routines (__cxa_begin_cleanup)
- Authentication-results: sourceware.org; auth=none
- References: <2091035514.147309.1505201756429.ref@mail.yahoo.com>
- Reply-to: Thomas Schmid <scth2000 at yahoo dot de>
- Reply-to: Thomas Schmid <scth2000 at yahoo dot de>
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