diff options
author | Daniel Jacobowitz <drow@false.org> | 2003-01-06 16:14:01 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2003-01-06 16:14:01 +0000 |
commit | 9c8ebd6a5127e55660465d193593cce16b26516c (patch) | |
tree | d9e30a69db894db226592dad8cf182d9bc60b00a /ld/emultempl | |
parent | b089b3da7575478aa863aa494cce5d5d7d4b68fe (diff) | |
download | gdb-9c8ebd6a5127e55660465d193593cce16b26516c.zip gdb-9c8ebd6a5127e55660465d193593cce16b26516c.tar.gz gdb-9c8ebd6a5127e55660465d193593cce16b26516c.tar.bz2 |
* Makefile.am (eelf32iq10.c): Fix tab/whitespace mixup.
* Makefile.am (ldmain.o): Add @TARGET_SYSTEM_ROOT_DEFINE@.
(GENSCRIPTS): Add @use_sysroot@.
* Makefile.in: Regenerated.
* configure.host: Move setting of NATIVE_LIB_DIRS to...
* configure.tgt: ... here. Use ${target} instead of ${host}
for NATIVE_LIB_DIRS.
* configure.in: Add --with-sysroot.
* configure: Regenerated.
* genscripts.sh: Accept use_sysroot option. Set new variables
NATIVE and USE_LIBPATH. Prepend "=" to directory names if
$use_sysroot. Don't search $tool_lib if $use_sysroot.
* ldfile.c (ldfile_add_library_path): Handle leading '='.
* ldmain.c (TARGET_SYSTEM_ROOT): Define if not defined.
(ld_sysroot): New variable.
(main): Initialize ld_sysroot.
* ldmain.h (ld_sysroot): New extern.
* emultempl/elf32.em: Use NATIVE and USE_LIBPATH instead of
searching $EMULATION_LIBPATH.
(gld${EMULATION_NAME}_add_sysroot): New function.
(gld${EMULATION_NAME}_check_ld_so_conf): Use it. Honor ld_sysroot.
(gld${EMULATION_NAME}_after_open): Likewise. Only search
environment variables if $NATIVE.
* ld.texinfo (Options): Mention "=" prefix in the description of -L.
* NEWS: Mention --with-sysroot.
* emulparams/elf32bmipn32-defs.sh: Set NATIVE and LIBPATH_SUFFIX
instead of setting LIB_PATH.
* emulparams/elf32ppc.sh: Likewise.
* emulparams/elf64_s390.sh: Likewise.
* emulparams/elf64_sparc.sh: Likewise.
* emulparams/elf64ppc.sh: Likewise.
* emulparams/elf_x86_64.sh: Likewise.
* emulparams/elf64_aix.sh: Add "=" prefixes to LIB_PATH.
* emulparams/elf64hppa.sh: Add "=" prefixes to LIB_PATH.
Diffstat (limited to 'ld/emultempl')
-rw-r--r-- | ld/emultempl/elf32.em | 108 |
1 files changed, 75 insertions, 33 deletions
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em index b7c31fa..a776d58 100644 --- a/ld/emultempl/elf32.em +++ b/ld/emultempl/elf32.em @@ -13,7 +13,7 @@ cat >e${EMULATION_NAME}.c <<EOF /* ${ELFSIZE} bit ELF emulation code for ${EMULATION_NAME} Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002 Free Software Foundation, Inc. + 2002, 2003 Free Software Foundation, Inc. Written by Steve Chamberlain <sac@cygnus.com> ELF support by Ian Lance Taylor <ian@cygnus.com> @@ -439,12 +439,48 @@ gld${EMULATION_NAME}_search_needed (path, name, force) } EOF -if [ "x${host}" = "x${target}" ] ; then - case " ${EMULATION_LIBPATH} " in - *" ${EMULATION_NAME} "*) - case ${target} in - *-*-linux-gnu*) - cat >>e${EMULATION_NAME}.c <<EOF +if [ "x${USE_LIBPATH}" = xyes ] ; then + case ${target} in + *-*-linux-gnu*) + cat >>e${EMULATION_NAME}.c <<EOF + +/* Add the sysroot to every entry in a colon-separated path. */ + +static char * +gld${EMULATION_NAME}_add_sysroot (path) + const char *path; +{ + int len, colons, i; + char *ret, *p; + + len = strlen (path); + colons = 0; + i = 0; + while (path[i]) + if (path[i++] == ':') + colons++; + + if (path[i]) + colons++; + + len = len + colons * strlen (ld_sysroot); + ret = xmalloc (len + 1); + strcpy (ret, ld_sysroot); + p = ret + strlen (ret); + i = 0; + while (path[i]) + if (path[i] == ':') + { + strcpy (p, ld_sysroot); + p = p + strlen (p); + i++; + } + else + *p++ = path[i++]; + + *p = 0; + return ret; +} /* For a native linker, check the file /etc/ld.so.conf for directories in which we may find shared libraries. /etc/ld.so.conf is really @@ -464,8 +500,11 @@ gld${EMULATION_NAME}_check_ld_so_conf (name, force) if (! initialized) { FILE *f; + char *tmppath; - f = fopen ("/etc/ld.so.conf", FOPEN_RT); + tmppath = concat (ld_sysroot, "/etc/ld.so.conf", NULL); + f = fopen (tmppath, FOPEN_RT); + free (tmppath); if (f != NULL) { char *b; @@ -515,6 +554,13 @@ gld${EMULATION_NAME}_check_ld_so_conf (name, force) fclose (f); + if (b) + { + char *d = gld${EMULATION_NAME}_add_sysroot (b); + free (b); + b = d; + } + ld_so_conf = b; } @@ -528,9 +574,8 @@ gld${EMULATION_NAME}_check_ld_so_conf (name, force) } EOF - # Linux - ;; - esac + # Linux + ;; esac fi cat >>e${EMULATION_NAME}.c <<EOF @@ -644,16 +689,12 @@ gld${EMULATION_NAME}_after_open () size_t len; search_dirs_type *search; EOF -if [ "x${host}" = "x${target}" ] ; then - case " ${EMULATION_LIBPATH} " in - *" ${EMULATION_NAME} "*) +if [ "x${USE_LIBPATH}" = xyes ] ; then cat >>e${EMULATION_NAME}.c <<EOF const char *lib_path; struct bfd_link_needed_list *rp; int found; EOF - ;; - esac fi cat >>e${EMULATION_NAME}.c <<EOF @@ -661,13 +702,15 @@ cat >>e${EMULATION_NAME}.c <<EOF l->name, force)) break; EOF -if [ "x${host}" = "x${target}" ] ; then - case " ${EMULATION_LIBPATH} " in - *" ${EMULATION_NAME} "*) +if [ "x${USE_LIBPATH}" = xyes ] ; then cat >>e${EMULATION_NAME}.c <<EOF if (gld${EMULATION_NAME}_search_needed (command_line.rpath, l->name, force)) break; +EOF +fi +if [ "x${NATIVE}" = xyes ] ; then +cat >>e${EMULATION_NAME}.c <<EOF if (command_line.rpath_link == NULL && command_line.rpath == NULL) { @@ -679,22 +722,25 @@ cat >>e${EMULATION_NAME}.c <<EOF lib_path = (const char *) getenv ("LD_LIBRARY_PATH"); if (gld${EMULATION_NAME}_search_needed (lib_path, l->name, force)) break; - +EOF +fi +if [ "x${USE_LIBPATH}" = xyes ] ; then +cat >>e${EMULATION_NAME}.c <<EOF found = 0; rp = bfd_elf_get_runpath_list (output_bfd, &link_info); for (; !found && rp != NULL; rp = rp->next) { + char *tmpname = gld${EMULATION_NAME}_add_sysroot (rp->name); found = (rp->by == l->by - && gld${EMULATION_NAME}_search_needed (rp->name, + && gld${EMULATION_NAME}_search_needed (tmpname, l->name, force)); + free (tmpname); } if (found) break; EOF - ;; - esac fi cat >>e${EMULATION_NAME}.c <<EOF len = strlen (l->name); @@ -713,19 +759,15 @@ cat >>e${EMULATION_NAME}.c <<EOF if (search != NULL) break; EOF -if [ "x${host}" = "x${target}" ] ; then - case " ${EMULATION_LIBPATH} " in - *" ${EMULATION_NAME} "*) - case ${target} in - *-*-linux-gnu*) - cat >>e${EMULATION_NAME}.c <<EOF +if [ "x${USE_LIBPATH}" = xyes ] ; then + case ${target} in + *-*-linux-gnu*) + cat >>e${EMULATION_NAME}.c <<EOF if (gld${EMULATION_NAME}_check_ld_so_conf (l->name, force)) break; EOF - # Linux - ;; - esac - ;; + # Linux + ;; esac fi cat >>e${EMULATION_NAME}.c <<EOF |