Import constants in x86 with gas

≯℡__Kan透↙ 提交于 2021-01-29 18:25:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!