Nasm - Symbol `printf' causes overflow in R_X86_64_PC32 relocation

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 01:56:34

try compiling with -no-pie, check out these posts for explanation: Assembling with GCC causes weird relocation error with regards to .data

in short:

Debian switched to PIC/PIE binaries in 64-bits mode & GCC in your case is trying to link your object as PIC, but it will encounter absolute address in mov $str, %rdi.

Full credit to https://stackoverflow.com/users/3062591/brian

for figuring out how to get this to work. If you're like me and very new to nasm OR if for some reason you're new to nasm and have done little to nothing with gcc then you're going to need to run the command:

nasm -felf64 YOUR_FILE.asm && gcc -no-pie YOUR_FILE.o && ./a.out

I was able to get this using a

call printf

without needing to change it to

printf wrt ..got

which had on previous attempts with some NASM introductory examples but not all.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!