RFC: Remove empty output sections
H. J. Lu
hjl@lucon.org
Fri Mar 18 17:22:00 GMT 2005
On Fri, Mar 18, 2005 at 11:32:20PM +1030, Alan Modra wrote:
> On Fri, Mar 18, 2005 at 05:43:00PM +1030, Alan Modra wrote:
> > your bfd_alloc's happened to return zeroed memory. I'm seeing this:
> >
> > 10: 00011a38 0 SECTION LOCAL DEFAULT 19
> > 11: 00011a3c 0 SECTION LOCAL DEFAULT 20
> > 12: 00000034 143 FUNC GLOBAL DEFAULT UND
> >
> > Please fix.
>
> I decided to fix this myself, because it was breaking my builds.
>
> * elf-bfd.h (_bfd_elf_link_renumber_dynsyms): Delete.
> * elflink.c (_bfd_elf_link_renumber_dynsyms): Make static, add
> section_sym_count param, and return number of section symbols.
> (bfd_elf_size_dynamic_sections): Clear section symbol area of
> .dynsym contents. Don't bother calling swap_symbol_out on the
> first all-zero dynsym.
> (elf_mark_used_section): Formatting. Avoid twiddling flags in
> special sections like bfd_abs_section.
> (bfd_elf_gc_sections): Spelling fix.
>
> static bfd_boolean
> elf_mark_used_section (struct elf_link_hash_entry *h,
> - void *global ATTRIBUTE_UNUSED)
> + void *data ATTRIBUTE_UNUSED)
> {
> if (h->root.type == bfd_link_hash_warning)
> h = (struct elf_link_hash_entry *) h->root.u.i.link;
>
> - if ((h->root.type == bfd_link_hash_defined
> - || h->root.type == bfd_link_hash_defweak))
> + if (h->root.type == bfd_link_hash_defined
> + || h->root.type == bfd_link_hash_defweak)
> {
> - asection *s = h->root.u.def.section->output_section;
> - if (s)
> - s->flags |= SEC_KEEP;
> + asection *s = h->root.u.def.section;
> + if (s != NULL && s->output_section != NULL && s->output_section != s)
> + s->output_section->flags |= SEC_KEEP;
> }
>
I don't think s->output_section != s is right. It may be the cause
of "make check" failures for cris-elf. Can we use
!bfd_is_const_section (s->output_section)
instead?
H.J.
More information about the Binutils
mailing list