/* Linker file opening and searching.
Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001, 2002,
- 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU Binutils.
void
ldfile_add_library_path (const char *name, bfd_boolean cmdline)
{
- search_dirs_type *new;
+ search_dirs_type *new_dirs;
if (!cmdline && config.only_cmd_line_lib_dirs)
return;
- new = xmalloc (sizeof (search_dirs_type));
- new->next = NULL;
- new->cmdline = cmdline;
- *search_tail_ptr = new;
- search_tail_ptr = &new->next;
+ new_dirs = (search_dirs_type *) xmalloc (sizeof (search_dirs_type));
+ new_dirs->next = NULL;
+ new_dirs->cmdline = cmdline;
+ *search_tail_ptr = new_dirs;
+ search_tail_ptr = &new_dirs->next;
/* If a directory is marked as honoring sysroot, prepend the sysroot path
now. */
if (name[0] == '=')
{
- new->name = concat (ld_sysroot, name + 1, (const char *) NULL);
- new->sysrooted = TRUE;
+ new_dirs->name = concat (ld_sysroot, name + 1, (const char *) NULL);
+ new_dirs->sysrooted = TRUE;
}
else
{
- new->name = xstrdup (name);
- new->sysrooted = is_sysrooted_pathname (name, FALSE);
+ new_dirs->name = xstrdup (name);
+ new_dirs->sysrooted = is_sysrooted_pathname (name, FALSE);
}
}
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)
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
+ dir = make_relative_prefix (program_name, ".", ".");
+ if (dir)
+ {
+ if (check_for_scripts_dir (dir))
+ return dir;
+ free (dir);
+ }
- 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);
return NULL;
}
ldfile_add_arch (const char *in_name)
{
char *name = xstrdup (in_name);
- search_arch_type *new = xmalloc (sizeof (search_arch_type));
+ search_arch_type *new_arch = (search_arch_type *)
+ xmalloc (sizeof (search_arch_type));
ldfile_output_machine_name = in_name;
- new->name = name;
- new->next = NULL;
+ new_arch->name = name;
+ new_arch->next = NULL;
while (*name)
{
*name = TOLOWER (*name);
name++;
}
- *search_arch_tail_ptr = new;
- search_arch_tail_ptr = &new->next;
+ *search_arch_tail_ptr = new_arch;
+ search_arch_tail_ptr = &new_arch->next;
}