aboutsummaryrefslogtreecommitdiff
path: root/tools/include
diff options
context:
space:
mode:
authorGravatar Sven Schnelle <svens@linux.ibm.com> 2023-01-10 08:24:24 +0100
committerGravatar Paul E. McKenney <paulmck@kernel.org> 2023-01-10 13:33:56 -0800
commit9e5bdc613d06fdc6fed73267767c09a0dc0c6aac (patch)
treeee789327f80546c6415ae7b5ee2a6569dc821515 /tools/include
parenttools/nolibc: export environ as a weak symbol on riscv (diff)
downloadlinux-9e5bdc613d06fdc6fed73267767c09a0dc0c6aac.tar.gz
linux-9e5bdc613d06fdc6fed73267767c09a0dc0c6aac.tar.bz2
linux-9e5bdc613d06fdc6fed73267767c09a0dc0c6aac.zip
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 <svens@linux.ibm.com> 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-s390.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/include/nolibc/arch-s390.h b/tools/include/nolibc/arch-s390.h
index b58f64d47b82..039b454e79f0 100644
--- a/tools/include/nolibc/arch-s390.h
+++ b/tools/include/nolibc/arch-s390.h
@@ -159,6 +159,8 @@ struct sys_stat_struct {
_arg1; \
})
+char **environ __attribute__((weak));
+
/* startup code */
void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
{
@@ -174,6 +176,8 @@ void __attribute__((weak,noreturn,optimize("omit-frame-pointer"))) _start(void)
"la %r4,8(%r4)\n" /* advance pointer */
"jnz 0b\n" /* no -> test next pointer */
/* yes -> r4 now contains start of envp */
+ "larl %r1,environ\n"
+ "stg %r4,0(%r1)\n"
"aghi %r15,-160\n" /* allocate new stackframe */
"xc 0(8,%r15),0(%r15)\n" /* clear backchain */