lang_input_statement_type statement (reached via input_statement field in a
lang_statement_union). */
lang_statement_list_type input_file_chain;
+static const char *current_input_file;
struct bfd_sym_chain entry_symbol = { NULL, NULL };
const char *entry_section = ".text";
struct lang_input_statement_flags input_flags;
return strcmp (pattern, name);
}
+static char *
+ldirname (const char *name)
+{
+ const char *base = lbasename (name);
+ char *dirname;
+
+ while (base > name && IS_DIR_SEPARATOR (base[-1]))
+ --base;
+ if (base == name)
+ return strdup (".");
+ dirname = strdup (name);
+ dirname[base - name] = '\0';
+ return dirname;
+}
+
/* If PATTERN is of the form archive:file, return a pointer to the
separator. If not, return NULL. */
static lang_input_statement_type *
new_afile (const char *name,
lang_input_file_enum_type file_type,
- const char *target)
+ const char *target,
+ const char *from_filename)
{
lang_input_statement_type *p;
p = new_stat (lang_input_statement, stat_ptr);
memset (&p->the_bfd, 0,
sizeof (*p) - offsetof (lang_input_statement_type, the_bfd));
+ p->extra_search_path = NULL;
p->target = target;
p->flags.dynamic = input_flags.dynamic;
p->flags.add_DT_NEEDED_for_dynamic = input_flags.add_DT_NEEDED_for_dynamic;
case lang_input_file_is_search_file_enum:
p->filename = name;
p->local_sym_name = name;
+ /* If name is a relative path, search the directory of the current linker
+ script first. */
+ if (from_filename && !IS_ABSOLUTE_PATH (name))
+ p->extra_search_path = ldirname (from_filename);
p->flags.real = TRUE;
p->flags.search_dirs = TRUE;
break;
within the sysroot subdirectory.) */
unsigned int outer_sysrooted = input_flags.sysrooted;
input_flags.sysrooted = 0;
- ret = new_afile (sysrooted_name, file_type, target);
+ ret = new_afile (sysrooted_name, file_type, target, NULL);
input_flags.sysrooted = outer_sysrooted;
return ret;
}
- return new_afile (name, file_type, target);
+ return new_afile (name, file_type, target, current_input_file);
}
struct out_section_hash_entry
lang_statement_union_type *rest = *after;
stat_ptr->tail = after;
search = new_afile (name, lang_input_file_is_search_file_enum,
- default_target);
+ default_target, NULL);
*stat_ptr->tail = rest;
if (*tail == NULL)
stat_ptr->tail = tail;
ldfile_assumed_script = TRUE;
parser_input = input_script;
+ current_input_file = entry->filename;
yyparse ();
+ current_input_file = NULL;
ldfile_assumed_script = FALSE;
/* missing_file is sticky. sysrooted will already have been
if (dot + TO_ADDR (i->size) > end)
{
if (i->flags & SEC_LINKER_CREATED)
- {
- einfo (_("Output section '%s' not large enough for the "
- "linker-created stubs section '%s'.\n"),
- i->output_section->name, i->name);
- abort();
- }
+ einfo (_("%F%P: Output section '%s' not large enough for the "
+ "linker-created stubs section '%s'.\n"),
+ i->output_section->name, i->name);
if (i->rawsize && i->rawsize != i->size)
- {
- einfo (_("Relaxation not supported with "
- "--enable-non-contiguous-regions (section '%s' "
- "would overflow '%s' after it changed size).\n"),
- i->name, i->output_section->name);
- abort();
- }
+ einfo (_("%F%P: Relaxation not supported with "
+ "--enable-non-contiguous-regions (section '%s' "
+ "would overflow '%s' after it changed size).\n"),
+ i->name, i->output_section->name);
*removed = 1;
dot = end;
bfd_printable_name (input_bfd), input_bfd,
bfd_printable_name (link_info.output_bfd));
}
- else if (bfd_count_sections (input_bfd))
- {
- /* If the input bfd has no contents, it shouldn't set the
- private data of the output bfd. */
+ /* If the input bfd has no contents, it shouldn't set the
+ private data of the output bfd. */
+ else if ((input_bfd->flags & DYNAMIC) != 0
+ || bfd_count_sections (input_bfd) != 0)
+ {
bfd_error_handler_type pfn = NULL;
/* If we aren't supposed to warn about mismatched input