diff options
author | Nick Clifton <nickc@redhat.com> | 2024-05-10 16:59:05 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2024-05-10 16:59:05 +0100 |
commit | 6e8376fa569e62379a42b91b0afd1f4086f1d897 (patch) | |
tree | d9bddaa0a8b3b242ba063df4dbbee272220ea385 /ld/ldmain.c | |
parent | ad658482c1e4feec4ac99c8e7df17ff78d0c2996 (diff) | |
download | binutils-6e8376fa569e62379a42b91b0afd1f4086f1d897.zip binutils-6e8376fa569e62379a42b91b0afd1f4086f1d897.tar.gz binutils-6e8376fa569e62379a42b91b0afd1f4086f1d897.tar.bz2 |
Add --section-ordering command line option to the bfd linker.
Diffstat (limited to 'ld/ldmain.c')
-rw-r--r-- | ld/ldmain.c | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/ld/ldmain.c b/ld/ldmain.c index fe38968..037099b 100644 --- a/ld/ldmain.c +++ b/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; |