I wanted to check the disassembled code of a hello world file in c to understand the assembly instructions it was using to run the code.
I tried compiling the Hello.c file to the object code using gcc Hello.c -c Hello.o
and used objdump to disassemble the file into a Hello.s file. The command was objdump -D -Mamd64 ./Hello.o >> a.s
. But when I searched for the “Hello, World” string or other things like printf, I did not find them in the disassembled file.
Here is the C file:
#include <stdio.h>
int main(void)
{
printf("Hello, World!");
return 0;
}
and the disassembled file:
./Hello.o: file format pe-i386
Disassembly of section .text:
00000000 <_main>:
0: 55 push %ebp
1: 89 e5 mov %esp,%ebp
3: 83 e4 f0 and $0xfffffff0,%esp
6: 83 ec 10 sub $0x10,%esp
9: e8 00 00 00 00 call e <_main+0xe>
e: c7 04 24 00 00 00 00 movl $0x0,(%esp)
15: e8 00 00 00 00 call 1a <_main+0x1a>
1a: b8 00 00 00 00 mov $0x0,%eax
1f: c9 leave
20: c3 ret
21: 90 nop
22: 90 nop
23: 90 nop
Disassembly of section .rdata:
00000000 <.rdata>:
0: 48 dec %eax
1: 65 6c gs insb (%dx),%es:(%edi)
3: 6c insb (%dx),%es:(%edi)
4: 6f outsl %ds:(%esi),(%dx)
5: 2c 20 sub $0x20,%al
7: 57 push %edi
8: 6f outsl %ds:(%esi),(%dx)
9: 72 6c jb 77 <.rdata+0x77>
b: 64 21 00 and %eax,%fs:(%eax)
...
Disassembly of section .rdata$zzz:
00000000 <.rdata$zzz>:
0: 47 inc %edi
1: 43 inc %ebx
2: 43 inc %ebx
3: 3a 20 cmp (%eax),%ah
5: 28 4d 69 sub %cl,0x69(%ebp)
8: 6e outsb %ds:(%esi),(%dx)
9: 47 inc %edi
a: 57 push %edi
b: 2e 6f outsl %cs:(%esi),(%dx)
d: 72 67 jb 76 <.rdata$zzz+0x76>
f: 20 47 43 and %al,0x43(%edi)
12: 43 inc %ebx
13: 2d 36 2e 33 2e sub $0x2e332e36,%eax
18: 30 2d 31 29 20 36 xor %ch,0x36202931
1e: 2e 33 2e xor %cs:(%esi),%ebp
21: 30 00 xor %al,(%eax)
...
Disassembly of section .eh_frame:
00000000 <.eh_frame>:
0: 14 00 adc $0x0,%al
2: 00 00 add %al,(%eax)
4: 00 00 add %al,(%eax)
6: 00 00 add %al,(%eax)
8: 01 7a 52 add %edi,0x52(%edx)
b: 00 01 add %al,(%ecx)
d: 7c 08 jl 17 <.eh_frame+0x17>
f: 01 1b add %ebx,(%ebx)
11: 0c 04 or $0x4,%al
13: 04 88 add $0x88,%al
15: 01 00 add %eax,(%eax)
17: 00 1c 00 add %bl,(%eax,%eax,1)
1a: 00 00 add %al,(%eax)
1c: 1c 00 sbb $0x0,%al
1e: 00 00 add %al,(%eax)
20: 04 00 add $0x0,%al
22: 00 00 add %al,(%eax)
24: 21 00 and %eax,(%eax)
26: 00 00 add %al,(%eax)
28: 00 41 0e add %al,0xe(%ecx)
2b: 08 85 02 42 0d 05 or %al,0x50d4202(%ebp)
31: 5d pop %ebp
32: c5 0c 04 lds (%esp,%eax,1),%ecx
35: 04 00 add $0x0,%al
...
rahulc0dy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.