[lld] 1d2a4cd - [lld-macho] Fix compact-unwind-bad-reloc.s test

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 26 15:59:18 PDT 2021


Author: Jez Ng
Date: 2021-10-26T18:59:12-04:00
New Revision: 1d2a4cd57df590a5d9a6aec9ecdf93a523c8b64b

URL: https://github.com/llvm/llvm-project/commit/1d2a4cd57df590a5d9a6aec9ecdf93a523c8b64b
DIFF: https://github.com/llvm/llvm-project/commit/1d2a4cd57df590a5d9a6aec9ecdf93a523c8b64b.diff

LOG: [lld-macho] Fix compact-unwind-bad-reloc.s test

Broken by a9353dbe517c522ac63818de2cde645acdc46834.

Now that the functions point to the compact unwind entries, instead of
the other way around, we need to perform the "invalid reference" check
in a different place.

This change was originally part of the stacked diff D109946, but should
have been included as part of D109945.

Added: 
    

Modified: 
    lld/MachO/InputFiles.cpp
    lld/test/MachO/invalid/compact-unwind-bad-reloc.s

Removed: 
    


################################################################################
diff  --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 14179afcaeb8..1f4313dd296f 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -902,6 +902,9 @@ void ObjFile::registerCompactUnwind() {
         referentIsec =
             cast<ConcatInputSection>(r.referent.dyn_cast<InputSection *>());
       }
+      if (referentIsec->getSegName() != segment_names::text)
+        error("compact unwind references address in " + toString(referentIsec) +
+              " which is not in segment __TEXT");
       // The functionAddress relocations are typically section relocations.
       // However, unwind info operates on a per-symbol basis, so we search for
       // the function symbol here.

diff  --git a/lld/test/MachO/invalid/compact-unwind-bad-reloc.s b/lld/test/MachO/invalid/compact-unwind-bad-reloc.s
index 9204cafcfc81..3e189dada0ca 100644
--- a/lld/test/MachO/invalid/compact-unwind-bad-reloc.s
+++ b/lld/test/MachO/invalid/compact-unwind-bad-reloc.s
@@ -1,13 +1,12 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %s -o %t.o
-# RUN: not %lld -pie -lSystem -lc++ %t.o -o %t 2>&1 | FileCheck %s -DFILE=%t.o
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/bad-function.s -o %t/bad-function.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/bad-personality.s -o %t/bad-personality.o
+# RUN: not %lld -pie -lSystem -lc++ %t/bad-function.o -o %t 2>&1 | FileCheck %s -DFILE=%t/bad-function.o
+# RUN: not %lld -pie -lSystem -lc++ %t/bad-personality.o -o %t 2>&1 | FileCheck %s -DFILE=%t/bad-personality.o
 # CHECK: error: compact unwind references address in [[FILE]]:(__data) which is not in segment __TEXT
 
-.globl _main, _not_a_function
-.text
-_main:
-  retq
-
+#--- bad-function.s
 .data
 _not_a_function:
   .cfi_startproc
@@ -15,3 +14,17 @@ _not_a_function:
   .cfi_def_cfa_offset 16
   retq
   .cfi_endproc
+
+#--- bad-personality.s
+.globl _main, _not_a_function
+.text
+_main:
+  .cfi_startproc
+  .cfi_personality 155, _my_personality
+  .cfi_def_cfa_offset 16
+  retq
+  .cfi_endproc
+
+.data
+.globl _my_personality
+_my_personality:


        


More information about the llvm-commits mailing list