This is an archive of the discontinued LLVM Phabricator instance.

Correctly resolve symbol names containing linker annotations
ClosedPublic

Authored by labath on Mar 3 2015, 9:33 AM.

Details

Summary

Symbols in ELF files can be versioned, but LLDB currently does not understand these. This problem
becomes apparent once one loads glibc with debug info. Here (in the .symtab section) the versions
are embedded in the name (name@VERSION), which causes issues when evaluating expressions
referencing memcpy for example (current glibc contains memcpy@@GLIBC_2.14 and
memcpy@GLIBC_2.2.5).

This problem was not evident without debug symbols as the .dynsym section
stores the bare names and the actual versions are present in a separate section (.gnu.version_d),
which LLDB ignores. This resulted in two definitions of memcpy in the symbol table.

This patch adds support for storing annotated names to the Symbol class. If
Symbol.m_contains_linker_annotations is true then this symbol is annotated. Unannotated name can
be obtained by calling StripLinkerAnnotations on the corresponding ObjectFile. ObjectFileELF
implements this to strip @VERSION suffixes when requested. Symtab uses this function to add the
bare name as well as the annotated name to the name lookup table.

To preserve the size of the Symbol class, I had to steal one bit from the m_type field.

Diff Detail

Repository
rL LLVM

Event Timeline

labath updated this revision to Diff 21111.Mar 3 2015, 9:33 AM
labath retitled this revision from to Correctly resolve symbol names containing linker annotations.
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added reviewers: clayborg, jingham.
labath added a subscriber: Unknown Object (MLST).
clayborg accepted this revision.Mar 3 2015, 9:50 AM
clayborg edited edge metadata.

Looks good. Stealing a bit from m_type is fine as long as all eSymbolType* enums can still fit.

This revision is now accepted and ready to land.Mar 3 2015, 9:50 AM
This revision was automatically updated to reflect the committed changes.