Bug 16456 - Wrong directory is searched with non-default emulation
Summary: Wrong directory is searched with non-default emulation
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: 2.25
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-15 20:28 UTC by H.J. Lu
Modified: 2014-01-16 04:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2014-01-15 20:28:50 UTC
On Linux/x86-64, when binutils is configured with --libdir=/usr/lib64,
genscripts.sh treats /usr/lib64 as the default search directory. It
put /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");
---

When I install my own 32bit GCC on Linux/x86-64, I got:

[hjl@gnu-atom-1 tmp]$ /export/build/gnu/gcc-32bit-4.7/release.original/usr/gcc-4.7.4/bin/gcc x.o 
/usr/bin/ld: skipping incompatible /usr/lib64/libc.so when searching for -lc
[hjl@gnu-atom-1 tmp]$
Comment 1 Sourceware Commits 2014-01-16 04:10:44 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  f6f6c6790a0f3704575b9e9c87cf55baf215eef3 (commit)
      from  6fcc66ab70d67efb1a8b96532b5eb96883caa727 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f6f6c6790a0f3704575b9e9c87cf55baf215eef3

commit f6f6c6790a0f3704575b9e9c87cf55baf215eef3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Jan 15 12:53:04 2014 -0800

    Skip directories with LIBPATH_SUFFIX_SKIP suffix
    
    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.

-----------------------------------------------------------------------

Summary of changes:
 ld/ChangeLog                  |   10 ++++++++++
 ld/emulparams/elf32_x86_64.sh |    9 +++++++--
 ld/emulparams/elf_i386.sh     |    5 ++++-
 ld/genscripts.sh              |   30 ++++++++++++++++++++----------
 4 files changed, 41 insertions(+), 13 deletions(-)
Comment 2 H.J. Lu 2014-01-16 04:13:49 UTC
Fixed.