mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
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.
34 lines
886 B
ArmAsm
34 lines
886 B
ArmAsm
/* https://github.com/cirosantilli/linux-kernel-module-cheat#arm-adr-instruction */
|
|
|
|
#include <lkmc.h>
|
|
|
|
.data
|
|
data_label:
|
|
.word 0x1234678
|
|
LKMC_PROLOGUE
|
|
adr r4, label
|
|
/* objdump tells us that this uses the literal pool,
|
|
* it does not get converted to adr, which is the better
|
|
* alternative here.
|
|
*/
|
|
ldr r5, =label
|
|
adrl r6, label
|
|
label:
|
|
LKMC_ASSERT_EQ_REG(r4, r5)
|
|
LKMC_ASSERT_EQ_REG(r4, r6)
|
|
|
|
#if 0
|
|
/* Error: symbol .data is in a different section.
|
|
*
|
|
* It works however in ARMv8.
|
|
* I think this means that there is no relocation type
|
|
* that takes care of this encoding in ARMv8, but there
|
|
* is one in ARMv8.
|
|
*
|
|
* If you have no idea what I'm talking about, read this:
|
|
* https://stackoverflow.com/questions/3322911/what-do-linkers-do/33690144#33690144
|
|
*/
|
|
adr r5, data_label
|
|
#endif
|
|
LKMC_EPILOGUE
|