I have allocated a small kernel stack to use while booting, but from what I can see, I can only put it either in the .bss section where it gets shared between address spaces or in the init area where it can't be stored as uninitialized data. I would like to store it in the init part of the image as uninitialized data so that each process gets its own copy.
I can think of two potential ways to do this, but I haven't been able to find out if they're possible or how I would tell the linker to do them. The first would be to put uninitialized regions in non-.bss sections, but I'm not sure that's possible- I don't think you can mix sections like that. The second would be to create a second .bss-like section that only stores uninitialized data, which I could put in the initialization pat of the linker script.
Any ideas? For completeness, here's the linker script I'm using:
Code: Select all
ENTRY(_start)
_kernel_offset = _start_kernel - _start_kernel_phys;
SECTIONS {
_start_init = 0x100000;
.init _start_init : AT(ADDR(.init)) { *(.mboot .init*) }
.ctors : {
__CTOR_NUM__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4)
__CTOR_LIST__ = .; *(.ctors*)
__CTOR_END__ = .;
}
_end_init = .;
. = ALIGN(4M);
_start_kernel_phys = .;
_start_kernel = 0xF0000000;
.text _start_kernel : AT(ADDR(.text) - _kernel_offset) { *(.text*) }
.data ALIGN(4K) : AT(ADDR(.data) - _kernel_offset) { *(.rodata* .data*) }
.bss ALIGN(4K) : AT(ADDR(.bss) - _kernel_offset) { *(.bss) *(COMMON) }
_end_kernel = .;
_end_kernel_phys = _end_kernel - _kernel_offset;
/DISCARD/ : { *(.eh_frame .comment) }
}