I have the following program, exitc.s:
[OP@localhost linking]$ cat exitc.s
.section .text
.globl _start
_start:
call exit
Built in the following way:
[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
When running it through gdb
, the following occurs:
(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 <exit@got.plt>
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 <exit@got.plt>
=> 0x0000000000401016 <+6>: pushq $0x0
0x000000000040101b <+11>: jmpq 0x401000
End of assembler dump.
In the last step of the assembly, why does a jump not occur?
In the last step of the assembly, why does a jump not occur?
The JUMP does occur, but just happens to jump to the next instruction.
That is entirely expected, and is how lazy symbol resolution works. You can read about it eg here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.