baremetal: fix heap and stack position in preparation for CLI arguments

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2020-04-01 02:00:01 +00:00
parent 6bb20c0386
commit e25e79c26b
9 changed files with 58 additions and 11 deletions

View File

@@ -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.