I try to run the following:
build.sh:
nasm -felf64 hello.asm && gcc hello.o && ./a.out
but for some reason it fails, and produces the following error, which I'm not quite sure why. I would like to know if there is any way to solve this problem.
error:
/usr/bin/ld: hello.o: warning: relocation in read-only section `.text'
/usr/bin/ld: hello.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
hello.asm
global main
extern puts
section .text
main: ; This is called by the C library startup code
mov rdi, message ; First integer (or pointer) argument in rdi
call puts ; puts(message)
ret ; Return from main back into C library wrapper
message:
db "Hello, World", 0