Start nostartfiles examples.

Interlink freestanding directories and readme.
This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-08-25 00:00:00 +00:00
parent 06374cda42
commit 96239298a9
9 changed files with 32 additions and 1 deletions

View File

@@ -13170,7 +13170,11 @@ The C standard library infrastructure is implemented in the common userland / ba
==== Freestanding programs
Unlike most our other assembly examples, which use the C standard library for portability, examples under `freestanding/` directories don't link to the C standard library.
Unlike most our other assembly examples, which use the C standard library for portability, examples under `freestanding/` directories don't link to the C standard library:
* link:userland/arch/x86_64/freestanding/[]
* link:userland/arch/arm/freestanding/[]
* link:userland/arch/aarch64/freestanding/[]
As a result, those examples cannot do IO portably, and so they make raw system calls and only be run on one given OS, e.g. <<linux-system-calls>>.
@@ -13185,6 +13189,14 @@ In order to GDB step debug those executables, you will want to use `--no-continu
You are now left on the very first instruction of our tiny executable!
===== nostartfiles programs
Assembly examples under `nostartfiles` directories can use the standard library, but they don't use the pre-`main` boilerplate and start directly at our explicitly given `_start`:
* link:userland/arch/aarch64/freestanding/[]
I'm not sure how much stdlib functionality is supposed to work without the pre-main stuff, but I guess we'll just have to find out!
=== GCC inline assembly
Examples under `arch/<arch>/c/` directories show to how use inline assembly from higher level languages such as C:

View File

@@ -260,6 +260,7 @@ gnu_extension_properties = {
'cc_pedantic': False,
'cxx_std': 'gnu++17'
}
# https://github.com/cirosantilli/linux-kernel-module-cheat#freestanding-programs
freestanding_properties = {
'baremetal': False,
'cc_flags': [
@@ -269,6 +270,13 @@ freestanding_properties = {
],
'extra_objs_lkmc_common': False,
}
# https://github.com/cirosantilli/linux-kernel-module-cheat#nostartfiles-programs
nostartfiles_properties = {
'baremetal': False,
'cc_flags': [
'-nostartfiles', LF,
],
}
# See: https://cirosantilli.com/linux-kernel-module-cheat#path-properties
path_properties_tuples = (
PathProperties.default_properties,
@@ -405,6 +413,7 @@ path_properties_tuples = (
'freestanding': freestanding_properties,
'lkmc_assert_eq_fail.S': {'signal_received': signal.Signals.SIGABRT},
'lkmc_assert_memcmp_fail.S': {'signal_received': signal.Signals.SIGABRT},
'nostartfiles': nostartfiles_properties,
'udf.S': {
'signal_generated_by_os': True,
'signal_received': signal.Signals.SIGILL,

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#freestanding-programs

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#nostartfiles-programs

View File

@@ -0,0 +1 @@
../build

View File

@@ -0,0 +1,4 @@
.global _start
_start:
mov x0, 0
bl exit

View File

@@ -0,0 +1 @@
../test

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#freestanding-programs

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#freestanding-programs