GAS 32位汇编中的未定义符号错误

时间:2019-04-01 23:57:34

标签: macos assembly gas

我写了一个名为'test.s'的GAS 32位源代码,如下所示:

.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)

但是我不确定原因到底是什么...

0 个答案:

没有答案