Skip directories with LIBPATH_SUFFIX_SKIP suffix
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 15 Jan 2014 20:53:04 +0000 (12:53 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 16 Jan 2014 04:09:09 +0000 (20:09 -0800)
On Linux/x86-64, when binutils is configured with --libdir=/usr/lib64,
genscripts.sh treats /usr/lib64 as the default search directory.  It
puts /usr/lib64 in linker scripts for all emulations, like

---
/* Script for -z combreloc: combine and sort reloc sections */
OUTPUT_FORMAT("elf32-i386", "elf32-i386",
      "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(_start)
SEARCH_DIR("/usr/x86_64-redhat-linux/lib32");
SEARCH_DIR("/usr/i386-redhat-linux/lib32"); SEARCH_DIR("/usr/lib6432");
SEARCH_DIR("/usr/local/lib32"); SEARCH_DIR("/lib32");
SEARCH_DIR("/usr/lib32"); SEARCH_DIR("/usr/i386-redhat-linux/lib");
SEARCH_DIR("/usr/lib64"); SEARCH_DIR("/usr/local/lib");
SEARCH_DIR("/lib"); SEARCH_DIR("/usr/lib");
---

/usr/lib6432 is odd and /usr/lib64 is wrong.  This patch changes
genscripts.sh to check LIBPATH_SUFFIX_SKIP if it is defined.  It
skips directories with LIBPATH_SUFFIX_SKIP suffix.

PR ld/16456
* genscripts.sh: Don't search directory with LIBPATH_SUFFIX_SKIP
suffix.
* emulparams/elf32_x86_64.sh (LIBPATH_SUFFIX_SKIP): Set to 64
for elf32_x86_64 emulation.
* emulparams/elf_i386.sh (LIBPATH_SUFFIX_SKIP): Set to 64
for elf_i386 emulation.

ld/ChangeLog
ld/emulparams/elf32_x86_64.sh
ld/emulparams/elf_i386.sh
ld/genscripts.sh

index 4303a728ed6aac981cbbd50864270971f68a5c08..08c9b384b5b15ebc83a5eef95dcd606d3d8d6ff0 100644 (file)
@@ -1,3 +1,13 @@
+2014-01-16  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/16456
+       * genscripts.sh: Don't search directory with LIBPATH_SUFFIX_SKIP
+       suffix.
+       * emulparams/elf32_x86_64.sh (LIBPATH_SUFFIX_SKIP): Set to 64
+       for elf32_x86_64 emulation.
+       * emulparams/elf_i386.sh (LIBPATH_SUFFIX_SKIP): Set to 64
+       for elf_i386 emulation.
+
 2014-01-16  Alan Modra  <amodra@gmail.com>
 
        * ld.h (fat_section_userdata_type, get_userdata): Move to..
index d34297be2ac2aac0d800ac668d76c16102704e9d..11d17adb1dc272ffd7c459192f5afd4fc78e093c 100644 (file)
@@ -29,8 +29,13 @@ fi
 case "$target" in
   x86_64*-linux*|i[3-7]86-*-linux-*)
     case "$EMULATION_NAME" in
-      *32*) LIBPATH_SUFFIX=x32 ;;
-      *64*) LIBPATH_SUFFIX=64 ;;
+      *32*)
+        LIBPATH_SUFFIX=x32
+       LIBPATH_SUFFIX_SKIP=64
+       ;;
+      *64*)
+        LIBPATH_SUFFIX=64
+       ;;
     esac
     ;;
 esac
index add700ff50a007fa647ad31046c5578fbab301a4..93f19924ecd558ab3d7d83516ae5a46f1cdc5bdb 100644 (file)
@@ -19,7 +19,10 @@ IREL_IN_PLT=
 case "$target" in
   x86_64*-linux* | i[3-7]86*-linux*)
     case "$EMULATION_NAME" in
-      *i386*) LIBPATH_SUFFIX=32 ;;
+      *i386*)
+       LIBPATH_SUFFIX=32
+       LIBPATH_SUFFIX_SKIP=64
+       ;;
     esac
     ;;
 esac
index a4da92d2d0c62d3a4a8bc54ca8daa2d290c32bcb..eeb6d73b31ebc24bf7d4b8183cccfb0f119ce088 100755 (executable)
@@ -160,6 +160,7 @@ append_to_lib_path()
       if [ "x${use_sysroot}" = "xyes" ] ; then
        lib="=${lib}"
       fi
+      skip_lib=no
       if test -n "${LIBPATH_SUFFIX}"; then
        case "${lib}" in
          *${LIBPATH_SUFFIX})
@@ -169,18 +170,27 @@ append_to_lib_path()
              *) lib_path1=${lib_path1}:${lib} ;;
            esac ;;
          *)
-           case :${lib_path1}: in
-             *:${lib}${LIBPATH_SUFFIX}:*) ;;
-             ::) lib_path1=${lib}${LIBPATH_SUFFIX} ;;
-             *) lib_path1=${lib_path1}:${lib}${LIBPATH_SUFFIX} ;;
-           esac ;;
+           if test -n "${LIBPATH_SUFFIX_SKIP}"; then
+             case "${lib}" in
+               *${LIBPATH_SUFFIX_SKIP}) skip_lib=yes ;;
+             esac
+           fi
+           if test "${skip_lib}" = "no"; then
+             case :${lib_path1}: in
+               *:${lib}${LIBPATH_SUFFIX}:*) ;;
+               ::) lib_path1=${lib}${LIBPATH_SUFFIX} ;;
+               *) lib_path1=${lib_path1}:${lib}${LIBPATH_SUFFIX} ;;
+             esac
+           fi ;;
+       esac
+      fi
+      if test "${skip_lib}" = "no"; then
+       case :${lib_path1}:${lib_path2}: in
+         *:${lib}:*) ;;
+         *::) lib_path2=${lib} ;;
+         *) lib_path2=${lib_path2}:${lib} ;;
        esac
       fi
-      case :${lib_path1}:${lib_path2}: in
-       *:${lib}:*) ;;
-       *::) lib_path2=${lib} ;;
-       *) lib_path2=${lib_path2}:${lib} ;;
-      esac
     done
   fi
 }