2021-02-28 01:30:17 +08:00
|
|
|
# REQUIRES: x86, aarch64
|
2021-02-24 10:42:02 +08:00
|
|
|
# RUN: rm -rf %t; split-file %s %t
|
2021-02-28 01:30:17 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/my-personality.s -o %t/x86_64-my-personality.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %t/main.s -o %t/x86_64-main.o
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
# RUN: %lld -arch x86_64 -pie -lSystem -lc++ %t/x86_64-my-personality.o %t/x86_64-main.o -o %t/x86_64-personality-first
|
2021-04-16 09:14:33 +08:00
|
|
|
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000
|
2021-07-04 09:57:43 +08:00
|
|
|
# RUN: %lld -dead_strip -arch x86_64 -pie -lSystem -lc++ %t/x86_64-main.o %t/x86_64-my-personality.o -o %t/x86_64-personality-second
|
2021-04-16 09:14:33 +08:00
|
|
|
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/x86_64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000
|
2021-02-28 01:30:17 +08:00
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/my-personality.s -o %t/arm64-my-personality.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin19.0.0 %t/main.s -o %t/arm64-main.o
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
# RUN: %lld -arch arm64 -pie -lSystem -lc++ %t/arm64-my-personality.o %t/arm64-main.o -o %t/arm64-personality-first
|
2021-04-16 09:14:33 +08:00
|
|
|
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000
|
2021-07-04 09:57:43 +08:00
|
|
|
# RUN: %lld -dead_strip -arch arm64 -pie -lSystem -lc++ %t/arm64-main.o %t/arm64-my-personality.o -o %t/arm64-personality-second
|
2021-04-16 09:14:33 +08:00
|
|
|
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x100000000
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/my-personality.s -o %t/arm64-32-my-personality.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/main.s -o %t/arm64-32-main.o
|
|
|
|
# RUN: %lld-watchos -pie -lSystem -lc++ %t/arm64-32-my-personality.o %t/arm64-32-main.o -o %t/arm64-32-personality-first
|
|
|
|
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-32-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x4000
|
2021-07-04 09:57:43 +08:00
|
|
|
# RUN: %lld-watchos -dead_strip -pie -lSystem -lc++ %t/arm64-32-main.o %t/arm64-32-my-personality.o -o %t/arm64-32-personality-second
|
2021-04-16 09:14:33 +08:00
|
|
|
# RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-32-personality-second | FileCheck %s --check-prefixes=SECOND,CHECK -D#%x,BASE=0x4000
|
2021-02-09 02:47:33 +08:00
|
|
|
|
2021-02-24 10:42:02 +08:00
|
|
|
# FIRST: Indirect symbols for (__DATA_CONST,__got)
|
|
|
|
# FIRST-NEXT: address index name
|
|
|
|
# FIRST-DAG: 0x[[#%x,GXX_PERSONALITY:]] [[#]] ___gxx_personality_v0
|
|
|
|
# FIRST-DAG: 0x[[#%x,MY_PERSONALITY:]] LOCAL
|
|
|
|
|
|
|
|
# SECOND: Indirect symbols for (__DATA_CONST,__got)
|
|
|
|
# SECOND-NEXT: address index name
|
|
|
|
# SECOND-DAG: 0x[[#%x,GXX_PERSONALITY:]] [[#]] ___gxx_personality_v0
|
|
|
|
# SECOND-DAG: 0x[[#%x,MY_PERSONALITY:]] [[#]] _my_personality
|
2021-02-09 02:47:33 +08:00
|
|
|
|
2021-02-09 02:47:34 +08:00
|
|
|
# CHECK: SYMBOL TABLE:
|
|
|
|
# CHECK-DAG: [[#%x,MAIN:]] g F __TEXT,__text _main
|
2021-06-22 10:29:11 +08:00
|
|
|
# CHECK-DAG: [[#%x,QUUX:]] g F __TEXT,__text _quux
|
2021-02-24 10:42:02 +08:00
|
|
|
# CHECK-DAG: [[#%x,FOO:]] l F __TEXT,__text _foo
|
2021-06-22 10:29:11 +08:00
|
|
|
# CHECK-DAG: [[#%x,BAZ:]] l F __TEXT,__text _baz
|
2021-02-09 02:47:34 +08:00
|
|
|
# CHECK-DAG: [[#%x,EXCEPTION0:]] g O __TEXT,__gcc_except_tab _exception0
|
|
|
|
# CHECK-DAG: [[#%x,EXCEPTION1:]] g O __TEXT,__gcc_except_tab _exception1
|
|
|
|
|
2021-02-09 02:47:33 +08:00
|
|
|
# CHECK: Contents of __unwind_info section:
|
|
|
|
# CHECK: Personality functions: (count = 2)
|
2021-04-16 09:14:33 +08:00
|
|
|
# CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#MY_PERSONALITY-BASE]]
|
|
|
|
# CHECK-DAG: personality[{{[0-9]+}}]: 0x{{0*}}[[#GXX_PERSONALITY-BASE]]
|
2021-07-04 10:23:42 +08:00
|
|
|
# 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,
|
2021-02-09 02:47:34 +08:00
|
|
|
# CHECK: LSDA descriptors:
|
2021-04-16 09:14:33 +08:00
|
|
|
# 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]]
|
2021-06-22 10:29:11 +08:00
|
|
|
# CHECK: Second level indices:
|
2021-07-04 10:23:42 +08:00
|
|
|
# CHECK-NEXT: Second level index[0]: offset in section=0x[[#%.8x,PAGEOFF]]
|
2021-06-22 10:29:11 +08:00
|
|
|
# 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
|
|
|
|
# CHECK-DAG: function offset=0x[[#%.8x,QUUX-BASE]], encoding{{.*}}=0x00000000
|
2021-02-09 02:47:33 +08:00
|
|
|
|
|
|
|
## Check that we do not add rebase opcodes to the compact unwind section.
|
|
|
|
# CHECK: Rebase table:
|
|
|
|
# CHECK-NEXT: segment section address type
|
2021-04-16 09:14:33 +08:00
|
|
|
# CHECK-NEXT: __DATA_CONST __got 0x{{[0-9A-F]*}} pointer
|
2021-02-24 10:42:02 +08:00
|
|
|
# CHECK-NOT: __TEXT
|
2021-02-09 02:47:33 +08:00
|
|
|
|
2021-07-07 23:28:27 +08:00
|
|
|
## Check that we don't create an __unwind_info section if no unwind info
|
|
|
|
## remains after dead-stripping.
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 \
|
|
|
|
# RUN: %t/empty-after-dead-strip.s -o %t/x86_64-empty-after-dead-strip.o
|
|
|
|
# RUN: %lld -dylib -dead_strip -arch x86_64 -lSystem \
|
|
|
|
# RUN: %t/x86_64-empty-after-dead-strip.o -o %t/x86_64-empty-after-strip.dylib
|
|
|
|
# RUN: llvm-objdump --macho --unwind-info %t/x86_64-empty-after-strip.dylib | \
|
|
|
|
# RUN: FileCheck %s --check-prefixes=NOUNWIND --allow-empty
|
|
|
|
# NOUNWIND-NOT: Contents of __unwind_info section:
|
|
|
|
|
2021-02-28 01:30:17 +08:00
|
|
|
#--- my-personality.s
|
2021-02-24 10:42:02 +08:00
|
|
|
.globl _my_personality, _exception0
|
2021-02-09 02:47:33 +08:00
|
|
|
.text
|
2021-02-28 01:30:17 +08:00
|
|
|
.p2align 2
|
2021-02-09 02:47:33 +08:00
|
|
|
_foo:
|
|
|
|
.cfi_startproc
|
2021-02-24 10:42:02 +08:00
|
|
|
## This will generate a section relocation.
|
2021-02-09 02:47:33 +08:00
|
|
|
.cfi_personality 155, _my_personality
|
2021-02-09 02:47:34 +08:00
|
|
|
.cfi_lsda 16, _exception0
|
2021-02-09 02:47:33 +08:00
|
|
|
.cfi_def_cfa_offset 16
|
2021-02-28 01:30:17 +08:00
|
|
|
ret
|
2021-02-09 02:47:33 +08:00
|
|
|
.cfi_endproc
|
|
|
|
|
2021-02-28 01:30:17 +08:00
|
|
|
.p2align 2
|
2021-02-09 02:47:33 +08:00
|
|
|
_bar:
|
|
|
|
.cfi_startproc
|
|
|
|
## Check that we dedup references to the same statically-linked personality.
|
|
|
|
.cfi_personality 155, _my_personality
|
2021-02-09 02:47:34 +08:00
|
|
|
.cfi_lsda 16, _exception0
|
2021-02-09 02:47:33 +08:00
|
|
|
.cfi_def_cfa_offset 16
|
2021-02-28 01:30:17 +08:00
|
|
|
ret
|
2021-02-09 02:47:33 +08:00
|
|
|
.cfi_endproc
|
|
|
|
|
2021-02-28 01:30:17 +08:00
|
|
|
.p2align 2
|
2021-02-24 10:42:02 +08:00
|
|
|
_my_personality:
|
2021-02-28 01:30:17 +08:00
|
|
|
ret
|
2021-02-24 10:42:02 +08:00
|
|
|
|
|
|
|
.section __TEXT,__gcc_except_tab
|
|
|
|
_exception0:
|
|
|
|
.space 1
|
|
|
|
|
|
|
|
#--- main.s
|
2021-06-22 10:29:11 +08:00
|
|
|
.globl _main, _quux, _my_personality, _exception1
|
2021-02-24 10:42:02 +08:00
|
|
|
|
|
|
|
.text
|
2021-02-28 01:30:17 +08:00
|
|
|
.p2align 2
|
2021-02-09 02:47:33 +08:00
|
|
|
_main:
|
|
|
|
.cfi_startproc
|
|
|
|
.cfi_personality 155, ___gxx_personality_v0
|
2021-02-09 02:47:34 +08:00
|
|
|
.cfi_lsda 16, _exception1
|
2021-02-09 02:47:33 +08:00
|
|
|
.cfi_def_cfa_offset 16
|
2021-02-28 01:30:17 +08:00
|
|
|
ret
|
2021-02-09 02:47:33 +08:00
|
|
|
.cfi_endproc
|
|
|
|
|
2021-06-22 10:29:11 +08:00
|
|
|
## _quux has no unwind information.
|
|
|
|
## (In real life, it'd be part of a separate TU that was built with
|
|
|
|
## -fno-exceptions, while the previous and next TU might be Objective-C++
|
|
|
|
## which has unwind info for Objective-C).
|
|
|
|
.p2align 2
|
2021-07-04 09:57:43 +08:00
|
|
|
.no_dead_strip _quux
|
2021-06-22 10:29:11 +08:00
|
|
|
_quux:
|
|
|
|
ret
|
|
|
|
|
2021-06-24 02:25:08 +08:00
|
|
|
.globl _abs
|
2021-07-04 09:57:43 +08:00
|
|
|
.no_dead_strip _abs
|
2021-06-24 02:25:08 +08:00
|
|
|
_abs = 4
|
|
|
|
|
2021-02-28 01:30:17 +08:00
|
|
|
.p2align 2
|
2021-07-04 09:57:43 +08:00
|
|
|
.no_dead_strip _baz
|
2021-02-24 10:42:02 +08:00
|
|
|
_baz:
|
|
|
|
.cfi_startproc
|
|
|
|
## This will generate a symbol relocation. Check that we reuse the personality
|
|
|
|
## referenced by the section relocation in my_personality.s.
|
|
|
|
.cfi_personality 155, _my_personality
|
|
|
|
.cfi_lsda 16, _exception1
|
|
|
|
.cfi_def_cfa_offset 16
|
2021-02-28 01:30:17 +08:00
|
|
|
ret
|
2021-02-24 10:42:02 +08:00
|
|
|
.cfi_endproc
|
|
|
|
|
2021-07-04 09:57:43 +08:00
|
|
|
.globl _stripped
|
|
|
|
_stripped:
|
|
|
|
.cfi_startproc
|
|
|
|
.cfi_personality 155, ___gxx_personality_v0
|
|
|
|
.cfi_lsda 16, _exception1
|
|
|
|
.cfi_def_cfa_offset 16
|
|
|
|
ret
|
|
|
|
.cfi_endproc
|
|
|
|
|
2021-02-09 02:47:34 +08:00
|
|
|
|
|
|
|
.section __TEXT,__gcc_except_tab
|
|
|
|
_exception1:
|
|
|
|
.space 1
|
2021-07-04 09:57:43 +08:00
|
|
|
|
|
|
|
.subsections_via_symbols
|
2021-07-07 23:28:27 +08:00
|
|
|
|
|
|
|
#--- empty-after-dead-strip.s
|
|
|
|
.text
|
|
|
|
|
|
|
|
## Local symbol with unwind info.
|
|
|
|
## The symbol is removed by -dead_strip.
|
|
|
|
_foo :
|
|
|
|
.cfi_startproc
|
|
|
|
.cfi_def_cfa_offset 16
|
|
|
|
retq
|
|
|
|
.cfi_endproc
|
|
|
|
|
|
|
|
.subsections_via_symbols
|