带-nostdlib的_start标签不起作用

时间:2014-06-24 20:42:52

标签: x86

我一直在尝试调试我的一个代码(x86),它从标准输入读取并打印它读取的任何内容。当我使用

编译和运行时,下面的代码可以正常工作
gcc -o file file.s
./file < input > output

但是,如果我进行以下更改并使用gcc -nostdlib -o file file.s命令行参数

进行编译
./file < input > output

不再有效。我的意思是什么都不会存储到输出文件。知道为什么吗?

.global main -> .global _start
main: -> _start

代码:

.globl  main

main:
        movl    $1, %edx
        jmp     .L3

.L2:    #write
        movl    $4, %eax
        movl    $1, %ebx
        int     $0x80

.L3:    #read
        movl    $3, %eax
        movl    $0, %ebx
        int     $0x80
        cmpl    $0, %eax
        jne     .L2

0 个答案:

没有答案