PATCH: PR ld/12851: --gc-sections doesn't work on note sections

Alan Modra amodra@gmail.com
Thu Jun 9 00:25:00 GMT 2011


On Thu, Jun 09, 2011 at 09:22:26AM +0930, Alan Modra wrote:
> On Wed, Jun 08, 2011 at 01:10:14PM -0700, H.J. Lu wrote:
> > SHT_NOTE sections are special.  We check it in elf_gc_sweep.  But
> > we missed it in bfd_elf_gc_sections.
> 
> I think your patch is going in the wrong directions.  If we missed
> anything in bfd_elf_gc_sections, it's that we keep note sections in
> files for which all other sections are discarded.  

Actually, I think that

	  else if ((o->flags & (SEC_DEBUGGING | SEC_LINKER_CREATED)) != 0
		   || (o->flags & (SEC_ALLOC | SEC_LOAD | SEC_RELOC)) == 0
		   || elf_section_data (o)->this_hdr.sh_type == SHT_NOTE)
	    {
	      /* Keep debug, special and SHT_NOTE sections.  */
	      o->gc_mark = 1;
	    }

doesn't belong in elf_gc_sweep at all.  It would be better to put code
marking these sections in a default gc_mark_extra_sections.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list