mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH v2 3/3] When switching optimization to higher levels (-O3) and enable link time optimization (-flto) my linker explodes because "__environ" is accessed through an alias named "environ", and that text segment has already been removed:
@ 2013-02-11 13:20 Jens Gustedt
  0 siblings, 0 replies; only message in thread
From: Jens Gustedt @ 2013-02-11 13:20 UTC (permalink / raw)
  To: musl

`environ' referenced in section `.text.execvp' of /tmp/cckGfCaK.ltrans1.ltrans.o: defined in discarded section `.text' of src/env/__environ.lo (symbol from plugin)
/usr/bin/ld: BFD (GNU Binutils for Ubuntu) 2.22 assertion fail ../../bfd/elf64-x86-64.c:4365

Use the "real" name of __environ directly and make this code consistent
with other functions (such as execv) that already use __environ,
too.

Some places where "environ" is used may already have been silently
renamed through a macro in internal/libc.h, but it is probably better to
have that in the open.

2	2	src/process/execvp.c
2	2	src/process/system.c

diff --git a/src/process/execvp.c b/src/process/execvp.c
index 682680d..0a33e42 100644
--- a/src/process/execvp.c
+++ b/src/process/execvp.c
@@ -4,7 +4,7 @@
 #include <errno.h>
 #include <limits.h>
 
-extern char **environ;
+extern char **__environ;
 
 int __execvpe(const char *file, char *const argv[], char *const envp[])
 {
@@ -45,5 +45,5 @@ int __execvpe(const char *file, char *const argv[], char *const envp[])
 
 int execvp(const char *file, char *const argv[])
 {
-	return __execvpe(file, argv, environ);
+	return __execvpe(file, argv, __environ);
 }
diff --git a/src/process/system.c b/src/process/system.c
index 0aa34cd..4232bef 100644
--- a/src/process/system.c
+++ b/src/process/system.c
@@ -13,7 +13,7 @@ static void dummy_0()
 weak_alias(dummy_0, __acquire_ptc);
 weak_alias(dummy_0, __release_ptc);
 
-extern char **environ;
+extern char **__environ;
 
 int system(const char *cmd)
 {
@@ -40,7 +40,7 @@ int system(const char *cmd)
 	posix_spawnattr_setsigdefault(&attr, &reset);
 	posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF|POSIX_SPAWN_SETSIGMASK);
 	ret = posix_spawn(&pid, "/bin/sh", 0, &attr,
-		(char *[]){"sh", "-c", (char *)cmd, 0}, environ);
+		(char *[]){"sh", "-c", (char *)cmd, 0}, __environ);
 	posix_spawnattr_destroy(&attr);
 
 	if (!ret) while (waitpid(pid, &status, 0)<0 && errno == EINTR);
-- 
1.7.9.5



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-02-11 13:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-11 13:20 [PATCH v2 3/3] When switching optimization to higher levels (-O3) and enable link time optimization (-flto) my linker explodes because "__environ" is accessed through an alias named "environ", and that text segment has already been removed: Jens Gustedt

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).