33.3. Baremetal linker script
For things to work in baremetal, we often have to layout memory in specific ways.
Notably, since we start with paging disabled, there are more constraints on where memory can or cannot go.
Especially for C programs, this memory layout is specified by a "linker script", which is present at: baremetal/link.ld
Note how our linker script also exposes some symbols to C:
lkmc_heap_low = .; lkmc_heap_top = .;
Those for example are required to implement malloc
in Newlib. We can play with those variables more explicitly with baremetal/linker_variables.c:
./run --arch aarch64 --baremetal baremetal/linker_variables.c