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 11:39:54AM -0800, Nick Clifton wrote:
> Hi H.J.
> 
> : > 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)
> : 
> 
> Right, but you could still have the case where a (non-archive) input
> bfd is not empty, but will not contribute anything to the output
> because all of its sections will be discarded.  In such a case you do
> not really want this bfd to contribute to the ELF header flags
> either.

That may be true. But it is much harder to do it right :-(.

> 
> 
> : A patch like the one below.
> 
> This looks OK, although I would suggest that you can move the no
> sections test to the surrounding else statement, and so avoid the
> whole save and restore of the error handler.
> 

Ok. Here is a new one.


-- 
H.J. Lu (hjl@valinux.com)
---
2001-01-16  H.J. Lu  <hjl@gnu.org>

	* ldlang.c (lang_check): Merge the private data only if the
	input file has contents.

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 20:22:24
@@ -3461,7 +3461,7 @@ lang_check ()
 		   bfd_printable_name (input_bfd), input_bfd,
 		   bfd_printable_name (output_bfd));
 	}
-      else
+      else if (bfd_count_sections (input_bfd))
 	{
 	  bfd_error_handler_type pfn = NULL;
 

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