Skip to content

Commit 2a39a53

Browse files
wtarreaupaulmckrcu
authored andcommitted
tools/nolibc: add auxiliary vector retrieval for arm64
In the _start block we now iterate over envp to find the auxiliary vector after the NULL. The pointer is saved into an _auxv variable that is marked as weak so that it's accessible from multiple units. Signed-off-by: Willy Tarreau <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 1cce162 commit 2a39a53

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/include/nolibc/arch-aarch64.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ struct sys_stat_struct {
170170
})
171171

172172
char **environ __attribute__((weak));
173+
const unsigned long *_auxv __attribute__((weak));
173174

174175
/* startup code */
175176
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
@@ -182,6 +183,12 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
182183
"add x2, x2, x1\n" // + argv
183184
"adrp x3, environ\n" // x3 = &environ (high bits)
184185
"str x2, [x3, #:lo12:environ]\n" // store envp into environ
186+
"mov x4, x2\n" // search for auxv (follows NULL after last env)
187+
"0:\n"
188+
"ldr x5, [x4], 8\n" // x5 = *x4; x4 += 8
189+
"cbnz x5, 0b\n" // and stop at NULL after last env
190+
"adrp x3, _auxv\n" // x3 = &_auxv (high bits)
191+
"str x4, [x3, #:lo12:_auxv]\n" // store x4 into _auxv
185192
"and sp, x1, -16\n" // sp must be 16-byte aligned in the callee
186193
"bl main\n" // main() returns the status code, we'll exit with it.
187194
"mov x8, 93\n" // NR_exit == 93

0 commit comments

Comments
 (0)