This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

ld --verbose output


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.

Andrew.


2001-08-10  Andrew Haley  <aph@cambridge.redhat.com>

        * ldmain.c (main): Print contents of linker script file.
        * ldmisc.c (info_print_file): New.
        * ldmisc.h (info_print_file): Declare.
        * ldfile.c (ldfile_open_command_file): Return file handle of
        opened file.

Index: ldfile.c
===================================================================
RCS file: /cvs/src/src/ld/ldfile.c,v
retrieving revision 1.11
diff -c -2 -p -r1.11 ldfile.c
*** ldfile.c	2001/05/02 16:42:55	1.11
--- ldfile.c	2001/08/10 17:29:39
*************** ldfile_find_command_file (name, extend)
*** 334,338 ****
  }
  
! void
  ldfile_open_command_file (name)
       const char *name;
--- 334,338 ----
  }
  
! FILE *
  ldfile_open_command_file (name)
       const char *name;
*************** ldfile_open_command_file (name)
*** 352,355 ****
--- 352,357 ----
    lineno = 1;
    had_script = true;
+ 
+   return ldlex_input_stack;
  }
  
Index: ldfile.h
===================================================================
RCS file: /cvs/src/src/ld/ldfile.h,v
retrieving revision 1.7
diff -c -2 -p -r1.7 ldfile.h
*** ldfile.h	2001/03/13 06:14:27	1.7
--- ldfile.h	2001/08/10 17:29:39
*************** extern search_dirs_type *search_head;
*** 44,48 ****
  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 void ldfile_open_file PARAMS ((struct lang_input_statement_struct *));
  extern boolean ldfile_try_open_bfd
--- 44,48 ----
  extern void ldfile_add_arch PARAMS ((CONST char *));
  extern void ldfile_add_library_path PARAMS ((const char *, boolean cmdline));
! 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
Index: ldmain.c
===================================================================
RCS file: /cvs/src/src/ld/ldmain.c,v
retrieving revision 1.26
diff -c -2 -p -r1.26 ldmain.c
*** ldmain.c	2001/08/02 23:12:02	1.26
--- ldmain.c	2001/08/10 17:29:39
*************** main (argc, argv)
*** 304,308 ****
  
        if (isfile)
! 	ldfile_open_command_file (s);
        else
  	{
--- 304,316 ----
  
        if (isfile)
! 	{
! 	  FILE *f = ldfile_open_command_file (s);
! 	  if (trace_file_tries)
! 	    {
! 	      info_msg ("==================================================\n");
! 	      info_print_file (f);
! 	      info_msg ("\n==================================================\n");
! 	    }
! 	}
        else
  	{
Index: ldmisc.c
===================================================================
RCS file: /cvs/src/src/ld/ldmisc.c,v
retrieving revision 1.7
diff -c -2 -p -r1.7 ldmisc.c
*** ldmisc.c	2001/05/02 16:42:55	1.7
--- ldmisc.c	2001/08/10 17:29:39
*************** lfinfo (va_alist)
*** 517,520 ****
--- 517,540 ----
  }
  
+ /* Print a file to stdout, taking care not to move its read pointer.  */
+ 
+ void
+ info_print_file (FILE *f)
+ {
+   char buf [4096];
+   int n;
+   long int pos = ftell (f);
+   rewind (f);
+ 
+   if (f == NULL)
+     return;
+ 
+   while ((n = fread (buf, 1, 4096, f)) > 0)
+     fwrite (buf, 1, n, stdout);
+       
+   fseek (f, pos, 0);
+   return;
+ }
+ 
  /* Functions to print the link map.  */
  
Index: ldmisc.h
===================================================================
RCS file: /cvs/src/src/ld/ldmisc.h,v
retrieving revision 1.3
diff -c -2 -p -r1.3 ldmisc.h
*** ldmisc.h	2001/05/02 16:42:55	1.3
--- ldmisc.h	2001/08/10 17:29:39
*************** extern PTR xmalloc PARAMS ((size_t));
*** 43,46 ****
--- 43,47 ----
  extern PTR xrealloc PARAMS ((PTR, size_t));
  extern void xexit PARAMS ((int));
+ extern void info_print_file PARAMS ((FILE *));
  
  #define ASSERT(x) \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]