mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 09:38:57 +00:00
Add --section-ordering command line option to the bfd linker.
This commit is contained in:
55
ld/ldmain.c
55
ld/ldmain.c
@@ -90,6 +90,8 @@ bool version_printed;
|
||||
/* TRUE if we should demangle symbol names. */
|
||||
bool demangling;
|
||||
|
||||
bool in_section_ordering;
|
||||
|
||||
args_type command_line;
|
||||
|
||||
ld_config_type config;
|
||||
@@ -246,6 +248,26 @@ ld_bfd_error_handler (const char *fmt, va_list ap)
|
||||
(*default_bfd_error_handler) (fmt, ap);
|
||||
}
|
||||
|
||||
static void
|
||||
display_external_script (void)
|
||||
{
|
||||
if (saved_script_handle == NULL)
|
||||
return;
|
||||
|
||||
static const int ld_bufsz = 8193;
|
||||
size_t n;
|
||||
char *buf = (char *) xmalloc (ld_bufsz);
|
||||
|
||||
rewind (saved_script_handle);
|
||||
while ((n = fread (buf, 1, ld_bufsz - 1, saved_script_handle)) > 0)
|
||||
{
|
||||
buf[n] = 0;
|
||||
info_msg ("%s", buf);
|
||||
}
|
||||
rewind (saved_script_handle);
|
||||
free (buf);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
@@ -416,26 +438,13 @@ main (int argc, char **argv)
|
||||
if (verbose)
|
||||
{
|
||||
if (saved_script_handle)
|
||||
info_msg (_("using external linker script:"));
|
||||
info_msg (_("using external linker script: %s"), processed_scripts->name);
|
||||
else
|
||||
info_msg (_("using internal linker script:"));
|
||||
info_msg ("\n==================================================\n");
|
||||
|
||||
if (saved_script_handle)
|
||||
{
|
||||
static const int ld_bufsz = 8193;
|
||||
size_t n;
|
||||
char *buf = (char *) xmalloc (ld_bufsz);
|
||||
|
||||
rewind (saved_script_handle);
|
||||
while ((n = fread (buf, 1, ld_bufsz - 1, saved_script_handle)) > 0)
|
||||
{
|
||||
buf[n] = 0;
|
||||
info_msg ("%s", buf);
|
||||
}
|
||||
rewind (saved_script_handle);
|
||||
free (buf);
|
||||
}
|
||||
display_external_script ();
|
||||
else
|
||||
{
|
||||
int isfile;
|
||||
@@ -446,6 +455,22 @@ main (int argc, char **argv)
|
||||
info_msg ("\n==================================================\n");
|
||||
}
|
||||
|
||||
if (command_line.section_ordering_file)
|
||||
{
|
||||
FILE *hold_script_handle;
|
||||
|
||||
hold_script_handle = saved_script_handle;
|
||||
ldfile_open_command_file (command_line.section_ordering_file);
|
||||
if (verbose)
|
||||
display_external_script ();
|
||||
saved_script_handle = hold_script_handle;
|
||||
in_section_ordering = true;
|
||||
parser_input = input_section_ordering_script;
|
||||
yyparse ();
|
||||
in_section_ordering = false;
|
||||
|
||||
}
|
||||
|
||||
if (command_line.force_group_allocation
|
||||
|| !bfd_link_relocatable (&link_info))
|
||||
link_info.resolve_section_groups = true;
|
||||
|
||||
Reference in New Issue
Block a user