diff options
author | Roland McGrath <roland@gnu.org> | 2011-07-16 07:58:40 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2011-07-16 07:58:40 +0000 |
commit | 30824704e933a2dad20afc97be7bce651e4b5ac1 (patch) | |
tree | 49a5ba33578f0ab2f30b548e4dbd12af83baa7c1 | |
parent | 436ce5e7e644c7b1746e83fa371b2fda18a83aad (diff) | |
download | gdb-30824704e933a2dad20afc97be7bce651e4b5ac1.zip gdb-30824704e933a2dad20afc97be7bce651e4b5ac1.tar.gz gdb-30824704e933a2dad20afc97be7bce651e4b5ac1.tar.bz2 |
Implement ld --print-output-format.
-rw-r--r-- | ld/ChangeLog | 11 | ||||
-rw-r--r-- | ld/ld.h | 3 | ||||
-rw-r--r-- | ld/ld.texinfo | 7 | ||||
-rw-r--r-- | ld/ldlang.c | 2 | ||||
-rw-r--r-- | ld/ldmain.c | 5 | ||||
-rw-r--r-- | ld/lexsup.c | 6 |
6 files changed, 32 insertions, 2 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 768d2bb..220ffe5 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,14 @@ +2011-07-16 Roland McGrath <roland@hack.frob.com> + + * ld.h (args_type): New field print_output_format. + * lexsup.c (enum option_values, ld_options, parse_args): + Handle --print-output-format. + * ldmain.c (main): Implement --print-output-format. + * ld.texinfo (Options): Document it. + + * ldlang.c (lang_get_output_target): Don't return current_target + when it's NULL. + 2011-07-15 Alan Modra <amodra@gmail.com> * Makefile.am (e*.c): Sort. @@ -200,6 +200,9 @@ typedef struct { input files. */ bfd_boolean accept_unknown_input_arch; + /* If TRUE we'll just print the default output on stdout. */ + bfd_boolean print_output_format; + /* Big or little endian as set on command line. */ enum endian_enum endian; diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 4fb649a..7547c0a5 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -1401,6 +1401,13 @@ default behaviour (of not listing the sections that are removed) can be restored by specifying @samp{--no-print-gc-sections} on the command line. +@kindex --print-output-format +@cindex output format +@item --print-output-format +Print the name of the default output format (perhaps influenced by +other command-line options). This is the string that would appear +in an @code{OUTPUT_FORMAT} linker script command (@pxref{File Commands}). + @cindex help @cindex usage @kindex --help diff --git a/ld/ldlang.c b/ld/ldlang.c index 3e63eed..0ffafb6 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -3052,7 +3052,7 @@ lang_get_output_target (void) /* No - has the current target been set to something other than the default? */ - if (current_target != default_target) + if (current_target != default_target && current_target != NULL) return current_target; /* No - can we determine the format of the first input file? */ diff --git a/ld/ldmain.c b/ld/ldmain.c index 1b4afff..ec9dcff 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -427,11 +427,14 @@ main (int argc, char **argv) info_msg ("\n==================================================\n"); } + if (command_line.print_output_format) + info_msg ("%s\n", lang_get_output_target ()); + lang_final (); if (!lang_has_input_file) { - if (version_printed) + if (version_printed || command_line.print_output_format) xexit (0); einfo (_("%P%F: no input files\n")); } diff --git a/ld/lexsup.c b/ld/lexsup.c index 08ef107..b5e52a8 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -175,6 +175,7 @@ enum option_values OPTION_PLUGIN_OPT, #endif /* ENABLE_PLUGINS */ OPTION_DEFAULT_SCRIPT, + OPTION_PRINT_OUTPUT_FORMAT, }; /* The long options. This structure is used for both the option @@ -491,6 +492,8 @@ static const struct ld_option ld_options[] = { {"oformat", required_argument, NULL, OPTION_OFORMAT}, '\0', N_("TARGET"), N_("Specify target of output file"), EXACTLY_TWO_DASHES }, + { {"print-output-format", no_argument, NULL, OPTION_PRINT_OUTPUT_FORMAT}, + '\0', NULL, N_("Print default output format"), TWO_DASHES }, { {"qmagic", no_argument, NULL, OPTION_IGNORE}, '\0', NULL, N_("Ignored for Linux compatibility"), ONE_DASH }, { {"reduce-memory-overheads", no_argument, NULL, @@ -1059,6 +1062,9 @@ parse_args (unsigned argc, char **argv) case OPTION_OFORMAT: lang_add_output_format (optarg, NULL, NULL, 0); break; + case OPTION_PRINT_OUTPUT_FORMAT: + command_line.print_output_format = TRUE; + break; #ifdef ENABLE_PLUGINS case OPTION_PLUGIN: if (plugin_opt_plugin (optarg)) |