Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I am trying to write my own toy os, I started with making my own bootloader and then setting up gdt, segment registers and switching to protected mode and doing a far jump to 0x1000 after that I call my main function from c. At this stage when I initialized static global variables, they don't get loaded where their symbol points I confirmed this by using gdb, I found a fix by using a linker script.
This makes it so the .data is present in the memory and I can access the variables and their initialized data. I used a Hex dump tool like xxd to verify both the .elf and .bin to see if the .data was present at the .data offset and in both cases with and without linker script the data is present but it never gets loaded I even tried to use the find in gdb to look for the data bytes as I know what the data is but it isn't there, using find in gdb when the kernel is build with linker I can see that data, the missing data also happens when in linker I specify some other place to put .data. I am wondering why does this happen cause the .data is there in .bin and .elf and that's what I load so how does it go missing. Currently I am concatenating my bootloader binary and kernel binary and use the bios interrupt to load the kernel sector from hard disk to 0x1000. I read on another thread that you are supposed to load the .data yourself but the .data is simply not present not on the specified memory address or any where else in the memory.
harsh00 wrote: ↑Sat May 24, 2025 9:49 amCurrently I am concatenating my bootloader binary and kernel binary and use the bios interrupt to load the kernel sector
Only one sector? If your kernel is bigger than the number of sectors you're loading, some parts will be missing because you didn't load them.
harsh00 wrote: ↑Sat May 24, 2025 9:49 amCurrently I am concatenating my bootloader binary and kernel binary and use the bios interrupt to load the kernel sector
Only one sector? If your kernel is bigger than the number of sectors you're loading, some parts will be missing because you didn't load them.
Thank you for the help,
My kernel.bin was way bigger than 512 bytes, I loaded 10 more sectors which solved the problem