问题
I have the following two files in assembly:
# file.s
.globl _start
_start:
mov $10, %edi
mov $SYS_EXIT, %eax
syscall
# utils.s
SYS_EXIT = 60
SYS_WRITE = 1
SYS_STDOUT = 1
What is required to be able to link these two files into an executable. To assemble and link I've tried doing:
$ as file.s -o file.o
$ as utils.s -o utils.o
$ ld utils.o file.o -o file
# file.o: In function `_start':
# (.text+0x8): undefined reference to `SYS_EXIT'
Which seems to just mean I'm not properly importing the file/constants. What would be the proper way to do this?
来源:https://stackoverflow.com/questions/64016443/import-constants-in-x86-with-gas