缺少对系统调用的引用

时间:2018-10-30 18:53:29

标签: linux assembly x86 gas

我正在看Linux上的汇编简介:

http://asm.sourceforge.net/articles/linasm.html#Compiling

我试图在其中编译hello world程序:

.data
hw:
    .string "hello world\n"
.text
.globl _start
_start:
    movl    $SYS_write,%eax
    movl    $1,%ebx
    movl    $hw,%ecx
    movl    $12,%edx
    int $0x80
    movl    $SYS_exit,%eax
    xorl    %ebx,%ebx
    int $0x80
$ gcc -c hello.s
$ ld -s -o hello hello.o
ld: hello.o: in function `_start':
(.text+0x1): undefined reference to `SYS_write'
ld: (.text+0x17): undefined reference to `SYS_exit'

所以,我想我需要告诉链接器在哪里可以找到那些符号。 (我也知道我可以在/ usr / include中的某个位置查找常量,然后将其作为文字包含在内。)

我想通过正确的调用,该程序可以编译,我缺少什么?还是只是这种情况是作者使用一种“元语言”编写的,其中这些$ SYS_ *项必须替换为内核特定的常量,而我实在是太笨拙而无法汇编呢?

0 个答案:

没有答案