[PATCH] D105404: [lld/mac] Fix function offset on 1st-level unwind table sentinel

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 3 19:36:20 PDT 2021


thakis updated this revision to Diff 356363.
thakis added a comment.

tweak


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105404/new/

https://reviews.llvm.org/D105404

Files:
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/compact-unwind.s


Index: lld/test/MachO/compact-unwind.s
===================================================================
--- lld/test/MachO/compact-unwind.s
+++ lld/test/MachO/compact-unwind.s
@@ -43,10 +43,14 @@
 # CHECK:        Personality functions: (count = 2)
 # CHECK-DAG:     personality[{{[0-9]+}}]: 0x{{0*}}[[#MY_PERSONALITY-BASE]]
 # CHECK-DAG:     personality[{{[0-9]+}}]: 0x{{0*}}[[#GXX_PERSONALITY-BASE]]
+# CHECK:      Top level indices: (count = 2)
+# CHECK-DAG:    [0]: function offset={{.*}}, 2nd level page offset=0x[[#%x,PAGEOFF:]],
+# CHECK-DAG:    [1]: function offset={{.*}}, 2nd level page offset=0x00000000,
 # CHECK:        LSDA descriptors:
 # CHECK-DAG:     function offset=0x[[#%.8x,FOO-BASE]],  LSDA offset=0x[[#%.8x,EXCEPTION0-BASE]]
 # CHECK-DAG:     function offset=0x[[#%.8x,MAIN-BASE]], LSDA offset=0x[[#%.8x,EXCEPTION1-BASE]]
 # CHECK:        Second level indices:
+# CHECK-NEXT:   Second level index[0]: offset in section=0x[[#%.8x,PAGEOFF]]
 # CHECK-DAG:     function offset=0x[[#%.8x,MAIN-BASE]], encoding
 # CHECK-DAG:     function offset=0x[[#%.8x,FOO-BASE]], encoding
 # CHECK-DAG:     function offset=0x[[#%.8x,BAZ-BASE]], encoding
Index: lld/MachO/UnwindInfoSection.cpp
===================================================================
--- lld/MachO/UnwindInfoSection.cpp
+++ lld/MachO/UnwindInfoSection.cpp
@@ -568,8 +568,10 @@
     l2PagesOffset += SECOND_LEVEL_PAGE_BYTES;
   }
   // Level-1 sentinel
-  const CompactUnwindEntry<Ptr> &cuEnd = cuVector.back();
-  iep->functionOffset = cuEnd.functionAddress + cuEnd.functionLength;
+  const CompactUnwindEntry<Ptr> &cuEnd = *cuPtrVector.back();
+  assert(cuEnd.functionAddress != static_cast<Ptr>(UINT64_MAX));
+  iep->functionOffset =
+      cuEnd.functionAddress - in.header->addr + cuEnd.functionLength;
   iep->secondLevelPagesSectionOffset = 0;
   iep->lsdaIndexArraySectionOffset =
       lsdaOffset +


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105404.356363.patch
Type: text/x-patch
Size: 1891 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210704/54027029/attachment.bin>


More information about the llvm-commits mailing list