Page MenuHomePhabricator

Find .plt section in object files generated by recent ld

Authored by uweigand on Apr 11 2016, 11:23 AM.



Code in ObjectFileELF::ParseTrampolineSymbols assumes that the sh_info
field of the .rel(a).plt section identifies the .plt section.

However, with recent GNU ld this is no longer true. As a result of this:
in object files generated with current linkers the sh_info field of
.rel(a).plt now points to the .got.plt section (or .got on some targets).

This causes LLDB to fail to identify any PLT stubs, causing a number of
test case failures.

This patch changes LLDB to simply always look for the .plt section by
name. This should be safe across all linkers and targets.

Diff Detail

Event Timeline

uweigand updated this revision to Diff 53288.Apr 11 2016, 11:23 AM
uweigand retitled this revision from to Find .plt section in object files generated by recent ld.
uweigand updated this object.
uweigand added reviewers: tberghammer, clayborg, labath.
uweigand added a subscriber: lldb-commits.
clayborg accepted this revision.Apr 11 2016, 1:27 PM
clayborg edited edge metadata.

Other ELF experts should OK this one as well, but looks good to me though.

This revision is now accepted and ready to land.Apr 11 2016, 1:27 PM
tberghammer accepted this revision.Apr 12 2016, 8:41 AM
tberghammer edited edge metadata.

Looks good as I am not aware of any system where the plt sections has different section name

We can create a new SectionType enumeration in lldb-enumerations.h. Then in ObjectFileELF::CreateSections() we would classify the ".plt" section as eSectionTypeProcedureLinkageTable:

static ConstString g_sect_name_plt (".plt");
if (name == g_sect_name_plt)
    sect_type = eSectionTypeProcedureLinkageTable;

Then you can find sections by type no matter what the file format is. This isn't needed for this fix, but if sections contain common information in different file formats, this is handy to avoid having to know to look for sections by name. For instance, DWARF debug info is contained in ".debug_info" and ".debug_abbrev" in ELF, but in MachO the sections are "debug_info" and "debug_abbrev". So we made section types for them in the SectionType enumeration and then the DWARF parser just asks the lldb_private::ObjectFile for the sections by type (eSectionTypeDWARFDebugInfo and eSectionTypeDWARFDebugAbbrev).

This revision was automatically updated to reflect the committed changes.