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]

Re: a patch to set ELF header flags for empty linker output files


On Tue, Jan 16, 2001 at 10:01:33AM -0800, Nick Clifton wrote:
> Hi H.J.
> 
> : I think "ld -r" is the only way to generate an empty file. However,
> : I'd like to see to ignore empty input files for all platforms, not
> : just ia64. Something like
> : 
> : bool bfd_has_contents (bfd *abfd)
> : 
> : should work. We can default it to 1.
> 
> Detecting empty files might be a problem.  Object files which only
> contain sections which are going to be discarded are 'empty' as are
> object files whose sections are thrown away due to garbage collection.
> 

By "empty", I mean "has no contents." That is

  if (abfd->sections == NULL)

and/or

  if (bfd_count_sections (abfd) == 0)

A patch like the one below.


-- 
H.J. Lu (hjl@valinux.com)
---
Index: ldlang.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ldlang.c,v
retrieving revision 1.17
diff -u -p -r1.17 ldlang.c
--- ldlang.c	2000/12/22 00:47:49	1.17
+++ ldlang.c	2001/01/16 18:59:52
@@ -3472,7 +3472,8 @@ lang_check ()
              information which is needed in the output file.  */
 	  if (! command_line.warn_mismatch)
 	    pfn = bfd_set_error_handler (ignore_bfd_errors);
-	  if (! bfd_merge_private_bfd_data (input_bfd, output_bfd))
+	  if (bfd_count_sections (input_bfd)
+	      && ! bfd_merge_private_bfd_data (input_bfd, output_bfd))
 	    {
 	      if (command_line.warn_mismatch)
 		einfo (_("%E%X: failed to merge target specific data of file %B\n"),

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