This works completely fine right now, although I have some suspicions, which I wanted to clarify.
1. ld seems to completely omit the .bss section in my NASM file, which uses RESB, when I switch to DB instead and use a different section it ends up in the exe. Is this correct?
2. For some reason the executable size drastically changes when I move sections around in the linker.ld script.
For example:
Code: Select all
.data ALIGN(4K) : AT (ADDR (.data) - 0xC0000000)
{
*(.data)
*(.paging_structures)
}
.bss ALIGN(4K) : AT (ADDR (.bss) - 0xC0000000)
{
*(COMMON)
*(.bss)
*(.kernel_stack)
}
Moving everything from .bss to .data decreases the binary file from 103K to 98K.
What is going on here? Is it omitting anything? Is it alignment changing the size so much?
What happens if i put a custom section into bss? Does it not end up in the binary file as well?
All the experimenting that i've done so far shows absolutely controversial results so it's impossible to tell what's happening.
For example putting a huge uninitialized static array of 4MB in a .cpp file and then iterating over (so it doesn't get optimized out) does increase the executable to 4MB+
Why???? So is .bss in the binary or not, I'm super confused...
And one last thing, how difficult do you think it would be to make a simple elf loader in assembly? I'm tired of this raw binary weirdness and just wanna get rid of it...
The most complicated part is probably finding a spot to load the elf first then parsing it and then somehow loading the kernel in the same place where the elf header was, I'm not sure
how that would even work, hence why I'm asking.
Thanks
