unreferenced local symbols generated in .dynsym

Ian Lance Taylor ian@airs.com
Wed Apr 23 18:46:00 GMT 2003


Roland McGrath <roland@redhat.com> writes:

> There should never be local symbols in .dynsym unless they are referenced
> by dynamic relocs.  Other superfluous symbols like the FILE symbol got
> removed, but the section symbols remain no matter what I do.  This is buggy.

A bit of a pain to fix in the general case, unfortunately.  The
section symbols are added by _bfd_elf_link_renumber_dynsyms(), which
is called by size_dynamic_sections().  At that point we want to know
the final size of all the dynamic sections.  However, at that point we
don't currently know which output sections will need relocs.  So we
just create a dynamic symbol for all the output sections.  I think
this is what the Solaris linker does as well.

To fix this we need new data structures to record which output
sections will need dynamic relocs, so that the dynamic symbol is
available when we get around to doing reloc processing.  Of course, in
ordinary cases we don't need a reloc against a dynamic section.  They
tend to be needed in cases where non-PIC code is linked into a shared
library, so we need to copy over the relocs but we don't necessarily
have a global symbol to hang them on.

Ian



More information about the Binutils mailing list