首页 > 解决方案 > 如何编译调用printf的nasm程序?

问题描述

https://cs.lmu.edu/~ray/notes/nasmtutorial/

尝试fib.asm在 Linux 上编译时出现以下错误。你能告诉我如何编译它吗?谢谢。

$ nasm -felf64 fib.asm && gcc fib.o && ./a.out
/usr/bin/ld: fib.o: warning: relocation in read-only section `.text'
/usr/bin/ld: fib.o: relocation R_X86_64_PC32 against symbol `printf@@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

标签: linuxassemblyx86-64nasmglibc

解决方案


推荐阅读