我有以下程序,exitc.s:
[OP@localhost linking]$ cat exitc.s
.section .text
.globl _start
_start:
call exit
以下列方式构建:
[OP@localhost linking]$ as exitc.s -o exitc.o
[OP@localhost linking]$ ld exitc.o -o exitc -lc -I /usr/lib64/ld-linux-x86-64.so.2
通过gdb
运行时,会发生以下情况:
(gdb) disas _start
Dump of assembler code for function _start:
0x0000000000401020 <+0>: callq 0x401010 <exit@plt>
End of assembler dump.
(gdb) break *_start
Breakpoint 1 at 0x401020
(gdb) run
Starting program: /path/to/linking/exitc
Breakpoint 1, 0x0000000000401020 in _start ()
(gdb) disas _start
Dump of assembler code for function _start:
=> 0x0000000000401020 <+0>: callq 0x401010 <exit@plt>
End of assembler dump.
(gdb) si
0x0000000000401010 in exit@plt ()
(gdb) disas 0x401010
Dump of assembler code for function exit@plt:
=> 0x0000000000401010 <+0>: jmpq *0x2002(%rip) # 0x403018 <[email protected]>
0x0000000000401016 <+6>: pushq $0x0
0x000000000040101b <+11>: jmpq 0x401000
End of assembler dump.
(gdb) si
0x0000000000401016 in exit@plt ()
(gdb) disas 0x401010
Dump of assembler code for function exit@plt:
0x0000000000401010 <+0>: jmpq *0x2002(%rip) # 0x403018 <[email protected]>
=> 0x0000000000401016 <+6>: pushq $0x0
0x000000000040101b <+11>: jmpq 0x401000
End of assembler dump.
在组装的最后一步,为什么不跳转?