[llvm] [llvm-dwp] Fix infinite loop on DWARFv5 DW_FORM_implicit_const (PR #205567)
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 10:48:23 PDT 2026
================
@@ -39,6 +39,23 @@ static uint64_t debugStrOffsetsHeaderSize(DataExtractor StrOffsetsData,
return 8; // unit length: 4 bytes, version: 2 bytes, padding: 2 bytes.
}
+// Read the next (attribute, form) pair from an abbreviation declaration.
+// DW_FORM_implicit_const is the only form that stores an extra value -- an
+// SLEB128 -- in the abbreviation declaration itself; consume it here so the
+// (attribute, form) walk stays aligned with the rest of the table.
+// return True if can keep going- Name or Form is not 0
+static bool readAbbrevAttribute(const DataExtractor &AbbrevData,
+ uint64_t *Offset, uint64_t &Name,
+ dwarf::Form &Form) {
+ Name = AbbrevData.getULEB128(Offset);
+ Form = static_cast<dwarf::Form>(AbbrevData.getULEB128(Offset));
+ if (Form == dwarf::DW_FORM_implicit_const)
+ AbbrevData.getSLEB128(Offset);
+ if (Name != 0 || Form != 0)
----------------
dwblaikie wrote:
I'd prefer a switch - the loop should be exiting gracefully under the DWARF spec'd condition, of a 0 byte for the abbrev code. And then should have some handling for failures to read/corrupted input.
(& probably best not to mark conversations as "resolved" when they have active questions in them like this - it hides them (it's not "resolved" as in "I've done my part, I'm waiting for someone else to do their part" - github's "resolved" is more "everything's done here, no need to look" (which also means you have to have high confidence marking /someone else's/ concerns as "resolved" - you should probably leave it open for them to decide if you've adequately addressed their concern/resolved the issue))
https://github.com/llvm/llvm-project/pull/205567
More information about the llvm-commits
mailing list