This is an archive of the discontinued LLVM Phabricator instance.

ObjectFileELF: Test whether reloc_header is non-null instead of asserting.
ClosedPublic

Authored by pcc on Dec 16 2020, 6:10 PM.

Details

Summary

It is possible for the GetSectionHeaderByIndex lookup to fail because
the previous FindSectionContainingFileAddress lookup found a segment
instead of a section. This is possible if the binary does not have
a PLT (which means that lld will in some circumstances set DT_JMPREL
to 0, which is typically an address that is part of the ELF headers
and not in a section) and may also be possible if the section headers
have been stripped. To handle this possibility, replace the assert
with an if.

Diff Detail

Event Timeline

pcc created this revision.Dec 16 2020, 6:10 PM
pcc requested review of this revision.Dec 16 2020, 6:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2020, 6:10 PM
Herald added a subscriber: MaskRay. · View Herald Transcript

The fix seems reasonable but it would use a test case. Is it possible to generate appropriate input with yaml2obj? If so you could run lldb-test symbols on the resulting object file, and verify that the Symbol table is printed out correctly (whatever "correct" means in this case).

pcc updated this revision to Diff 312608.Dec 17 2020, 1:44 PM

Add test

labath accepted this revision.Dec 18 2020, 1:38 AM
This revision is now accepted and ready to land.Dec 18 2020, 1:38 AM
This revision was landed with ongoing or failed builds.Feb 11 2021, 3:05 PM
This revision was automatically updated to reflect the committed changes.