Update sources to GPLv3
[deliverable/binutils-gdb.git] / ld / emultempl / aix.em
index a85f7d0c05794e89fc10b7fb068ed60db4a0204f..df983b14a8e14ad3507f05213b353adf38bcd423 100644 (file)
@@ -10,32 +10,33 @@ cat >e${EMULATION_NAME}.c <<EOF
 
 /* AIX emulation code for ${EMULATION_NAME}
    Copyright 1991, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-   2003, 2004, 2005, 2006
+   2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
    Written by Steve Chamberlain <sac@cygnus.com>
    AIX support by Ian Lance Taylor <ian@cygnus.com>
    AIX 64 bit support by Tom Rix <trix@redhat.com>
 
-This file is part of GLD, the Gnu Linker.
+   This file is part of the GNU Binutils.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program 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 General Public License for more details.
+   This program 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 General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
 #define TARGET_IS_${EMULATION_NAME}
 
-#include "bfd.h"
 #include "sysdep.h"
+#include "bfd.h"
 #include "libiberty.h"
 #include "safe-ctype.h"
 #include "getopt.h"
@@ -651,18 +652,52 @@ gld${EMULATION_NAME}_before_allocation (void)
       size_t len;
       search_dirs_type *search;
 
-      len = strlen (search_head->name);
-      libpath = xmalloc (len + 1);
-      strcpy (libpath, search_head->name);
-      for (search = search_head->next; search != NULL; search = search->next)
+      /* PR ld/4023: Strip sysroot prefix from any paths
+        being inserted into the output binary's DT_RPATH.  */
+      if (ld_sysroot != NULL
+         && * ld_sysroot != 0)
        {
-         size_t nlen;
+         const char * name = search_head->name;
+         size_t ld_sysroot_len = strlen (ld_sysroot);
+
+         if (strncmp (name, ld_sysroot, ld_sysroot_len) == 0)
+           name += ld_sysroot_len;
+
+         len = strlen (name);
+         libpath = xmalloc (len + 1);
+         strcpy (libpath, name);
 
-         nlen = strlen (search->name);
-         libpath = xrealloc (libpath, len + nlen + 2);
-         libpath[len] = ':';
-         strcpy (libpath + len + 1, search->name);
-         len += nlen + 1;
+         for (search = search_head->next; search != NULL; search = search->next)
+           {
+             size_t nlen;
+
+             name = search->name;
+             if (strncmp (name, ld_sysroot, ld_sysroot_len) == 0)
+               name += ld_sysroot_len;
+
+             nlen = strlen (name);
+             libpath = xrealloc (libpath, len + nlen + 2);
+             libpath[len] = ':';
+             strcpy (libpath + len + 1, name);
+             len += nlen + 1;
+           }
+       }
+      else
+       {
+         len = strlen (search_head->name);
+         libpath = xmalloc (len + 1);
+         strcpy (libpath, search_head->name);
+
+         for (search = search_head->next; search != NULL; search = search->next)
+           {
+             size_t nlen;
+
+             nlen = strlen (search->name);
+             libpath = xrealloc (libpath, len + nlen + 2);
+             libpath[len] = ':';
+             strcpy (libpath + len + 1, search->name);
+             len += nlen + 1;
+           }
        }
     }
 
This page took 0.025203 seconds and 4 git commands to generate.