0

状況


  1. 環境

    Arch Linux x86-64 (4.2.3-1-ARCH)

  2. GCC

    gcc (GCC) 5.2.0

  3. 指示

    gcc -Wall -g -o asm_printf asm_printf.s 
    
  4. エラー

    /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
    
  5. コード

    .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のプログラムをコンパイルしようとしましたが、エラーセクションでエラーが発生しました。

共有ライブラリをコンパイルしていないことに注意してください。

  1. このエラーは何ですか?
  2. これを修正するにはどうすればよいですか?

4

1 に答える 1