mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 12:04:27 +01:00
baremetal: fix heap and stack position in preparation for CLI arguments
This commit is contained in:
21
README.adoc
21
README.adoc
@@ -19482,6 +19482,27 @@ It is not possible to call those C functions from the examples that don't use a
|
||||
|
||||
For this reason, we tend to create examples with bootloaders, as it is easier to write them portably.
|
||||
|
||||
=== Baremetal linker script
|
||||
|
||||
For things to work in baremetal, we often have to layout memory in specific ways.
|
||||
|
||||
Notably, since we start with <<arm-paging,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: link: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 link:baremetal/linker_variables.c[]:
|
||||
|
||||
....
|
||||
./run --arch aarch64 --baremetal baremetal/linker_variables.c
|
||||
....
|
||||
|
||||
=== Semihosting
|
||||
|
||||
Semihosting is a publicly documented interface specified by ARM Holdings that allows us to do some magic operations very useful in development.
|
||||
|
||||
Reference in New Issue
Block a user