How can I force UEFI to zero my PE BSS section?
Posted: Wed Oct 19, 2016 9:21 pm
I'm currently writing a UEFI based operating system using Rust. This means that it's generating LLVM IR, and then compiling that down to ASM, before I link it with a bare bones C entry point.
My question is:
How do I force the BSS to be zeroed before my UEFI Loader starts executing? Currently Rust is making an optimization by having a mutex that starts initialized to all zeroes live in .bss, but when my program loads i'm instead getting garbage.
If I ask the compiler to make the object start with a struct of {0u8, 1u8}, I can see that it is correct when the program loads. If instead I ask it to start with {0u8, 0u8}, the memory is filled with 0xafafafaf. When I examine the objdump of the library, I can see the following:
Does anyone know how to force 0-initialization for .bss sections when loading your program under UEFI?
My question is:
How do I force the BSS to be zeroed before my UEFI Loader starts executing? Currently Rust is making an optimization by having a mutex that starts initialized to all zeroes live in .bss, but when my program loads i'm instead getting garbage.
If I ask the compiler to make the object start with a struct of {0u8, 1u8}, I can see that it is correct when the program loads. If instead I ask it to start with {0u8, 0u8}, the memory is filled with 0xafafafaf. When I examine the objdump of the library, I can see the following:
Code: Select all
objdump -t kernel/target/x86_64-unknown-pintos/debug/libkernel.a | ag WRITER
0000000000000000 l O .bss._ZN6kernel6serial13SERIAL_WRITER17h796764bd9f75b31cE 0000000000000002 _ZN6kernel6serial13SERIAL_WRITER17h796764bd9f75b31cE
0000000000000000 l d .bss._ZN6kernel6serial13SERIAL_WRITER17h796764bd9f75b31cE 0000000000000000 .bss._ZN6kernel6serial13SERIAL_WRITER17h796764bd9f75b31cE