mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 11:41:35 +01:00
asm: make use regular asserts that will just work on baremetal
Previously had wonky line pointer in asm_main. New interface simpler and more portable. Add tests for ASSERT_EQ_ and family in arm and aarch64, previously on x86_64. ASSERT_EQ_ and family in ARM can now either take =123, =addr or var, before this the = was added on macros so var was not possible. Define the main function directly in assembly, the C driver was useless.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#calling-convention */
|
||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-calling-convention */
|
||||
|
||||
#include "common.h"
|
||||
#include <lkmc.h>
|
||||
|
||||
.data
|
||||
puts_s:
|
||||
@@ -12,7 +12,7 @@ my_array_0:
|
||||
my_array_1:
|
||||
.word 0x55555555, 0x66666666, 0x77777777, 0x88888888
|
||||
|
||||
LKMC_ENTRY
|
||||
LKMC_PROLOGUE
|
||||
/* puts("hello world") */
|
||||
/* r0 is first argument. */
|
||||
ldr r0, =puts_s
|
||||
@@ -49,11 +49,11 @@ LKMC_ENTRY
|
||||
ldr r1, =my_array_1
|
||||
ldr r2, =0x10
|
||||
bl memcmp
|
||||
LKMC_ASSERT_EQ(r0, 0)
|
||||
LKMC_ASSERT_EQ(r0, =0)
|
||||
|
||||
/* exit(0) */
|
||||
mov r0, 0
|
||||
bl exit
|
||||
|
||||
/* Never reached, just for the fail symbol. */
|
||||
LKMC_EXIT
|
||||
LKMC_EPILOGUE
|
||||
|
||||
Reference in New Issue
Block a user