yasukata / zpoline

system call hook for Linux
Apache License 2.0
408 stars 32 forks source link

relocation R_X86_64_PC32 against symbol `syscall_hook' can not be used when making a shared object; recompile with -fPIC #11

Closed 98hq closed 9 months ago

98hq commented 9 months ago

When I type make, the error is as follows:

gcc -O3 -pipe -Werror -Wall -Wunused-function -Wextra -shared -fPIC   -c -o main.o main.c
gcc -O3 -pipe -Werror -Wall -Wunused-function -Wextra -shared -fPIC -o libzpoline.so main.o -lopcodes -ldl
/usr/bin/ld: main.o: relocation R_X86_64_PC32 against symbol `syscall_hook' 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
Makefile:30: recipe for target 'libzpoline.so' failed
make: *** [libzpoline.so] Error 1

The version of gcc I use is gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04), May I know your operating system and software configuration?

98hq commented 9 months ago

This problem has been solved, you can refer to the link below https://stackoverflow.com/questions/52126328/cant-call-c-standard-library-function-on-64-bit-linux-from-assembly-yasm-code

yasukata commented 9 months ago

Thank you very much for reporting the issue and providing the solution.