WIP: add _auxv retrieval for arm
diff --git a/tools/include/nolibc/arch-arm.h b/tools/include/nolibc/arch-arm.h
index 7c4e30f..9460c37 100644
--- a/tools/include/nolibc/arch-arm.h
+++ b/tools/include/nolibc/arch-arm.h
@@ -175,6 +175,7 @@ struct sys_stat_struct {
})
char **environ __attribute__((weak));
+const void *_auxv __attribute__((weak));
/* startup code */
__asm__ (".section .text\n"
@@ -198,6 +199,15 @@ __asm__ (".section .text\n"
"add %r2, %r2, $4\n" // ... + 4
"ldr %r3, 1f\n" // r3 = &environ (see below)
"str %r2, [r3]\n" // store envp into environ
+
+ "mov r4, r2\n" // search for auxv (follows NULL after last env)
+ "0:\n"
+ "ldr r5, [r4], #4\n" // r5 = *r4; r4 += 4
+ "cmp r5, #0\n" // and stop at NULL after last env
+ "bne 0b\n"
+ "ldr %r3, 2f\n" // r3 = &_auxv (low bits)
+ "str r4, [r3]\n" // store r4 into _auxv
+
"and %r3, %r1, $-8\n" // AAPCS : sp must be 8-byte aligned in the
"mov %sp, %r3\n" // callee, an bl doesn't push (lr=pc)
"bl main\n" // main() returns the status code, we'll exit with it.
@@ -206,6 +216,8 @@ __asm__ (".section .text\n"
".align 2\n" // below are the pointers to a few variables
"1:\n"
".word environ\n"
+ "2:\n"
+ ".word _auxv\n"
"");
#endif // _NOLIBC_ARCH_ARM_H