From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2794 Path: news.gmane.org!not-for-mail From: Jens Gustedt Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH v3 3/3] internally use the symbol __environ instead of environ Date: Mon, 11 Feb 2013 23:51:52 +0100 Message-ID: <1360623064.2536.66.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1360623123 23996 80.91.229.3 (11 Feb 2013 22:52:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Feb 2013 22:52:03 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2795-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 11 23:52:25 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U52Ea-00088D-KT for gllmg-musl@plane.gmane.org; Mon, 11 Feb 2013 23:52:24 +0100 Original-Received: (qmail 19526 invoked by uid 550); 11 Feb 2013 22:52:05 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 19518 invoked from network); 11 Feb 2013 22:52:05 -0000 X-IronPort-AV: E=Sophos;i="4.84,646,1355094000"; d="scan'208";a="2390652" Resent-From: Jens Gustedt Resent-To: musl@lists.openwall.com Resent-Cc: musl X-Mailer: Evolution 3.2.3-0ubuntu6 Xref: news.gmane.org gmane.linux.lib.musl.general:2794 Archived-At: 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: `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. 0 1 src/internal/libc.h 2 2 src/process/execvp.c 2 2 src/process/system.c diff --git a/src/internal/libc.h b/src/internal/libc.h index 5089114..c9416f0 100644 --- a/src/internal/libc.h +++ b/src/internal/libc.h @@ -57,7 +57,6 @@ void __synccall(void (*)(void *), void *); int __setxid(int, int, int, int); extern char **__environ; -#define environ __environ #undef weak_alias #define weak_alias(old, new) \ 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 #include -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