[PATCH] D101353: [DebugInfo] do not add pc value if lsda value in fde is 0

Yifeng Dong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 27 04:18:56 PDT 2021


dongAxis1944 created this revision.
dongAxis1944 added a reviewer: rafaelauler.
Herald added a subscriber: hiraditya.
dongAxis1944 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Summary
The code might occur error in the following code:
This CIE shows the FDE related to the CIE has LSDA and the encoding of LSDA is DW_EH_PE_pcrel.
But the LDSA value is zero in FDE, in this case llvm should set lsda value to 0 even if LSDA is relative to pc.

Test Plan:

  check-llvm


https://reviews.llvm.org/D101353

Files:
  llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp


Index: llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugFrame.cpp
@@ -1133,9 +1133,16 @@
 
           // Decode the LSDA if the CIE augmentation string said we should.
           if (Cie->getLSDAPointerEncoding() != DW_EH_PE_omit) {
+            auto CurPC = Offset + EHFrameAddress;
             LSDAAddress = Data.getEncodedPointer(
-                &Offset, Cie->getLSDAPointerEncoding(),
-                EHFrameAddress ? Offset + EHFrameAddress : 0);
+                &Offset, Cie->getLSDAPointerEncoding(), 0);
+
+            auto IsPCRelativeFn = [&]() {
+              return (0x70 & Cie->getLSDAPointerEncoding()) ==
+                     dwarf::DW_EH_PE_pcrel;
+            };
+            if (LSDAAddress && *LSDAAddress != 0 && IsPCRelativeFn())
+              LSDAAddress = *LSDAAddress + CurPC;
           }
 
           if (Offset != EndAugmentationOffset)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101353.340789.patch
Type: text/x-patch
Size: 1024 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210427/a4996297/attachment.bin>


More information about the llvm-commits mailing list