/* Linker file opening and searching.
- Copyright (C) 1991, 92, 93, 94, 95, 98, 99, 2000
+ Copyright 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
This file is part of GLD, the Gnu Linker.
#include "ldgram.h"
#include "ldlex.h"
#include "ldemul.h"
+#include "libiberty.h"
#include <ctype.h>
static search_dirs_type **search_tail_ptr = &search_head;
-typedef struct search_arch
-{
+typedef struct search_arch {
char *name;
struct search_arch *next;
} search_arch_type;
}
for (search = search_head;
- search != (search_dirs_type *)NULL;
+ search != (search_dirs_type *) NULL;
search = search->next)
{
char *string;
else
{
search_arch_type *arch;
+ boolean found = false;
/* Try to open <filename><suffix> or lib<filename><suffix>.a */
for (arch = search_arch_head;
arch != (search_arch_type *) NULL;
arch = arch->next)
{
- if (ldfile_open_file_search (arch->name, entry, "lib", ".a"))
- return;
+ found = ldfile_open_file_search (arch->name, entry, "lib", ".a");
+ if (found)
+ break;
#ifdef VMS
- if (ldfile_open_file_search (arch->name, entry, ":lib", ".a"))
- return;
+ found = ldfile_open_file_search (arch->name, entry, ":lib", ".a");
+ if (found)
+ break;
#endif
- if (ldemul_find_potential_libraries (arch->name, entry))
- return;
+ found = ldemul_find_potential_libraries (arch->name, entry);
+ if (found)
+ break;
}
- einfo (_("%F%P: cannot find %s\n"), entry->local_sym_name);
+ /* If we have found the file, we don't need to search directories
+ again. */
+ if (found)
+ entry->search_dirs_flag = false;
+ else
+ einfo (_("%F%P: cannot find %s\n"), entry->local_sym_name);
}
}
FILE *result;
char buffer[1000];
- /* First try raw name */
+ /* First try raw name. */
result = try_open (name, "");
- if (result == (FILE *)NULL)
+ if (result == (FILE *) NULL)
{
- /* Try now prefixes */
+ /* Try now prefixes. */
for (search = search_head;
- search != (search_dirs_type *)NULL;
+ search != (search_dirs_type *) NULL;
search = search->next)
{
- sprintf (buffer,"%s%s%s", search->name, slash, name);
+ sprintf (buffer, "%s%s%s", search->name, slash, name);
result = try_open (buffer, extend);
if (result)
FILE *ldlex_input_stack;
ldlex_input_stack = ldfile_find_command_file (name, "");
- if (ldlex_input_stack == (FILE *)NULL)
+ if (ldlex_input_stack == (FILE *) NULL)
{
bfd_set_error (bfd_error_system_call);
einfo (_("%P%F: cannot open linker script file %s: %E\n"), name);
}
if (tp->cmd_switch == NULL)
- einfo (_("%P%F: unknown architecture: %s\n"),name);
+ einfo (_("%P%F: unknown architecture: %s\n"), name);
return tp->arch;
}
char *name;
{
search_arch_type *new =
- (search_arch_type *)xmalloc ((bfd_size_type)(sizeof (search_arch_type)));
+ (search_arch_type *) xmalloc ((bfd_size_type) (sizeof (search_arch_type)));
if (*name != '\0')
{
ldfile_output_machine_name = name;
}
- new->next = (search_arch_type*)NULL;
+ new->next = (search_arch_type *) NULL;
new->name = gnu960_map_archname (name);
*search_arch_tail_ptr = new;
search_arch_tail_ptr = &new->next;
}
-#else /* not GNU960 */
+#else /* not GNU960 */
void
ldfile_add_arch (in_name)
- CONST char * in_name;
+ CONST char *in_name;
{
- char *name = buystring (in_name);
+ char *name = xstrdup (in_name);
search_arch_type *new =
(search_arch_type *) xmalloc (sizeof (search_arch_type));
ldfile_output_machine_name = in_name;
new->name = name;
- new->next = (search_arch_type*)NULL;
+ new->next = (search_arch_type *) NULL;
while (*name)
{
if (isupper ((unsigned char) *name))
}
#endif
-/* Set the output architecture */
+/* Set the output architecture. */
+
void
ldfile_set_output_arch (string)
CONST char *string;