Verifying any DWARF file that is optimized and contains at least one tag
with a DW_AT_location with a location list offset as a
DW_AT_form_dataXXX results in dwarfdump spuriously claiming that the
location list is invalid.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/DebugInfo/DWARF/DWARFVerifier.cpp | ||
---|---|---|
431 ↗ | (On Diff #123425) | Looks like this path is missing a couple of opportunities to detect invalid references. |
The FORM that's appropriate for DW_AT_location to use as a reference varies with the DWARF version. In v2 and v3, it's FORM_data4 or FORM_data8, in v4 it's FORM_sec_offset. I haven't looked at the verifier much but it seems like using the correct FORM is something that ought to be verifiable.
In v5 things get way more complicated, but that's not anything you have to deal with now.
Do you happen to have a minimal reproducer that we could check in as an assembler testcase?
lib/DebugInfo/DWARF/DWARFVerifier.cpp | ||
---|---|---|
413 ↗ | (On Diff #123425) | Probably move this down into the "if (Expr)" condition below if (Optional<ArrayRef<uint8_t>> Expr = AttrValue.Value.getAsBlock()) { VerifyLocation(...); |
426–435 ↗ | (On Diff #123425) | Alternatively/slightly different to all this, could use early breaks: auto X = ...; if (!X) break; etc... |
429–431 ↗ | (On Diff #123425) | Could roll this into else-if: } else if (auto LocOffset = ... ) { |
432–435 ↗ | (On Diff #123425) | Could roll these variables into the conditions: if (auto DebugLoc = DCtx.getDebugLoc()) if (auto LocList = ... |
Fixed Adrian's comments.
I also discovered that I was using this false positive to test the dsymutil -verify feature, so I had to fixing that test as well.
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp | ||
---|---|---|
413 ↗ | (On Diff #133616) | No. The call sites have respectively ArrayRef<uint8t_t> and SmallVector<char, 4> as argument. |
I'd have though invalid.s should be a text file from the name, but it shows up as binary here?
Not sure why Phabricator didn't pick it up. Here's its content: https://reviews.llvm.org/P8063
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp | ||
---|---|---|
427 ↗ | (On Diff #134721) | -> llvm::toStringRef(ArrayRef<uint8_t> Input) |