mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 12:34:26 +01:00
baremetal: get exit status working with on_exit :-)
This commit is contained in:
5
baremetal/arch/aarch64/return1.S
Normal file
5
baremetal/arch/aarch64/return1.S
Normal file
@@ -0,0 +1,5 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
|
||||
.global main
|
||||
main:
|
||||
mov x0, 1
|
||||
ret
|
||||
5
baremetal/arch/arm/return1.S
Normal file
5
baremetal/arch/arm/return1.S
Normal file
@@ -0,0 +1,5 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
|
||||
.global main
|
||||
main:
|
||||
mov r0, #1
|
||||
bx lr
|
||||
@@ -1,6 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
exit(0);
|
||||
}
|
||||
7
baremetal/exit0.c
Normal file
7
baremetal/exit0.c
Normal file
@@ -0,0 +1,7 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
exit(0);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
|
||||
int main(void) { return 1; }
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
|
||||
int main(void) { return 2; }
|
||||
|
||||
Reference in New Issue
Block a user