I have been compiling some C programs for my OS and noticed GCC adding a bunch of 'junk' to the end of the executable files.
Code: Select all
int main()
{
unsigned int i=1;
i = i - 1;
return i;
}
and then link as: ld -T app.ld -o test.app test.o
The output is a flat binary but much larger than necessary.
Code: Select all
[root@baremetal-dev prime]# ndisasm -b 64 test.app
00000000 31C0 xor eax,eax
00000002 C3 ret
00000003 0000 add [rax],al
00000005 0000 add [rax],al
00000007 001400 add [rax+rax],dl
0000000A 0000 add [rax],al
0000000C 0000 add [rax],al
0000000E 0000 add [rax],al
00000010 017A52 add [rdx+0x52],edi
00000013 0001 add [rcx],al
00000015 7810 js 0x27
00000017 011B add [rbx],ebx
00000019 0C07 or al,0x7
0000001B 089001000014 or [rax+0x14000001],dl
00000021 0000 add [rax],al
00000023 001C00 add [rax+rax],bl
00000026 0000 add [rax],al
00000028 D8FF fdivr st7
0000002A FF db 0xff
0000002B FF03 inc dword [rbx]
0000002D 0000 add [rax],al
0000002F 0000 add [rax],al
00000031 0000 add [rax],al
00000033 0000 add [rax],al
00000035 0000 add [rax],al
00000037 00 db 0x00
[root@baremetal-dev prime]#
Thanks,
-Ian