mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
Start nostartfiles examples.
Interlink freestanding directories and readme.
This commit is contained in:
14
README.adoc
14
README.adoc
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
1
userland/arch/aarch64/freestanding/README.adoc
Normal file
1
userland/arch/aarch64/freestanding/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#freestanding-programs
|
||||
1
userland/arch/aarch64/nostartfiles/README.adoc
Normal file
1
userland/arch/aarch64/nostartfiles/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#nostartfiles-programs
|
||||
1
userland/arch/aarch64/nostartfiles/build
Symbolic link
1
userland/arch/aarch64/nostartfiles/build
Symbolic link
@@ -0,0 +1 @@
|
||||
../build
|
||||
4
userland/arch/aarch64/nostartfiles/exit.S
Normal file
4
userland/arch/aarch64/nostartfiles/exit.S
Normal file
@@ -0,0 +1,4 @@
|
||||
.global _start
|
||||
_start:
|
||||
mov x0, 0
|
||||
bl exit
|
||||
1
userland/arch/aarch64/nostartfiles/test
Symbolic link
1
userland/arch/aarch64/nostartfiles/test
Symbolic link
@@ -0,0 +1 @@
|
||||
../test
|
||||
1
userland/arch/arm/freestanding/README.adoc
Normal file
1
userland/arch/arm/freestanding/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#freestanding-programs
|
||||
1
userland/arch/x86_64/freestanding/README.adoc
Normal file
1
userland/arch/x86_64/freestanding/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#freestanding-programs
|
||||
Reference in New Issue
Block a user