Page 1 of 1

Why isn't bootstrap_stack .bss?

Posted: Tue Apr 29, 2014 4:42 am
by dlarudgus20
While reading http://wiki.osdev.org/C%2B%2B_Bare_Bones, I found a strange thing. ld gives me this error.
ld: warning: section `.bss' type changed to PROGBITS
I figured out what it is, and I fixed like this (because stack doesn't need to be initialized zero, and it's better for kernel to be more small-size.)

(Please notice I'm using NASM.)

Code: Select all

; boot.asm
section .bss    ; changed from .bootstrap_stack
align 4
stack_bottom:
resb 16384     ; changed from times 16384 db 0
stack_top:

/* linker.ld */
.bss BLOCK(4K) : ALIGN(4K)
{
	*(COMMON)
	*(.bss)
	/* *(.bootstrap_stack) */ /* removed */
}
When I test this, there's no problem. Then, why "C++ Bare Bones" code isn't like this? Is there any reason?

Re: Why isn't bootstrap_stack .bss?

Posted: Tue Apr 29, 2014 5:30 am
by sortie
Note there no longer is a C++ Bare Bones, but a unified C and C++ Bare Bones.

You forgot to read the instructions carefully and did a common beginner mistake: Taking assembly for one assembler and translating it to another assembler, poorly. Think about it, if you really prefer your alternate assembler that much, you should get to know it much better. Anyways, what you missed is that we already ported the bootstrap assembly to NASM: http://wiki.osdev.org/Bare_Bones_with_NASM - note the "Alternatively, you can use NASM as your assembler." link in the Bare Bones tutorial. :-)

The bootstrap stack is not in the bss to allow you to customize its linked location using the linker script. Indeed, you may even be able to discard it once your operating system no longer needs it and reuse the memory for other purposes. The main rationale for doing things this way is just to show it can be done in this manner. The reason you got a warning was that you tried to put initialized (zero values) in the bss rather than just uninitialized values.

Good luck!