1 2 3 4 5 6 7 8 9 10 11 12 13 | /* m.c */ int i = 1; int j = 2; extern int sum(); void main() { int s; s = sum(i, j); /* f.c */ int sum(int i, int j) { return i + j; } |
1 2 | $ gcc -c m.c $ gcc -c f.c |
1 2 3 4 5 6 7 8 9 10 11 12 13 | $ objdump -x m.o …… SYMBOL TABLE: …… 00000000 g O .data 00000004 i 00000004 g O .data 00000004 j 00000000 g F .text 00000021 main 00000000 *UND* 00000000 sum RELOCATION RECORDS FOR [.text]: OFFSET TYPE VALUE 00000007 R_386_32 j 0000000d R_386_32 i 00000013 R_386_PC32 sum |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | $ objdump -dx m.o Disassembly of section .text: 00000000 <main>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 04 sub $0x4,%esp 6: a1 00 00 00 00 mov 0x0,%eax 7: R_386_32 j b: 50 push %eax c: a1 00 00 00 00 mov 0x0,%eax d: R_386_32 i 11: 50 push %eax 12: e8 fc ff ff ff call 13 <main+0x13> 13: R_386_PC32 sum 17: 83 c4 08 add $0x8,%esp 1a: 89 c0 mov %eax,%eax 1c: 89 45 fc mov %eax,0xfffffffc(%ebp) 1f: c9 leave 20: c3 ret |
1 2 3 4 5 6 7 8 9 10 11 | $ gcc m.o f.o $ objdump -dj .text a.out | less Disassembly of section .text: …… 080482c4 <main>: …… 80482d6: e8 0d 00 00 00 call 80482e8 <sum> 80482db: 83 c4 08 add $0x8,%esp …… 080482e8 <sum>: …… |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |