Неопределенная ошибка символа в 32-битной сборке GAS - PullRequest
0 голосов
/ 02 апреля 2019

Я написал 32-битный исходный код GAS с именем 'test.s', как показано ниже:

.global _main
.data
    message: .string "Hello, World!\n\0"
.text
_main:
    # BEGIN Stack Frame
    pushl %ebp
    movl %esp, %ebp

    # Call Unix System Call - write(fd, buf, count)
    pushl $1 # fd = stdout
    pushl $message # buf = message
    pushl $14 # count = 14
    call write

    # END Stack Frame
    movl %ebp, %esp
    popl %ebp

    xor %eax, %eax # return 0
    ret

и я запускаю команду в macOS 10.14.4 (Mojave), как показано ниже:

$ gcc -m32 test.s -otest

Затем произошла ошибка:

ld: warning: The i386 architecture is deprecated for macOS (removed from the Xcode build setting: ARCHS)
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
Undefined symbols for architecture i386:
    "write", referenced from:
    _main in test-8c5cf2.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Но я точно не знаю, в чем причина ...

...