ld: link order changes behavior

hauke strasdat strasdat@gmail.com
Wed Dec 7 00:28:00 GMT 2011
Hi,

I hope this is the right place to ask this question. If not, I apologize!

I do have two object files (foo.cpp.o, main.cpp.o).

The first link order produces one result (=correct result):
/usr/bin/g++-4.4   -g  foo.cpp.o main.cpp.o -o test
./test
output: 1

The other link order produces a different result (=incorrect result):
/usr/bin/g++-4.4   -g  main.cpp.o foo.cpp.o -o test
./test
output: -1

Could this be a linker bug? If yes, I would go ahead and file a bug report.
Or is a different cause likely?

Thanks,
Hauke

 ld -v
GNU ld (GNU Binutils for Ubuntu) 2.21.53.20110810



More information about the Binutils mailing list