更新时间:2015年12月28日16时40分 来源:传智播客C/C++学科 浏览次数:
$ objdump libmymath.so -dS
...
00000538 <add>:
538: 55 push %ebp
539: 89 e5 mov %esp,%ebp
53b: 8b 45 0c mov 0xc(%ebp),%eax
53e: 8b 55 08 mov 0x8(%ebp),%edx
541: 01 d0 add %edx,%eax
543: 5d pop %ebp
544: c3 ret
Disassembly of section .fini:
...
$ objdump -dS app
...
Disassembly of section .plt:
08048460 <add@plt-0x10>:
8048460: ff 35 04 a0 04 08 pushl 0x804a004
8048466: ff 25 08 a0 04 08 jmp *0x804a008
804846c: 00 00 add %al,(%eax)
...
08048470 <add@plt>:
8048470: ff 25 0c a0 04 08 jmp *0x804a00c
8048476: 68 00 00 00 00 push $0x0
804847b: e9 e0 ff ff ff jmp 8048460 <_init+0x2c>
...
080485cd <main>:
int main(void)
{
80485cd: 55 push %ebp
80485ce: 89 e5 mov %esp,%ebp
80485d0: 83 e4 f0 and $0xfffffff0,%esp
80485d3: 83 ec 20 sub $0x20,%esp
int a = 5;
80485d6: c7 44 24 18 05 00 00 movl $0x5,0x18(%esp)
80485dd: 00
int b = 9;
80485de: c7 44 24 1c 09 00 00 movl $0x9,0x1c(%esp)
80485e5: 00
printf("%d + %d = %d\n", a, b, add(a, b));
80485e6: 8b 44 24 1c mov 0x1c(%esp),%eax
80485ea: 89 44 24 04 mov %eax,0x4(%esp)
80485ee: 8b 44 24 18 mov 0x18(%esp),%eax
80485f2: 89 04 24 mov %eax,(%esp)
80485f5: e8 76 fe ff ff call 8048470 <add@plt>
...
$ gdb app
...
(gdb) start
Temporary breakpoint 1 at 0x80485d6: file main.c, line 6.
Starting program: /home/itcast/lib/app
Temporary breakpoint 1, main () at main.c:6
6 int a = 5;
(gdb) si
7 int b = 9;
(gdb) si
9 printf("%d + %d = %d\n", a, b, add(a, b));
(gdb) si
0x080485ea 9 printf("%d + %d = %d\n", a, b, add(a, b));
(gdb) si
0x080485ee 9 printf("%d + %d = %d\n", a, b, add(a, b));
(gdb) si
0x080485f2 9 printf("%d + %d = %d\n", a, b, add(a, b));
(gdb) si
0x080485f5 9 printf("%d + %d = %d\n", a, b, add(a, b));
(gdb) si
0x08048470 in add@plt ()
(gdb) x 0x804a00c
0x804a00c <add@got.plt>: 0x08048476
(gdb) si
0x08048470 in add@plt ()
(gdb) si
0x08048476 in add@plt ()
(gdb) si
0x0804847b in add@plt ()
(gdb) si
0x08048460 in ?? ()
(gdb) si
0x08048466 in ?? ()
(gdb) si
0xf7ff04f0 in ?? () from /lib/ld-linux.so.2
(gdb) si
0xf7ff04f2 in ?? () from /lib/ld-linux.so.2
(gdb) finish
Run till exit from #0 0xf7ff04f2 in ?? () from /lib/ld-linux.so.2
0x080485fa in main () at main.c:9
9 printf("%d + %d = %d\n", a, b, add(a, b));
(gdb) x 0x804a00c
0x804a00c <add@got.plt>: 0xf7fd4538
(gdb) x 0xf7fd4538
0xf7fd4538 <add>: 0x8be58955