baremetal: get exit status working with on_exit :-)

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-08 00:00:01 +00:00
parent 18ca0b3c9c
commit 406ee82cf3
16 changed files with 79 additions and 34 deletions

View File

@@ -0,0 +1,5 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
.global main
main:
mov x0, 1
ret

View File

@@ -0,0 +1,5 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
.global main
main:
mov r0, #1
bx lr

View File

@@ -1,6 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
int main(void) {
exit(0);
}

7
baremetal/exit0.c Normal file
View File

@@ -0,0 +1,7 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
#include <stdlib.h>
int main(void) {
exit(0);
}

View File

@@ -1,4 +1,5 @@
#include <stdio.h>
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
#include <stdlib.h>
int main(void) {

View File

@@ -14,6 +14,12 @@ mystart:
/* Prepare the stack for main, mandatory for C code. */
ldr x0, =stack_top
mov sp, x0
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
adr x0, lkmc_baremetal_on_exit_callback
bl on_exit
/* Run main. */
bl main
/* If main returns, exit. */

View File

@@ -1,5 +1,16 @@
#include <lkmc.h>
.global mystart
mystart:
/* Prepare the stack for main, mandatory for C code. */
ldr sp, =stack_top
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
ldr r0, =lkmc_baremetal_on_exit_callback
bl on_exit
/* Run main. */
bl main
/* If main returns, exit. */
bl exit

View File

@@ -1 +1,2 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
int main(void) { return 1; }

View File

@@ -1 +1,2 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
int main(void) { return 2; }