From: Nick Clifton Date: Sun, 12 Aug 2001 07:59:28 +0000 (+0000) Subject: Make --verbose always display linker script X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b9a8de1ea39d0e4fb34407388382f192f2304e80;p=binutils-gdb.git Make --verbose always display linker script --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 94f54c5c560..f9974c37a4c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,22 @@ +2001-08-12 H.J. Lu + Andrew Haley + Nick Clifton + + * ldgram.y (had_script): Change name to saved_script_handle. + Change type to file handle. + * ld.h (had_script): Rename and retype. + * ldfile.c (ldfile_open_command_file): Save the file handle + used in saved_script_handle. + * lexsup.c (parse_args): Do not allow -c option to alter + saved_script_handle. + * ldmain.c (main): Print out the linker script used if + --verbose is given. Check saved_script_handle to obtain the + external linker script used, or if NULL, dump the builtin + script. + * ld.texinfo: Document that --verbose now dumps the linker + script used, regardless of whether it was an internal or an + external script. + 2001-08-10 Andreas Jaeger * configure.in: Add -Wstrict-prototypes and -Wmissing-prototypes diff --git a/ld/ld.h b/ld/ld.h index 71ac5c930e3..fef40a5338e 100644 --- a/ld/ld.h +++ b/ld/ld.h @@ -221,7 +221,7 @@ typedef enum { lang_final_phase_enum } lang_phase_type; -extern boolean had_script; +extern FILE * saved_script_handle; extern boolean force_make_executable; /* Non-zero if we are processing a --defsym from the command line. */ diff --git a/ld/ld.texinfo b/ld/ld.texinfo index a8778d994d0..82e7fc4fc89 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -1339,7 +1339,7 @@ for compatibility with other linkers, you may omit the leading @itemx --verbose Display the version number for @code{ld} and list the linker emulations supported. Display which input files can and cannot be opened. Display -the linker script if using a default builtin script. +the linker script being used by the linker. @kindex --version-script=@var{version-scriptfile} @cindex version script, symbol versions diff --git a/ld/ldfile.c b/ld/ldfile.c index 0e4d0ec3a2e..001f71a2f93 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -350,7 +350,8 @@ ldfile_open_command_file (name) ldfile_input_filename = name; lineno = 1; - had_script = true; + + saved_script_handle = ldlex_input_stack; } #ifdef GNU960 diff --git a/ld/ldgram.y b/ld/ldgram.y index 5e9fd62180b..f9c6058feaa 100644 --- a/ld/ldgram.y +++ b/ld/ldgram.y @@ -50,7 +50,7 @@ static enum section_type sectype; lang_memory_region_type *region; boolean ldgram_want_filename = true; -boolean had_script = false; +FILE * saved_script_handle = false; boolean force_make_executable = false; boolean ldgram_in_script = false; diff --git a/ld/ldmain.c b/ld/ldmain.c index 7a450e8e661..849e0ae2ef7 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -296,23 +296,17 @@ main (argc, argv) the -L's in argv have been processed. */ set_scripts_dir (); - if (had_script == false) + /* If we have not already opened and parsed a linker script + read the emulation's appropriate default script. */ + if (saved_script_handle == false) { - /* Read the emulation's appropriate default script. */ int isfile; - char *s = ldemul_get_script (&isfile); + char *s = ldemul_get_script (& isfile); if (isfile) ldfile_open_command_file (s); else - { - if (trace_file_tries) - { - info_msg (_("using internal linker script:\n")); - info_msg ("==================================================\n"); - info_msg (s); - info_msg ("\n==================================================\n"); - } + { lex_string = s; lex_redirect (s); } @@ -321,6 +315,37 @@ main (argc, argv) lex_string = NULL; } + if (trace_file_tries) + { + info_msg (_("using %s linker script:\n"), + saved_script_handle ? "external" : "internal"); + info_msg ("==================================================\n"); + + if (saved_script_handle) + { + const int BSIZE = 8192; + size_t n; + char *buf = xmalloc (BSIZE); + + rewind (saved_script_handle); + while ((n = fread (buf, 1, BSIZE - 1, saved_script_handle)) > 0) + { + buf [n] = 0; + info_msg (buf); + } + rewind (saved_script_handle); + free (buf); + } + else + { + int isfile; + + info_msg (ldemul_get_script (& isfile)); + } + + info_msg ("\n==================================================\n"); + } + lang_final (); if (lang_has_input_file == false) diff --git a/ld/lexsup.c b/ld/lexsup.c index 91a1f1dc39c..7e23a7d07b6 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -1017,11 +1017,11 @@ the GNU General Public License. This program has absolutely no warranty.\n")); version information. Read it, but don't assume that we've seen a linker script. */ { - boolean hold_had_script; + FILE * hold_script_handle; - hold_had_script = had_script; + hold_script_handle = saved_script_handle; ldfile_open_command_file (optarg); - had_script = hold_had_script; + saved_script_handle = hold_script_handle; parser_input = input_version_script; yyparse (); }