[llvm] [llvm-debuginfo-analyzer] Add support for WebAssembly binary format. (PR #82588)

Carlos Alberto Enciso via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 14 07:30:20 PDT 2024


================
@@ -429,10 +431,14 @@ void LVELFReader::processOneAttribute(const DWARFDie &Die, LVOffset *OffsetPtr,
         CurrentHighPC = *Address;
       if (std::optional<uint64_t> Offset = FormValue.getAsUnsignedConstant())
         // High PC is an offset from LowPC.
-        CurrentHighPC = CurrentLowPC + *Offset;
+        // Don't add the WebAssembly offset if we have seen a DW_AT_low_pc.
+        CurrentHighPC =
+            (FoundLowPC ? CurrentLowPC - WasmOffset : CurrentLowPC) + *Offset;
----------------
CarlosAlbertoEnciso wrote:

The `CurrentLowPC (DW_AT_low_pc)` always is encoded as an address.
The `CurrentHighPC (DW_AT_high_pc)` can be encoded as an address or as a constant.

When it is a constant, its value is an offset from the `CurrentLowPC`.
That is the only case where we use the formula:
`CurrentHighPC = (FoundLowPC ? CurrentLowPC - WasmOffset : CurrentLowPC) + *Offset
`
and we need to check if the `CurrentLowPC` has been already updated to include the `WasmOffset`.

If the `CurrentHighPC` is encoded as an address, we just add the `WasmOffset`.

https://github.com/llvm/llvm-project/pull/82588


More information about the llvm-commits mailing list