Created
April 4, 2013 05:18
-
-
Save depressed-pho/5308015 to your computer and use it in GitHub Desktop.
Old binutils fails to link a shared library if there is a reference to a hidden symbol that isn't locally defined.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void callee() { | |
/* Look I'm not declared as a hidden symbol! */ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__attribute__((__visibility__("hidden"))) void callee(); | |
void caller() { | |
callee(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% gmake | |
ld -v | |
GNU ld version 2.17.50.0.6-20.el5_8.3 20061020 | |
gcc -fPIC -o caller.o -c caller.c | |
gcc -fPIC -o callee.o -c callee.c | |
gcc -shared -o libfoo.so caller.o callee.o | |
/usr/bin/ld: caller.o: relocation R_X86_64_PC32 against `callee' can not be used when making a shared object; recompile with -fPIC | |
/usr/bin/ld: final link failed: Bad value | |
collect2: ld returned 1 exit status | |
gmake: *** [all] Error 1 | |
% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% gmake | |
ld -v | |
GNU ld (NetBSD Binutils nb1) 2.21.1 | |
gcc -fPIC -o caller.o -c caller.c | |
gcc -fPIC -o callee.o -c callee.c | |
gcc -shared -o libfoo.so caller.o callee.o | |
% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all: | |
ld -v | |
gcc -fPIC -o caller.o -c caller.c | |
gcc -fPIC -o callee.o -c callee.c | |
gcc -shared -o libfoo.so caller.o callee.o | |
clean: | |
rm -f *.o *.so |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment