aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorDavid MacKenzie <djm@cygnus>1993-07-13 00:54:45 +0000
committerDavid MacKenzie <djm@cygnus>1993-07-13 00:54:45 +0000
commitf42084627b449996204810c61068505deffe77af (patch)
treec53ed4c48ebbe24d077b8b96e7ae69364a1072c9 /ld
parent8549490910bfca42afe8eb51f66aeb143d647c25 (diff)
downloadgdb-f42084627b449996204810c61068505deffe77af.zip
gdb-f42084627b449996204810c61068505deffe77af.tar.gz
gdb-f42084627b449996204810c61068505deffe77af.tar.bz2
* ldmain.c (set_scripts_dir): Check . and <ld bin dir>/../lib for
ldscripts, as well as <ld bin dir> and SCRIPTDIR.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog3
-rw-r--r--ld/ldmain.c44
2 files changed, 33 insertions, 14 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 7445fe3..46dadca 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,8 @@
Mon Jul 12 11:45:48 1993 David J. Mackenzie (djm@thepub.cygnus.com)
+ * ldmain.c (set_scripts_dir): Check . and <ld bin dir>/../lib for
+ ldscripts, as well as <ld bin dir> and SCRIPTDIR.
+
* ldlang.c (lang_process): Use sizeof instead of magic constant.
* ldmain.c (get_emulation, check_for_scripts_dir,
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 111edea..9239c4a 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -338,36 +338,52 @@ check_for_scripts_dir (dir)
sprintf (buf, "%s/ldscripts", dir);
res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
+ free (buf);
if (res)
- {
- buf[dirlen] = '\0';
- ldfile_add_library_path (buf);
- }
- else
- free (buf);
-
+ ldfile_add_library_path (dir);
return res;
}
/* Set the default directory for finding script files.
- Libraries will be searched for here too, but that's ok. */
+ Libraries will be searched for here too, but that's ok.
+ We look for the "ldscripts" directory in:
+
+ the curent dir
+ SCRIPTDIR (passed from Makefile)
+ the dir where this program is
+ the dir where this program is/../lib */
static void
set_scripts_dir ()
{
- char *end;
+ char *end, *dir;
+ size_t dirlen;
+
+ if (check_for_scripts_dir ("."))
+ return; /* Newest version, most likely. */
if (check_for_scripts_dir (SCRIPTDIR))
- return; /* Good--we've been installed. */
+ return; /* We've been installed normally. */
/* Look for "ldscripts" in the dir where our binary is. */
end = strrchr (program_name, '/');
if (!end)
- return; /* Hope for the best. */
+ return;
+
+ /* Make a copy of program_name in dir. */
+ dirlen = end - program_name;
+ dir = (char *) ldmalloc (dirlen + 8); /* Leave room for later "/../lib". */
+ strncpy (dir, program_name, dirlen);
+ dir[dirlen] = '\0';
+ if (check_for_scripts_dir (dir))
+ return; /* Don't free dir. */
+
+ /* Look for "ldscripts" in <the dir where our binary is>/../lib. */
+ strcpy (dir + dirlen, "/../lib");
+ if (check_for_scripts_dir (dir))
+ return;
- *end = '\0';
- check_for_scripts_dir (program_name);
- *end = '/';
+ free (dir); /* Well, we tried. */
}
void