-
-
Save dvanhorn/d4ccb7c43464d2070f7032086c80b6e8 to your computer and use it in GitHub Desktop.
can't link an external call in a shared library
This file contains 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
int f () { | |
return 42; | |
} |
This file contains 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
default rel | |
extern f | |
global g:function | |
g: | |
call f | |
ret |
This file contains 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
$ gcc -fPIC -c f.c | |
$ nasm -f elf64 g.s | |
$ gcc -shared f.o g.o | |
/usr/bin/ld: g.o: relocation R_X86_64_PC32 against symbol `f' can not be used when making a shared object; recompile with -fPIC | |
/usr/bin/ld: final link failed: Bad value | |
collect2: error: ld returned 1 exit status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment