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;
+static lang_input_statement_type *current_input_file;
struct bfd_elf_dynamic_list **current_dynamic_list_p;
struct bfd_sym_chain entry_symbol = { NULL, NULL };
const char *entry_section = ".text";
FAIL ();
}
- lang_statement_append (&input_file_chain, p, &p->next_real_file);
+ if (current_input_file != NULL)
+ {
+ lang_input_statement_type *f, *prev;
+
+ /* Insert the new input file before the current input file to
+ maintain the input file order. NB: The first item on the
+ input file chain is a null one. */
+ prev = &input_file_chain.head->input_statement;
+ for (f = prev->next_real_file;
+ f != NULL;
+ f = f->next_real_file)
+ {
+ if (f == current_input_file)
+ {
+ p->next_real_file = prev->next_real_file;
+ prev->next_real_file = p;
+ break;
+ }
+ prev = f;
+ }
+
+ if (f == NULL)
+ abort ();
+ }
+ else
+ lang_statement_append (&input_file_chain, p, &p->next_real_file);
return p;
}
return ret;
}
- return new_afile (name, file_type, target, current_input_file);
+ return new_afile (name, file_type, target,
+ (current_input_file
+ ? current_input_file->filename
+ : NULL));
}
struct out_section_hash_entry
ldfile_assumed_script = true;
parser_input = input_script;
- current_input_file = entry->filename;
+ current_input_file = entry;
yyparse ();
current_input_file = NULL;
ldfile_assumed_script = false;
}
}
+static void
+debug_input_files (void)
+{
+ lang_input_statement_type *f;
+
+ for (f = &input_file_chain.head->input_statement;
+ f != NULL;
+ f = f->next_real_file)
+ if (f->the_bfd)
+ fprintf (stderr, "file: %s\n", f->the_bfd->filename);
+ else
+ fprintf (stderr, "input: %s\n", f->filename);
+}
+
/* Call a function on each real input file. This function will be
called on an archive, but not on the elements. */
lang_common ();
if (0)
- debug_prefix_tree ();
+ {
+ debug_prefix_tree ();
+ debug_input_files ();
+ }
resolve_wilds ();