summaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorWilly Tarreau <w@1wt.eu>2023-01-10 10:24:27 +0300
committerPaul E. McKenney <paulmck@kernel.org>2023-01-11 00:33:56 +0300
commit2a39a53245d2b5eae83c10a67581e8dc6b629b85 (patch)
treeea023096042992420de926e042b54d7644638dda /tools/include
parent1cce162ab4a565c8a88ffac1d9f78c80e160d6a1 (diff)
downloadlinux-2a39a53245d2b5eae83c10a67581e8dc6b629b85.tar.xz
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 <w@1wt.eu> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/nolibc/arch-aarch64.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/include/nolibc/arch-aarch64.h b/tools/include/nolibc/arch-aarch64.h
index 2e3d9adc4c4c..383baddef701 100644
--- a/tools/include/nolibc/arch-aarch64.h
+++ b/tools/include/nolibc/arch-aarch64.h
@@ -170,6 +170,7 @@ struct sys_stat_struct {
})
char **environ __attribute__((weak));
+const unsigned long *_auxv __attribute__((weak));
/* startup code */
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
@@ -182,6 +183,12 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
"add x2, x2, x1\n" // + argv
"adrp x3, environ\n" // x3 = &environ (high bits)
"str x2, [x3, #:lo12:environ]\n" // store envp into environ
+ "mov x4, x2\n" // search for auxv (follows NULL after last env)
+ "0:\n"
+ "ldr x5, [x4], 8\n" // x5 = *x4; x4 += 8
+ "cbnz x5, 0b\n" // and stop at NULL after last env
+ "adrp x3, _auxv\n" // x3 = &_auxv (high bits)
+ "str x4, [x3, #:lo12:_auxv]\n" // store x4 into _auxv
"and sp, x1, -16\n" // sp must be 16-byte aligned in the callee
"bl main\n" // main() returns the status code, we'll exit with it.
"mov x8, 93\n" // NR_exit == 93