diff options
author | David MacKenzie <djm@cygnus> | 1993-07-13 00:54:45 +0000 |
---|---|---|
committer | David MacKenzie <djm@cygnus> | 1993-07-13 00:54:45 +0000 |
commit | f42084627b449996204810c61068505deffe77af (patch) | |
tree | c53ed4c48ebbe24d077b8b96e7ae69364a1072c9 /ld/ldmain.c | |
parent | 8549490910bfca42afe8eb51f66aeb143d647c25 (diff) | |
download | ppe42-binutils-f42084627b449996204810c61068505deffe77af.tar.gz ppe42-binutils-f42084627b449996204810c61068505deffe77af.zip |
* 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/ldmain.c')
-rw-r--r-- | ld/ldmain.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c index 111edea5a0..9239c4a948 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 |