aboutsummaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorGravatar Willy Tarreau <w@1wt.eu> 2023-01-10 08:24:25 +0100
committerGravatar Paul E. McKenney <paulmck@kernel.org> 2023-01-10 13:33:56 -0800
commit2ab4aa487b93d9d994b4a20382848a4041f00d78 (patch)
treef5a49a4fd583899aaeccd3db9c102df7c8285e48 /tools/include
parenttools/nolibc: export environ as a weak symbol on s390 (diff)
downloadlinux-2ab4aa487b93d9d994b4a20382848a4041f00d78.tar.gz
linux-2ab4aa487b93d9d994b4a20382848a4041f00d78.tar.bz2
linux-2ab4aa487b93d9d994b4a20382848a4041f00d78.zip
tools/nolibc: add auxiliary vector retrieval for i386
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-i386.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/include/nolibc/arch-i386.h b/tools/include/nolibc/arch-i386.h
index 60b586120727..e8d0cf545bf1 100644
--- a/tools/include/nolibc/arch-i386.h
+++ b/tools/include/nolibc/arch-i386.h
@@ -179,6 +179,7 @@ struct sys_stat_struct {
})
char **environ __attribute__((weak));
+const unsigned long *_auxv __attribute__((weak));
/* startup code */
/*
@@ -195,6 +196,12 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
"lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx)
"mov %ecx, environ\n" // save environ
"xor %ebp, %ebp\n" // zero the stack frame
+ "mov %ecx, %edx\n" // search for auxv (follows NULL after last env)
+ "0:\n"
+ "add $4, %edx\n" // search for auxv using edx, it follows the
+ "cmp -4(%edx), %ebp\n" // ... NULL after last env (ebp is zero here)
+ "jnz 0b\n"
+ "mov %edx, _auxv\n" // save it into _auxv
"and $-16, %esp\n" // x86 ABI : esp must be 16-byte aligned before
"sub $4, %esp\n" // the call instruction (args are aligned)
"push %ecx\n" // push all registers on the stack so that we