This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld --verbose output
- To: Andrew Haley <aph at cambridge dot redhat dot com>
- Subject: Re: ld --verbose output
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Fri, 10 Aug 2001 10:47:56 -0700
- Cc: binutils at sources dot redhat dot com
- References: <15220.6875.556107.324991@cuddles.cambridge.redhat.com>
On Fri, Aug 10, 2001 at 06:33:15PM +0100, Andrew Haley wrote:
> ld is rather inconsistent when one uses --verbose. If its linker
> script happens to be builtin, ld --verbose outputs it. If its script
> is not builtin, ld instead prints out the name of the file in which
> the script may be found.
>
> While this may be all well and good to users, some build scripts
> process the output of --verbose to get a linker script. glibc does
> this, and if the script happens not to be builtin the build fails.
>
> I think that ld --verbose should behave consistently and always output
> the linker script whether it is builtin or not. That's what this
> patch does.
>
FYI, that is I use in my Linux bintuils. I'd like to have a common
solution on this.
Thanks.
H.J.
-----
2001-04-25 H.J. Lu <hjl@gnu.org>
* ldmain.c (main): Print out the external linker script for
--verbose. Try internal linker script if the external linker
script doesn't exist.
Index: ldmain.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ldmain.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -p -r1.24 -r1.25
--- ldmain.c 2001/04/24 16:03:47 1.24
+++ ldmain.c 2001/04/25 22:54:15 1.25
@@ -292,10 +292,48 @@ 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
+ {
+ /* We thought there was an external linker script. But
+ we couldn't find it. Let's try gain for the internal
+ one without command_line.multilib_dir. */
+ char *saved = command_line.multilib_dir;
+ command_line.multilib_dir = NULL;
+ s = ldemul_get_script (&isfile);
+ command_line.multilib_dir = saved;
+ if (isfile)
+ {
+ /* 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)
{