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]
Other format: [Raw text]

Re: your patch to remove unused sections


On Fri, Apr 08, 2005 at 09:29:55AM +0930, Alan Modra wrote:
> On Thu, Apr 07, 2005 at 04:47:05PM -0700, H. J. Lu wrote:
> > On Fri, Apr 08, 2005 at 08:03:47AM +0930, Alan Modra wrote:
> > > ..seems to break i960-elf.
> > > 
> > 
> > How many failures were there before my unused section removal patch?
> > i960-elf doesn't use ELF linker. This patch gets
> > 
> > ./ld/ld.log:FAIL: ld-elf/group1
> > ./ld/ld.log:FAIL: ld-elf/merge2
> > ./ld/ld.log:FAIL: ld-elf/warn1
> > 
> > I am not sure if they were ever working.
> 
> That's right, these tests have failed on i960 for quite a while.
> 
> 
> Not OK.  This is just a hack.  You need to figure out why i960-elf is
> trying to emit symbols to removed output sections.
> 

That is a long standing bug in generic linker:

     /* If this symbol is in a section which is not being included
         in the output file, then we don't want to output the symbol.

         Gross.  .bss and similar sections won't have the linker_mark
         field set.  */

swap_out_syms in elf.c failed on the removed .bss section. The
following patch fixes the problem.


H.J.
----
2005-04-08  H.J. Lu  <hongjiu.lu@intel.com>

	* linker.c (_bfd_generic_link_output_symbols): Scan the section
	list of output_bfd to check if an input section is included in
	the output file.

--- bfd/linker.c.generic	2005-02-11 09:28:14.000000000 -0800
+++ bfd/linker.c	2005-04-08 09:36:58.849353040 -0700
@@ -2363,13 +2363,25 @@ _bfd_generic_link_output_symbols (bfd *o
 	abort ();
 
       /* If this symbol is in a section which is not being included
-	 in the output file, then we don't want to output the symbol.
-
-	 Gross.  .bss and similar sections won't have the linker_mark
-	 field set.  */
+	 in the output file, then we don't want to output the
+	 symbol.  */
       if ((sym->section->flags & SEC_HAS_CONTENTS) != 0
 	  && ! sym->section->linker_mark)
 	output = FALSE;
+      else
+	{
+	  asection *sec;
+
+	  /* .bss and similar sections won't have the linker_mark
+	     field set.  We have to check if its output section is
+	     included in output_bfd.  */
+	  for (sec = output_bfd->sections; sec != NULL; sec = sec->next)
+	    if (sec == sym->section->output_section)
+	      break;
+
+	  if (!sec)
+	    output = FALSE;
+	}
 
       if (output)
 	{


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