情况
环境
Arch Linux x86-64 (4.2.3-1-ARCH)
海合会
海合会 (GCC) 5.2.0
命令
gcc -Wall -g -o asm_printf asm_printf.s
错误
/usr/bin/ld: /tmp/cct4fa.o: Relocation R_X86_64_32S against '.data' can not be used when making a shared object; recompile with -fPIC /tmp/cct4fa.o:err adding symbols: Bad value collect2: error: ld returned 1 exit status
代码
.section .data msg: .asciz "Printf In Assembly!!\n" .section .text .globl main main: pushq $msg call printf addq $8 %esp pushq $0 call exit
问题
我尝试使用上述命令gcc
部分中的命令编译上述代码部分中的程序,并最终在错误部分中出现错误。
请注意,我不是在编译共享库。
- 这是什么错误?
- 我该如何解决?