llvm-project
eb836fa7 - [lldb] Don't create functions for DWARF dead-code tombstones (#205691)

Commit
50 days ago
[lldb] Don't create functions for DWARF dead-code tombstones (#205691) A function the linker eliminated (dead-stripped, or inlined into all its callers) keeps a DWARF subprogram DIE whose DW_AT_low_pc is a "(dead code)" tombstone: the all-ones value for the unit's address size. LLDB has no explicit tombstone check; it only rejects dead code where Address::IsValid() happens to catch it, i.e. when the tombstone equals the 8-byte LLDB_INVALID_ADDRESS. On wasm32 the tombstone is the 4-byte 0xffffffff, which IsValid() lets through, so LLDB builds a section-less, module-less lldb_private::Function and later crashes in Block::GetRangeContainingAddress (reached from Function::GetPrologueByteSize) dereferencing the empty module. Require the low PC to resolve to a section in SymbolFileDWARF::ParseFunction, using Address::IsSectionOffset() instead of IsValid(). This is the single point where functions are created, so it covers both the DW_AT_low/high_pc and DW_AT_ranges encodings, and it rejects any low PC that doesn't land in real code regardless of address width. It also avoids special-casing the all- ones tombstone value, which is an LLVM convention; other linkers tombstone with zero or a near-zero address, and those are already handled by the adjacent range.valid()/m_first_code_address check.
Author
Parents
Loading