[PATCH] D117217: Dwarf: Fix high pc patching

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 13 05:54:19 PST 2022


yota9 created this revision.
yota9 added reviewers: maksfb, rafaelauler, Amir, ayermolo.
yota9 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The DW_FORM_addr form of highPC address is written in absolute addres,
the data form is written in offset-from-low pc format.

Due to the large test binary the test is prepared separately in
https://github.com/rafaelauler/bolt-tests/pull/8

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117217

Files:
  bolt/lib/Rewrite/DWARFRewriter.cpp


Index: bolt/lib/Rewrite/DWARFRewriter.cpp
===================================================================
--- bolt/lib/Rewrite/DWARFRewriter.cpp
+++ bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -1508,11 +1508,15 @@
     TempDebugPatcher->addLE64Patch(LowPCOffset, Range.LowPC);
   }
 
+  uint64_t HighPC = Range.HighPC;
+  // The DW_FORM_data* is delta between high and low pc
+  if (HighPCVal->V.getForm() != dwarf::Form::DW_FORM_addr)
+    HighPC -= Range.LowPC;
+
   if (isHighPcFormEightBytes(HighPCVal->V.getForm()))
-    TempDebugPatcher->addLE64Patch(HighPCOffset, Range.HighPC - Range.LowPC);
+    TempDebugPatcher->addLE64Patch(HighPCOffset, HighPC);
   else
-    TempDebugPatcher->addLE32Patch(HighPCOffset, Range.HighPC - Range.LowPC,
-                                   HighPCVal->Size);
+    TempDebugPatcher->addLE32Patch(HighPCOffset, HighPC);
 }
 
 void DWARFRewriter::convertToRangesPatchAbbrev(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117217.399642.patch
Type: text/x-patch
Size: 910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220113/5b3dce5b/attachment.bin>


More information about the llvm-commits mailing list