링크 어셈블러

링크 어셈블러

어셈블리 프로그램을 컴파일하고 링크하려고 합니다.

어셈블리 파일(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

프로그램을 성공적으로 연결하고 실행하려면 어떻게 해야 합니까?

관련 정보