状況
環境
Arch Linux x86-64 (4.2.3-1-ARCH)
GCC
gcc (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
のプログラムをコンパイルしようとしましたが、エラーセクションでエラーが発生しました。
共有ライブラリをコンパイルしていないことに注意してください。
- このエラーは何ですか?
- これを修正するにはどうすればよいですか?