I am learing assembly language recently and I want to run 64 bit assembly code file.
but when I try assembling and linking my file with gcc -o test1 test1.s
command, I encounter an error:
/usr/bin/ld: /tmp/ccdyRWWG.o: relocation R_X86_64_32S against `.data' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
This is the code that I wrote.
.section ".rodata"
printFormat:
.asciz "%d\n"
### --------------------------------------------------------------------
.section ".data"
### --------------------------------------------------------------------
.section ".bss"
### --------------------------------------------------------------------
.section ".text"
.text
.globl main
.type main, @function
main:
movq $0x1111222233334444, %rax
pushq %rax
pushq $printFormat
call printf
addq $16, %rsp
movq $0, %rax
ret
I can assemble/link the file if I erase pushq $printFormat
in the main function but the code written above makes error. How can I fix the problem?