This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: PATCH: PR ld/10047: [Regression] ld-new -m XXX no longer works


On Sun, Apr 12, 2009 at 07:10:59AM -0700, H.J. Lu wrote:
> On Sat, Apr 11, 2009 at 8:03 PM, Alan Modra <amodra@bigpond.net.au> wrote:
> > On Sat, Apr 11, 2009 at 07:04:27AM -0700, H.J. Lu wrote:
> >> Hi,
> >>
> >> I am checking in this patch to restore try raw name first for default
> >> linker script.
> >
> > Did one of the global maintainers approve this? ?I'm not convinced
> > this is correct, since it would appear to only benefit maintainers.
> > At least someone else agrees with me, given the comment in
> > find_scripts_dir which was present in rev 1.1 of ldmain.c.
> >
> > ? ?/* Don't look for ldscripts in the current directory. ?There is
> > ? ? ? too much potential for confusion. ?*/
> >
> 
> I fixed a bug to to restore the old behavior which my scripts depend on.
> However, if the old behavior is a bug, I will revert my fix and change
> my scripts.

HJ, Please revert your patch, and I'll apply this one instead.

make_relative_prefix contains code to look up $PATH when argv[0] is a
file name without path, so there should be no dependency on the
current directory.  Also, SCRIPTDIR is always ../lib relative to
TOOLBINDIR (unless someone is overriding make variables), so
  /* Look for "ldscripts" in <the dir where our binary is>/../lib.  */
has already been done with
  make_relative_prefix (program_name, TOOLBINDIR, SCRIPTDIR).

	* ldfile.c (find_scripts_dir): Use make_relative_prefix to find
	ldscripts in build tree.  Don't repeat search for ../lib/ldscripts.

Index: ld/ldfile.c
===================================================================
RCS file: /cvs/src/src/ld/ldfile.c,v
retrieving revision 1.49
diff -u -p -r1.49 ldfile.c
--- ld/ldfile.c	6 Apr 2009 01:21:09 -0000	1.49
+++ ld/ldfile.c	13 Apr 2009 23:57:10 -0000
@@ -477,15 +477,12 @@ check_for_scripts_dir (char *dir)
    SCRIPTDIR (passed from Makefile)
 	     (adjusted according to the current location of the binary)
    SCRIPTDIR (passed from Makefile)
-   the dir where this program is (for using it from the build tree)
-   the dir where this program is/../lib
-	     (for installing the tool suite elsewhere).  */
+   the dir where this program is (for using it from the build tree).  */
 
 static char *
 find_scripts_dir (void)
 {
-  char *end, *dir;
-  size_t dirlen;
+  char *dir;
 
   dir = make_relative_prefix (program_name, BINDIR, SCRIPTDIR);
   if (dir)
@@ -508,37 +505,14 @@ find_scripts_dir (void)
     return SCRIPTDIR;
 
   /* Look for "ldscripts" in the dir where our binary is.  */
-  end = strrchr (program_name, '/');
-#ifdef HAVE_DOS_BASED_FILE_SYSTEM
-  {
-    /* We could have \foo\bar, or /foo\bar.  */
-    char *bslash = strrchr (program_name, '\\');
-
-    if (end == NULL || (bslash != NULL && bslash > end))
-      end = bslash;
-  }
-#endif
-
-  if (end == NULL)
-    /* Don't look for ldscripts in the current directory.  There is
-       too much potential for confusion.  */
-    return NULL;
-
-  dirlen = end - program_name;
-  /* Make a copy of program_name in dir.
-     Leave room for later "/../lib".  */
-  dir = xmalloc (dirlen + sizeof ("/../lib"));
-  strncpy (dir, program_name, dirlen);
-  dir[dirlen] = '\0';
-
-  if (check_for_scripts_dir (dir))
-    return dir;
-
-  /* Look for "ldscripts" in <the dir where our binary is>/../lib.  */
-  strcpy (dir + dirlen, "/../lib");
-  if (check_for_scripts_dir (dir))
-    return dir;
-  free (dir);
+  dir = make_relative_prefix (program_name, ".", ".");
+  if (dir)
+    {
+      if (check_for_scripts_dir (dir))
+	return dir;
+      free (dir);
+    }
+
   return NULL;
 }
 

-- 
Alan Modra
Australia Development Lab, IBM


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