Make --verbose always display linker script

This commit is contained in:
Nick Clifton
2001-08-12 07:59:28 +00:00
parent 6ca173e32c
commit b9a8de1ea3
7 changed files with 63 additions and 18 deletions

View File

@ -1,3 +1,22 @@
2001-08-12 H.J. Lu <hjl@gnu.org>
Andrew Haley <aph@cambridge.redhat.com>
Nick Clifton <nickc@redhat.com>
* 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 <aj@suse.de>
* configure.in: Add -Wstrict-prototypes and -Wmissing-prototypes

View File

@ -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. */

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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)

View File

@ -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 ();
}