linux程序运行出现段错误
发布网友
发布时间:2022-04-21 19:18
我来回答
共1个回答
热心网友
时间:2023-06-29 16:17
我这里是ubuntu x86-64,照着抄你的代码运行非常正常。
编译运行:
as run.s -o run.o
ld run.o -o run
./run
GDB调试也没问题
GNU gdb (Ubuntu 8.1.1-0ubuntu1) 8.1.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from run...done.
(gdb) b _start
Breakpoint 1 at 0x400078: file run.s, line 6.
(gdb) r
Starting program: /home/×××××××/Desktop/run
Breakpoint 1, _start () at run.s:6
6 movl $1, %eax
(gdb) ni
7 movl $0, %ebx
(gdb) ni
8 int $0x80
(gdb) ni
[Inferior 1 (process 10617) exited normally]
(gdb) b _start