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

Broken by a9353dbe51.

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.
This commit is contained in:
Jez Ng 2021-10-26 18:40:20 -04:00
parent 3ac709b6ce
commit 1d2a4cd57d
2 changed files with 23 additions and 7 deletions

View File

@ -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.

View File

@ -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: