6

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 <unistd.h>
#include <string.h>

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 <_main>:
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 <_a>:
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
| improve this question | | | | |
10

You can use objdump. See man objdump. For example -d option for disassemble (there are a lot of options):

objdump -d a.o

Another useful programs are included in binutils.

| improve this answer | | | | |
0

See objdump options. For example:

objdump -d a.o

objdump -D a.o

objdump -S a.o

enter image description here

| improve this answer | | | | |
  • Don't post images of text. – RalfFriedl Aug 21 '19 at 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.