Skip to content

Commit 241c4b4

Browse files
svens-s390paulmckrcu
authored andcommitted
tools/nolibc: add auxiliary vector retrieval for s390
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: Sven Schnelle <[email protected]> Signed-off-by: Willy Tarreau <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent d01869c commit 241c4b4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tools/include/nolibc/arch-s390.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct sys_stat_struct {
160160
})
161161

162162
char **environ __attribute__((weak));
163+
const unsigned long *_auxv __attribute__((weak));
163164

164165
/* startup code */
165166
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
@@ -179,6 +180,15 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
179180
"larl %r1,environ\n"
180181
"stg %r4,0(%r1)\n"
181182

183+
/* search for auxv */
184+
"lgr %r5,%r4\n" /* start at envp */
185+
"1:\n"
186+
"clg %r0,0(%r5)\n" /* entry zero? */
187+
"la %r5,8(%r5)\n" /* advance pointer */
188+
"jnz 1b\n" /* no -> test next pointer */
189+
"larl %r1,_auxv\n" /* yes -> store value in _auxv */
190+
"stg %r5,0(%r1)\n"
191+
182192
"aghi %r15,-160\n" /* allocate new stackframe */
183193
"xc 0(8,%r15),0(%r15)\n" /* clear backchain */
184194
"brasl %r14,main\n" /* ret value of main is arg to exit */

0 commit comments

Comments
 (0)