Sample Header Ad - 728x90

What tool to use to view an object file?

10 votes
2 answers
18512 views
I'm reading an old book on linkers and loaders and it has images of object code. But I can't figure out what tools are used to display the contents of these files. I'd appreciate if someone could point out the tool. Here is the C code and corresponding display of the object files. Source file m.c: extern void a(char *); int main(int argc, char **argv) { static char string[] = "Hello, world!\n"; a(string); } Source file a.c: #include #include void a(char *s) { write(1, s, strlen(s)); } Object code for m.o: Sections: Idx Name Size VMA LMA File off Algn 0 .text 00000010 00000000 00000000 00000020 2**3 1 .data 00000010 00000010 00000010 00000030 2**3 Disassembly of section .text: 00000000 : 0: 55 pushl %ebp 1: 89 e5 movl %esp,%ebp 3: 68 10 00 00 00 pushl $0x10 4: 32 .data 8: e8 f3 ff ff ff call 0 9: DISP32 _a d: c9 leave e: c3 ret ... Object code for a.o: Sections: Idx Name Size VMA LMA File off Algn 0 .text 0000001c 00000000 00000000 00000020 2**2 CONTENTS, ALLOC, LOAD, RELOC, CODE 1 .data 00000000 0000001c 0000001c 0000003c 2**2 CONTENTS, ALLOC, LOAD, DATA Disassembly of section .text: 00000000 : 0: 55 pushl %ebp 1: 89 e5 movl %esp,%ebp 3: 53 pushl %ebx 4: 8b 5d 08 movl 0x8(%ebp),%ebx 7: 53 pushl %ebx 8: e8 f3 ff ff ff call 0 9: DISP32 _strlen d: 50 pushl %eax e: 53 pushl %ebx f: 6a 01 pushl $0x1 11: e8 ea ff ff ff call 0 12: DISP32 _write 16: 8d 65 fc leal -4(%ebp),%esp 19: 5b popl %ebx 1a: c9 leave 1b: c3 ret
Asked by flashburn (691 rep)
Apr 15, 2015, 07:59 PM
Last activity: Mar 9, 2020, 04:03 PM