This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Generalized verification of .apple_names accelerator table to be applicable to any acceleration table. Added verification for .apple_types, .apple_namespaces and .apple_objc sections.
ClosedPublic

Authored by sgravani on Jul 25 2017, 1:35 PM.

Details

Summary

This patch replaces .handleAppleNames() with .handleAccelTables().
This way, any accelerator tables will be verified (if it exists).

Diff Detail

Repository
rL LLVM

Event Timeline

sgravani created this revision.Jul 25 2017, 1:35 PM
sgravani edited the summary of this revision. (Show Details)Jul 25 2017, 1:38 PM
sgravani added a subscriber: llvm-commits.
aprantl added inline comments.Jul 25 2017, 2:20 PM
include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
52 ↗(On Diff #108148)

I'm not sure this needs to be part of the interface — and if it is this should be a static constant or a constexpr instead of a data member.

include/llvm/DebugInfo/DWARF/DWARFVerifier.h
175 ↗(On Diff #108148)

... existing *Apple-style* accelerator tables ...
DWARF v5 accelerator tables are not yet supported.

lib/DebugInfo/DWARF/DWARFContext.cpp
430 ↗(On Diff #108148)

Could you just update all of the other cases in a separate commit?

lib/DebugInfo/DWARF/DWARFVerifier.cpp
478 ↗(On Diff #108148)

"Section" << Sectionname << " is too small to fit a section header\n"

482 ↗(On Diff #108148)

why initialize to 8?

484 ↗(On Diff #108148)

"Section" << Sectionname << " is smaller than size described in section header\n"

569 ↗(On Diff #108148)

if (!D.getAppleNamesSection().Data.empty())

572 ↗(On Diff #108148)

...

583 ↗(On Diff #108148)

add one :-)

sgravani updated this revision to Diff 108179.Jul 25 2017, 3:58 PM
sgravani marked 8 inline comments as done.

Addressed reviewer's comments.

include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
52 ↗(On Diff #108148)

Removed it. I can use getSizeHdr() instead.

lib/DebugInfo/DWARF/DWARFContext.cpp
430 ↗(On Diff #108148)

Yes, I'll do that.

lib/DebugInfo/DWARF/DWARFVerifier.cpp
482 ↗(On Diff #108148)

I thought I need to verify whether num_of_buckets > 0 (and that field would be at offset 8 from the beginning of the section).
However, after the first check (for the size of the fixed part of the header), if we just check the return value of extract(), it suffices
to perform the second check (for the size of the section).

I modified the code to perform only extract() for the second check.

aprantl accepted this revision.Jul 25 2017, 4:08 PM

Two minor nitpicks, but otherwise LGTM, thanks!

include/llvm/DebugInfo/DWARF/DWARFVerifier.h
175 ↗(On Diff #108148)

Would you mind removing the *s again? I meant to use them as <insert new text here>-marker.

Sorry :-)

lib/DebugInfo/DWARF/DWARFVerifier.cpp
483 ↗(On Diff #108179)

remove commented out line

This revision is now accepted and ready to land.Jul 25 2017, 4:08 PM
aprantl added inline comments.Jul 25 2017, 4:09 PM
lib/DebugInfo/DWARF/DWARFVerifier.cpp
567 ↗(On Diff #108179)

One last thing: You should not need to hard-code the name here. Can you extract it from the Section datastructure instead?

This revision was automatically updated to reflect the committed changes.
sgravani marked 2 inline comments as done.
sgravani added inline comments.Jul 25 2017, 5:53 PM
lib/DebugInfo/DWARF/DWARFVerifier.cpp
567 ↗(On Diff #108179)

I'm not sure how to do this. Even dumpAccelSection() in DWARFContext.cpp is being called with the name of the section as an argument.