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]

Re: R_386_32 relocations with sym-value=0 ?


> The standard startup files do have a call to __gmon_start__, but that
> may not be of interest to you.
Indeed, I don't need that.

> Scratch that idea then.  Hmm, the symbol that you show with zero
> value, _ZTVN10__cxxabiv120__si_class_type_infoE is likely undefined as
> I said, but it's weak undefined so won't cause link errors.  This
> would seem to indicate that libstdc++ was designed to cope without
> si_class_type_info, but may not due to a bug somewhere.  I don't
> know enough about libstdc++ to say much more.
I've just played around a bit. I can even reproduce the problem (or
better: the actual problem that I thought resulted from the strange
relocations) on my linux-system:
myex.h:
#ifndef MY_EX_H_
#define MY_EX_H_
class myexception {
public:
	explicit myexception() {}
	virtual ~myexception() throw () {}
};
void exthrower();
#endif

myex.cpp:
#include "myex.h"
void exthrower() {
	throw myexception();
}

test.cpp:
#include <cstdio>
#include "myex.h"
int main(void) {
	try { exthrower(); }
	catch(const myexception& e) {
		printf("Exception caught\n");
	}
	return 0;
}

build with:
g++ -fPIC -c -o myex.o myex.cpp
ld -shared -soname libtest.so -o libtest.so myex.o
g++ -fPIC -c -o test.o test.cpp
g++ -nodefaultlibs -o test test.o -lgcc_s -lsupc++ -lc -L. -ltest

When I run the application I get:
> terminate called after throwing an instance of 'myexception'
> Aborted
(which is the behaviour I'm experiencing with my OS atm, too. Although I
have to threat the zero-symbol special by searching for the symbol and
using that value to prevent other problems. But thats perhaps a different
story, I don't know...)
Note in the last g++-command, that I try to use the same stuff like
when doing that for my OS. So, just libc, libgcc (actually I'm using the
static one for my OS, but I think that shouldn't matter) and libsupc++.

If I instead use g++ to link libtest.so:
g++ -shared -Wl,-soname,libtest.so -o libtest.so myex.o -nostdlib
Everything works fine:
> Exception caught

No matter whether using ld or g++ the shared library has R_386_32-relocations with
a symbol-value of 0. So perhaps thats ok and the problem is really, that I can't
use ld to build it? Although I don't know what exactly causes the problem when
using ld...

Nils Asmussen


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