アセンブリプログラムをコンパイルしてリンクしようとしています。
アセンブリファイル(main.asm):
.section .text
.global main
main:
mov $msg, %rdi
call printf
xor %rax, %rax
mov $80, %rdi
syscall
msg:
.ascii "hello world\n\0"
LDスクリプト:
ENTRY(main)
SECTIONS
{
. = 0x10000;
.text : {
*(.text)
}
}
コンパイルコマンド(成功的に終了):
as -c main.asm -o main.o
リンクコマンド:
ld main.o -o main -Tbin.ld -lc
*printf*
未定義の参照エラーやその他の関連シンボルのため、最後のコマンドは失敗します。
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: out/main: section .tdata lma 0xaef90 adjusted to 0xaefd0
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(printf_fp.o): in function `__printf_fp_l':
(.text+0x4d0): undefined reference to `__unordtf2'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: (.text+0x501): undefined reference to `__unordtf2'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: (.text+0x523): undefined reference to `__letf2'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(printf_fphex.o): in function `__printf_fphex':
(.text+0x94): undefined reference to `__unordtf2'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: (.text+0xce): undefined reference to `__unordtf2'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: (.text+0xea): undefined reference to `__letf2'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(iofclose.o): in function `_IO_new_fclose.cold.0':
(.text.unlikely+0x35): undefined reference to `_Unwind_Resume'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(iofclose.o):(.data.rel.local.DW.ref.__gcc_personality_v0[DW.ref.__gcc_personality_v0]+0x0): undefined reference to `__gcc_personality_v0'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(iofflush.o): in function `_IO_fflush.cold.0':
(.text.unlikely+0x35): undefined reference to `_Unwind_Resume'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(iofputs.o): in function `_IO_fputs.cold.0':
(.text.unlikely+0x35): undefined reference to `_Unwind_Resume'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(iofwrite.o): in function `_IO_fwrite.cold.0':
(.text.unlikely+0x35): undefined reference to `_Unwind_Resume'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(iogetdelim.o): in function `_IO_getdelim.cold.0':
(.text.unlikely+0x35): undefined reference to `_Unwind_Resume'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(wfileops.o): in function `_IO_wfile_underflow.cold.2':
(.text.unlikely+0x37): undefined reference to `_Unwind_Resume'
/nix/store/b10shv9yqbgps47y0n8x7l7bq8fmp1i6-binutils-2.31.1/bin/ld: /nix/store/9xjk9wgkdqkh5vw9f8brjg3bx6k8r02f-glibc-2.31-static/lib/libc.a(fileops.o):(.text.unlikely+0x38): more undefined references to `_Unwind_Resume' follow
プログラムを正常に接続して実行するにはどうすればよいですか?