Skip to content

Commit 9e5bdc6

Browse files
svens-s390paulmckrcu
authored andcommitted
tools/nolibc: export environ as a weak symbol on s390
The environ is retrieved from the _start code and is easy to store at this moment. Let's declare the variable weak and store the value into it. By not being static it will be visible to all units. By being weak, if some programs already declared it, they will continue to be able to use it. This was tested on s390 both with environ inherited from _start and extracted from envp. Signed-off-by: Sven Schnelle <[email protected]> Signed-off-by: Willy Tarreau <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 758f333 commit 9e5bdc6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/include/nolibc/arch-s390.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ struct sys_stat_struct {
159159
_arg1; \
160160
})
161161

162+
char **environ __attribute__((weak));
163+
162164
/* startup code */
163165
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
164166
{
@@ -174,6 +176,8 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
174176
"la %r4,8(%r4)\n" /* advance pointer */
175177
"jnz 0b\n" /* no -> test next pointer */
176178
/* yes -> r4 now contains start of envp */
179+
"larl %r1,environ\n"
180+
"stg %r4,0(%r1)\n"
177181

178182
"aghi %r15,-160\n" /* allocate new stackframe */
179183
"xc 0(8,%r15),0(%r15)\n" /* clear backchain */

0 commit comments

Comments
 (0)