I write a small operating system in C. I wrote a bootloader, and now I'm trying to get a simple C file ("kernel") to compile with gcc :
int main(void) { return 0; }
I will compile the file with the following command:
gcc kernel.c -o kernel.o -nostdlib -nostartfiles
I use the linker to create the final image using this command:
ld kernel.o -o kernel.bin -T linker.ld --oformat=binary
The contents of the linker.ld file are as follows:
SECTIONS
{
. = 0x7e00;
.text ALIGN (0x00):
{
* (. text)
}
}
(The bootloader downloads the image at 0x7e00 .)
This works very well - ld creates a 128-byte file containing the following instructions in the first 11 bytes:
00000000 55 push ebp
00000001 48 dec eax
00000002 89 E5 mov ebp, esp
00000004 B8 00 00 00 00 mov eax, 0x00000000
00000009 5D pop ebp
0000000A C3 ret
However, I cannot understand why the remaining 117 bytes are needed. Dismantling them seems to create a bunch of garbage that makes no sense. The existence of additional bytes is interesting to me that I am doing something wrong.
Should I be bothered?

Nathan osman
source share