This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld --verbose output
On Fri, Aug 10, 2001 at 04:20:20PM -0700, H . J . Lu wrote:
>
> Please try this complete patch. It is based on the one in my Linux
> bintuils, which has been in since April. It passed "make check" on
> Linux/x86.
>
Ooops. An update.
H.J.
----
2001-04-25 H.J. Lu <hjl@gnu.org>
* ldfile.h (ldfile_open_command_file): Return FILE *;
* ldfile.c (ldfile_open_command_file): Return NULL if failed
to open the file.
Return ldlex_input_stack if ok.
* ldmain.c (main): Print out the external linker script for
--verbose. Try internal linker script if the external linker
script doesn't exist.
--- ld/ldfile.c.verbose Wed May 2 09:42:55 2001
+++ ld/ldfile.c Fri Aug 10 16:14:04 2001
@@ -333,7 +333,7 @@ ldfile_find_command_file (name, extend)
return result;
}
-void
+FILE *
ldfile_open_command_file (name)
const char *name;
{
@@ -341,16 +341,14 @@ ldfile_open_command_file (name)
ldlex_input_stack = ldfile_find_command_file (name, "");
if (ldlex_input_stack == (FILE *) NULL)
- {
- bfd_set_error (bfd_error_system_call);
- einfo (_("%P%F: cannot open linker script file %s: %E\n"), name);
- }
+ return NULL;
lex_push_file (ldlex_input_stack, name);
ldfile_input_filename = name;
lineno = 1;
had_script = true;
+ return ldlex_input_stack;
}
#ifdef GNU960
--- ld/ldfile.h.verbose Mon Mar 12 22:14:27 2001
+++ ld/ldfile.h Fri Aug 10 16:12:05 2001
@@ -43,7 +43,7 @@ extern search_dirs_type *search_head;
extern void ldfile_add_arch PARAMS ((CONST char *));
extern void ldfile_add_library_path PARAMS ((const char *, boolean cmdline));
-extern void ldfile_open_command_file PARAMS ((const char *name));
+extern FILE *ldfile_open_command_file PARAMS ((const char *name));
extern void ldfile_open_file PARAMS ((struct lang_input_statement_struct *));
extern boolean ldfile_try_open_bfd
PARAMS ((const char *, struct lang_input_statement_struct *));
--- ld/ldmain.c.verbose Thu Aug 2 16:12:02 2001
+++ ld/ldmain.c Fri Aug 10 16:24:28 2001
@@ -301,10 +301,38 @@ main (argc, argv)
/* Read the emulation's appropriate default script. */
int isfile;
char *s = ldemul_get_script (&isfile);
+ FILE *script;
if (isfile)
- ldfile_open_command_file (s);
- else
+ {
+ script = ldfile_open_command_file (s);
+ if (script)
+ {
+ if (trace_file_tries)
+ {
+ const int bsize = 8192;
+ char *buf = xmalloc (bsize);
+
+ info_msg (_("using external linker script:\n"));
+ info_msg ("==================================================\n");
+ rewind (script);
+ while (fread (buf, 1, bsize, script) > 0)
+ info_msg (buf);
+ free (buf);
+ rewind (script);
+ info_msg ("\n==================================================\n");
+ }
+ }
+ else
+ {
+ /* It should never happen. */
+ bfd_set_error (bfd_error_system_call);
+ einfo (_("%P%F: cannot open linker script file %s: %E\n"),
+ s);
+ }
+ }
+
+ if (!isfile)
{
if (trace_file_tries)
{