Scalpel wrote:Let me see if I'm understanding this correctly.
1. bootf02 is filling the first 512 bytes of my image file, and is ended by 55AA, and thus is interpreted as a bootable disk.
2. bootf02 does it's magic with A20, memory and such.
3. The bootloader jumps to 0xFF800000, which is where my code begins.
4. In my linker script I've stated that
is the absolute beginning of my code.
5. In my loader.asm file I have a few definitions at the top, but start: is the first step run by my code. The first CPU instruction run by my code is "call _main".
6. During linking with ld, for some reason, it doesn't find the entry point called start, but since I'm using .text 0xFF800000 in my linker script it defaults to the correct address anyway.
Is it possible to use a tool to examine my .img file with a disassembler tool, and observe that "call _main" is located at 0xFF800000, or is this address only used during the actual booting process?
Hope you bear with me. I'm trying to wrap my head around this.

Yes, use a hex editor, you should see a short or far jump (depending on how far the jump is, which depends on how much assembly and C end up between the jump and your main function). Also, I use no underscores (there is an option in GCC for this, makes it much simpler for me to remember variable names!) You have start set as global, so that is good, not sure why it can't find, it, but I had a similar problem, can't remember how I fixed it, can check my script when i go home tomorrow. It's not important, you can disregard it anyways, because once you compile to binary, it loses that type of information anyways, so it's not important

. I don't align my segments on a 4096 boundary, the reason some people do this, is so they can keep data and code seperate, you can allocate data sections as read/write, and the code section as read only, this stops self modifying code from working, and can be a bit safer I guess, but I am not worried about it much, and my kernel needs to self modify itself, so not a big deal! Also, if you enable PAE, and are using 64k blocks, you would have to align on a 64k boundary, which means tons of wasted space for a smaller kernel/app. Also, unless you have a method to tell your boot loader how much of a BSS you require, put that section BEFORE the data section, this ensures that your BSS is actually in your binary flat file, so you don't have to allocate it after you load the kernel (unless you feel like it, that is fine, and if you have a very large BSS it'd be worth it to store it's size, and add that after the kernel is loaded from disk, and ZERO IT OUT!!). Anyways, hope this helps, let me know if you need more help, I have mine working pretty good and have a pretty good grasp on what's going on I think

.