Fix PR63758 by using the _NSGetEnviron() API on Darwin
authorIain Sandoe <iain@codesourcery.com>
Sat, 28 Nov 2015 16:39:30 +0000 (16:39 +0000)
committerPedro Alves <palves@redhat.com>
Sat, 28 Nov 2015 16:39:30 +0000 (16:39 +0000)
include/

Roland McGrath  <roland@gnu.org>

PR other/63758
* environ.h: New file.

libiberty/

Roland McGrath  <roland@gnu.org>
Iain Sandoe  <iain@codesourcery.com>

PR other/63758
* pex-unix.c: Obtain the environment interface from settings in environ.h
rather than in-line code.  Update copyright date.
* setenv.c: Likewise.
* xmalloc.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228942 138bc75d-0d04-0410-961f-82ee72b054a4

include/ChangeLog
include/environ.h [new file with mode: 0644]
libiberty/ChangeLog
libiberty/pex-unix.c
libiberty/setenv.c
libiberty/xmalloc.c

index 01a25def7a41def4c60bc18013a55295acea59f2..74f9cdc9476f4b836f0b3fc79c9413a49c76733e 100644 (file)
        * bfdlink.h (bfd_link_info): Add call_nop_as_suffix and
        call_nop_byte.
 
+2015-10-18  Roland McGrath  <roland@gnu.org>
+
+       PR other/63758
+       * environ.h: New file.
+
 2015-10-07  Claudiu Zissulescu  <claziss@synopsys.com>
 
        * dis-asm.h (arc_get_disassembler): Correct declaration.
diff --git a/include/environ.h b/include/environ.h
new file mode 100644 (file)
index 0000000..c18902b
--- /dev/null
@@ -0,0 +1,33 @@
+/* Declare the environ system variable.
+   Copyright (C) 2015 Free Software Foundation, Inc.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB.  If not,
+write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+Boston, MA 02110-1301, USA.  */
+
+/* On OSX, the environ variable can be used directly in the code of an
+   executable, but cannot be used in the code of a shared library (such as
+   GCC's liblto_plugin, which links in libiberty code).  Instead, the
+   function _NSGetEnviron can be called to get the address of environ.  */
+
+#ifndef HAVE_ENVIRON_DECL
+#  ifdef __APPLE__
+#     include <crt_externs.h>
+#     define environ (*_NSGetEnviron ())
+#  else
+extern char **environ;
+#  endif
+#  define HAVE_ENVIRON_DECL
+#endif
index 3cd03749da5e69470c70b202202c31de3ffa0a95..3025e99324bd10db9aeb35d5a876ec2c7920d3ee 100644 (file)
        Android hosts.
        * configure: Regenerate.
 
+2015-10-18  Roland McGrath  <roland@gnu.org>
+           Iain Sandoe  <iain@codesourcery.com>
+
+       PR other/63758
+       * pex-unix.c: Obtain the environment interface from settings in
+       environ.h rather than in-line code.  Update copyright date.
+       * setenv.c: Likewise.
+       * xmalloc.c: Likewise.
+
 2015-09-30  Jason Merrill  <jason@redhat.com>
 
        * cp-demangle.c (d_cv_qualifiers): Dx means transaction_safe.
index 0715115747826d510a960ae772cccc052012ee5a..b48f315f83fa9b744426bd3f89acfce0f72e861a 100644 (file)
@@ -2,7 +2,7 @@
    with other subprocesses), and wait for it.  Generic Unix version
    (also used for UWIN and VMS).
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2009,
-   2010 Free Software Foundation, Inc.
+   2010, 2015 Free Software Foundation, Inc.
 
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
@@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA.  */
 #include "config.h"
 #include "libiberty.h"
 #include "pex-common.h"
+#include "environ.h"
 
 #include <stdio.h>
 #include <signal.h>
@@ -390,8 +391,6 @@ pex_child_error (struct pex_obj *obj, const char *executable,
 
 /* Execute a child.  */
 
-extern char **environ;
-
 #if defined(HAVE_SPAWNVE) && defined(HAVE_SPAWNVPE)
 /* Implementation of pex->exec_child using the Cygwin spawn operation.  */
 
index 714ca0a407687e9be46c3da4427f974186a2b9f1..5b51193319de57d81f8f7f9c751175850f107819 100644 (file)
@@ -1,5 +1,5 @@
-/* Copyright (C) 1992, 1995, 1996, 1997, 2002, 2011 Free Software Foundation,
-   Inc.
+/* Copyright (C) 1992, 1995, 1996, 1997, 2002, 2011, 2015
+   Free Software Foundation, Inc.
    This file based on setenv.c in the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -62,11 +62,7 @@ extern int errno;
 #endif
 
 #define __environ      environ
-#ifndef HAVE_ENVIRON_DECL
-#ifndef environ
-extern char **environ;
-#endif
-#endif
+#include "environ.h"
 
 #undef setenv
 #undef unsetenv
index 3e97aab563f0e409a3d65a6258ee911e89101eb5..f849aee53e28c8581e662c872c9931bdbcca2b91 100644 (file)
@@ -1,5 +1,6 @@
 /* memory allocation routines with error checking.
-   Copyright 1989, 90, 91, 92, 93, 94 Free Software Foundation, Inc.
+   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 2015
+   Free Software Foundation, Inc.
    
 This file is part of the libiberty library.
 Libiberty is free software; you can redistribute it and/or
@@ -65,6 +66,7 @@ function will be called to print an error message and terminate execution.
 #endif
 #include "ansidecl.h"
 #include "libiberty.h"
+#include "environ.h"
 
 #include <stdio.h>
 
@@ -117,7 +119,6 @@ void
 xmalloc_failed (size_t size)
 {
 #ifdef HAVE_SBRK
-  extern char **environ;
   size_t allocated;
 
   if (first_break != NULL)
This page took 0.032063 seconds and 4 git commands to generate.