baremetal: implement C assert

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-08 00:00:02 +00:00
parent 406ee82cf3
commit 40169f7427
9 changed files with 101 additions and 37 deletions

View File

@@ -14012,7 +14012,14 @@ lkmc_exit_status_(\d+)
and then exit with the given regular expression, e.g.:
....
./run --arch aarch64 baremetal
./run --arch aarch64 baremetal/return2.c
echo $?
....
should output:
....
2
....
This magic output string is notably generated by:
@@ -14028,6 +14035,7 @@ So setup this `on_exit` automatically from all our <<baremetal-bootloaders>>, so
+
The following examples end up testing that our setup is working:
+
* link:baremetal/assert_fail.c[]
* link:baremetal/lkmc_assert_fail.c[]
* link:baremetal/return1.c[]
* link:baremetal/return2.c[]
@@ -14038,6 +14046,30 @@ The following examples end up testing that our setup is working:
Beware that on Linux kernel simulations, you cannot even echo that string from userland, since userland stdout shows up on the serial.
====== baremetal assert
TODO: implement enough syscalls for it, so we can get the error line:
....
cd baremetal
ln -s ../lkmc/assert_fail.c
cd ..
./build --arch aarch64
....
fails with:
....
/path/to/linux-kernel-module-cheat/out/crosstool-ng/build/default/install/aarch64/lib/gcc/aarch64-unknown-elf/8.1.0/../../../../aarch64-unknown-elf/lib/libg.a(lib_a-signalr.o): In function `_kill_r':
/path/to/linux-kernel-module-cheat/out/crosstool-ng/build/default/build/aarch64-unknown-elf/src/newlib/newlib/libc/reent/signalr.c:53: undefined reference to `_kill'
/path/to/linux-kernel-module-cheat/out/crosstool-ng/build/default/build/aarch64-unknown-elf/src/newlib/newlib/libc/reent/signalr.c:53:(.text+0x20): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `_kill'
/path/to/linux-kernel-module-cheat/out/crosstool-ng/build/default/install/aarch64/lib/gcc/aarch64-unknown-elf/8.1.0/../../../../aarch64-unknown-elf/lib/libg.a(lib_a-signalr.o): In function `_getpid_r':
/path/to/linux-kernel-module-cheat/out/crosstool-ng/build/default/build/aarch64-unknown-elf/src/newlib/newlib/libc/reent/signalr.c:83: undefined reference to `_getpid'
/path/to/linux-kernel-module-cheat/out/crosstool-ng/build/default/build/aarch64-unknown-elf/src/newlib/newlib/libc/reent/signalr.c:83:(.text+0x44): relocation truncated to fit: R_AARCH64_JUMP26 against undefined symbol `_getpid'
....
at 406ee82cf33a6e3df0067b219b0414c59d7018b3 + 1.
==== Non-automated tests
===== Test GDB Linux kernel