mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
qemu-baremetal-cli-args
QEMU part done https://github.com/cirosantilli/linux-kernel-module-cheat/issues/67
This commit is contained in:
@@ -27,8 +27,10 @@ _start:
|
||||
adr x0, lkmc_baremetal_on_exit_callback
|
||||
bl on_exit
|
||||
|
||||
/* Run main. */
|
||||
mov x0, 0
|
||||
/* Setup CLI arguments and run main. */
|
||||
ldr x0, =lkmc_argc
|
||||
ldr x0, [x0]
|
||||
ldr x1, =lkmc_argv
|
||||
bl main
|
||||
|
||||
/* If main returns, exit. */
|
||||
|
||||
@@ -14,15 +14,19 @@ SECTIONS
|
||||
/* Fix the addresses of everything that comes after, no matter
|
||||
* the exact size of the code present in .text. This allows us to
|
||||
* place CLI arguments in memory at a known location! */
|
||||
/* TODO would be better like this with --section-start=.lkmc_memory= on CLI,
|
||||
* so that Python controls this value, but I can't that fucking working.
|
||||
* baremetal_max_size from the Python must match this offset for now.
|
||||
*/
|
||||
/*. = SEGMENT_START(.lkmc_memory, .);*/
|
||||
. = ADDR(.text) + 0x1000000;
|
||||
lkmc_heap_low = .;
|
||||
. = . + 0x1000000;
|
||||
lkmc_heap_top = .;
|
||||
. = . + 0x1000000;
|
||||
lkmc_stack_top = .;
|
||||
. = . + 0x1000000;
|
||||
lkmc_argv = .;
|
||||
. = . + 0x4;
|
||||
lkmc_argc = .;
|
||||
. = . + 0x4;
|
||||
lkmc_argv = .;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ extern int32_t lkmc_heap_low;
|
||||
int main(int argc, char **argv) {
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
printf("&lkmc_heap_low %p\n", (void*)&lkmc_heap_low);
|
||||
printf("&lkmc_argc %p\n", (void*)&lkmc_argc);
|
||||
printf("&lkmc_heap_low %p\n", (void *)&lkmc_heap_low);
|
||||
printf("&lkmc_argc %p\n", (void *)&lkmc_argc);
|
||||
printf("argc %d\n", argc);
|
||||
printf("argv %p\n", (void *)argv);
|
||||
printf("lkmc_argc %" PRId32 "\n", lkmc_argc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user