Error while linking x86_64 assembly file

I was trying to assemble and link this file, but when i try to link it with the following command:

gcc x64_hello.o -o x64_hello.elf -nostdlib

gcc throws the following error:

/usr/bin/ld: x64_hello.o: relocation R_X86_64_32S against '.data' can not be used when making a PIE object; recompile with -fPIE /usr/bin/ld: Failed to set dynamic section sizes: bad value collect2: error: ld returned exit status 1

2 points · 2 comments · view on lemmy.world

2 Comments

orclev@lemmy.world · 2 pts · 2y (2 replies)

Seems like the error is telling you how to fix it. There seems to be a mismatch between something that wants PIE enabled and something that doesn't have it enabled. Without a better understanding of what you're doing I can't provide much more help other than to say maybe try disabling or enabling PIE at various points.

prettydarknwild@lemmy.world · 1 pts · 2y
[ removed ]
prettydarknwild@lemmy.world · 1 pts · 2y

here is the file: https://pastebin.com/ujyQBTy6, i was trying to do a hello world like i would do it in x86 assembly