Well, I use nasm
to produce test.o
from my test.s
. When I then run gcc test.o
, it gives me the error message
/usr/bin/ld: test.o: relocation R_X86_64_PC32 against symbol `puts@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld: final link failed: bad value collect2: error: ld returned 1 exit status
test.s:
global main
extern puts
section .text
main:
mov rdi, message
call puts
ret
message:
db "Hello World", 0
What this error message means and how to fix it?
Also, in this case i use gcc
to link my object file with the standard library, but how can i use ld
to do the same job?
I am running Ubuntu 20.04 LTS