James Malloy OS; modern infra

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.
Octocontrabass
Member
Member
Posts: 5768
Joined: Mon Mar 25, 2013 7:01 pm

Re: James Malloy OS; modern infra

Post by Octocontrabass »

teverett wrote: Sat Apr 19, 2025 12:26 pmI presume this is a typo of some sort? There shouldn't be an assembler instruction in what appears to be loader configuration?
It's incomplete, but otherwise it's correct. Multiboot doesn't follow any standard C ABI, so you need at least a little bit of assembly code at the kernel entry point to set up the stack and adjust the parameter passing. The tutorial includes code to do one of those two things.
teverett wrote: Sat Apr 19, 2025 1:39 pmok so here is a modified link.ld which sets aside some space for a stack
If you place your stack in the .bss section, you don't need to modify your linker script. You might not want to place your stack in the .bss section, but it's an option.
teverett wrote: Sat Apr 19, 2025 1:39 pm

Code: Select all

    .stack (NOLOAD):
I'm pretty sure your stack needs to be loaded. If you want it to be uninitialized data like the .bss section, that's a different flag. Normally you let the linker automatically set the output section attributes based on the input section attributes, so you'd specify the attributes of your .stack section in the assembly file where you declare it (.section .stack,"aw",@nobits) and then you wouldn't need to give it any special treatment in your linker script.
teverett wrote: Sat Apr 19, 2025 1:39 pm

Code: Select all

    asm volatile("mov %0, %%esp" : : "r" (kernel_stack_bottom));
Inline assembly is not allowed to change the stack pointer like that.
teverett wrote: Sat Apr 19, 2025 12:26 pmSo, an open question: I see lots of GitHub repo's with the James Molloy code in them from the tutorial. Did they ever actually boot?
Most of them probably did boot.
Post Reply