This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Patch: Re: bug in ld -rpath ??


On Tue, Aug 22, 2000 at 07:26:37PM -0400, Robert E. Brown wrote:
> 
> I have tracked down the bug that stopped your patches from working for me in
> my build environment.  In function gldelf_i386_after_open in file
> eelf_i386.c near the top, there is the statement:
> 
>   run_path = bfd_elf_get_runpath_list (output_bfd, &link_info);
> 
> Later, run_path is searched.  Unfortunately, if run_path is NULL and a call
> to gldelf_i386_search_needed results in a library being read, the contents
> of
> 
>     bfd_elf_get_runpath_list (output_bfd, &link_info)
> 
> can be set to contain a non-NULL runpath, making the local run_path variable
> invalid.  Hence, run_path should be set right before it is used.
> 
> 				bob

Oops. You are right. This patch is against the current CVS on
sourceware. Ok to install?

Thanks.


H.J.
---
2000-08-22  H.J. Lu  <hjl@gnu.org>

	* emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Get
	the current runpath list from bfd_elf_get_runpath_list ()
	before search.

Index: ChangeLog
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ChangeLog,v
retrieving revision 1.1.1.76
diff -u -p -r1.1.1.76 ChangeLog
--- ChangeLog	2000/08/22 23:50:16	1.1.1.76
+++ ChangeLog	2000/08/23 01:16:00
@@ -8,7 +8,7 @@
 	if trace_file_tries is non-zero.
 
 	* ld.texinfo: Document the usage of DT_RPATH/DT_RUNPATH.
-	* News: Mention it.
+	* NEWS: Mention it.
 
 2000-08-14  Jason Eckhardt  <jle@cygnus.com>
 
Index: emultempl/elf32.em
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/emultempl/elf32.em,v
retrieving revision 1.25
diff -u -p -r1.25 elf32.em
--- emultempl/elf32.em	2000/08/23 00:16:31	1.25
+++ emultempl/elf32.em	2000/08/23 01:14:29
@@ -570,34 +570,11 @@ static void
 gld${EMULATION_NAME}_after_open ()
 {
   struct bfd_link_needed_list *needed, *l;
-EOF
-if [ "x${host}" = "x${target}" ] ; then
-  case " ${EMULATION_LIBPATH} " in
-  *" ${EMULATION_NAME} "*)
-cat >>e${EMULATION_NAME}.c <<EOF
-  struct bfd_link_needed_list *run_path;
-EOF
-  ;;
-  esac
-fi
-cat >>e${EMULATION_NAME}.c <<EOF
 
   /* We only need to worry about this when doing a final link.  */
   if (link_info.relocateable || link_info.shared)
     return;
 
-EOF
-if [ "x${host}" = "x${target}" ] ; then
-  case " ${EMULATION_LIBPATH} " in
-  *" ${EMULATION_NAME} "*)
-cat >>e${EMULATION_NAME}.c <<EOF
-  run_path = bfd_elf_get_runpath_list (output_bfd, &link_info);
-EOF
-  ;;
-  esac
-fi
-cat >>e${EMULATION_NAME}.c <<EOF
-
   /* Get the list of files which appear in DT_NEEDED entries in
      dynamic objects included in the link (often there will be none).
      For each such file, we want to track down the corresponding
@@ -612,18 +589,6 @@ cat >>e${EMULATION_NAME}.c <<EOF
     {
       struct bfd_link_needed_list *ll;
       int force;
-EOF
-if [ "x${host}" = "x${target}" ] ; then
-  case " ${EMULATION_LIBPATH} " in
-  *" ${EMULATION_NAME} "*)
-cat >>e${EMULATION_NAME}.c <<EOF
-      struct bfd_link_needed_list *rp;
-      int found;
-EOF
-  ;;
-  esac
-fi
-cat >>e${EMULATION_NAME}.c <<EOF
 
       /* If we've already seen this file, skip it.  */
       for (ll = needed; ll != l; ll = ll->next)
@@ -658,6 +623,18 @@ cat >>e${EMULATION_NAME}.c <<EOF
 	  const char *lib_path;
 	  size_t len;
 	  search_dirs_type *search;
+EOF
+if [ "x${host}" = "x${target}" ] ; then
+  case " ${EMULATION_LIBPATH} " in
+  *" ${EMULATION_NAME} "*)
+cat >>e${EMULATION_NAME}.c <<EOF
+	  struct bfd_link_needed_list *rp;
+	  int found;
+EOF
+  ;;
+  esac
+fi
+cat >>e${EMULATION_NAME}.c <<EOF
 
 	  if (gld${EMULATION_NAME}_search_needed (command_line.rpath_link,
 						  l->name, force))
@@ -683,7 +660,8 @@ cat >>e${EMULATION_NAME}.c <<EOF
 	    break;
 
 	  found = 0;
-	  for (rp = run_path; !found && rp != NULL; rp = rp->next)
+	  rp = bfd_elf_get_runpath_list (output_bfd, &link_info);
+	  for (; !found && rp != NULL; rp = rp->next)
 	    {
 	      found = (rp->by == l->by
 		       && gld${EMULATION_NAME}_search_needed (rp->name,

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]