From fd28f71872f74cfa23f676e87e1c27c4431d6dfa Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Thu, 22 Apr 2021 19:37:47 -0400 Subject: [PATCH] [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 --- lld/test/MachO/compact-unwind-generated.test | 2 +- lld/test/MachO/compact-unwind.s | 8 +++--- lld/test/MachO/export-trie.s | 4 +-- lld/test/MachO/internalize.ll | 4 +-- lld/test/MachO/invalid/compact-unwind-bad-reloc.s | 2 +- .../MachO/invalid/compact-unwind-personalities.s | 4 +-- .../MachO/invalid/invalid-relocation-length.yaml | 2 +- .../MachO/invalid/invalid-relocation-pcrel.yaml | 2 +- lld/test/MachO/lc-linker-option.ll | 6 ++--- lld/test/MachO/linkonce.ll | 4 +-- lld/test/MachO/lit.local.cfg | 2 +- lld/test/MachO/load-command-sequence.s | 2 +- lld/test/MachO/local-got.s | 27 +++++++++----------- lld/test/MachO/lto-archive.ll | 6 ++--- lld/test/MachO/lto-object-path.ll | 2 +- lld/test/MachO/lto-save-temps.ll | 4 +-- lld/test/MachO/map-file.s | 2 +- lld/test/MachO/mh-header-link.s | 4 +-- lld/test/MachO/module-asm.ll | 2 +- lld/test/MachO/objc.s | 2 +- lld/test/MachO/symtab.s | 6 ++--- lld/test/MachO/t.s | 2 +- lld/test/MachO/x86-64-reloc-unsigned.s | 3 --- lld/test/MachO/x86-64-relocs.s | 2 +- lld/test/MachO/x86-64-stubs.s | 29 +++++++++++----------- 25 files changed, 64 insertions(+), 69 deletions(-) diff --git a/lld/test/MachO/compact-unwind-generated.test b/lld/test/MachO/compact-unwind-generated.test index 4f8a9618..42dd918 100644 --- a/lld/test/MachO/compact-unwind-generated.test +++ b/lld/test/MachO/compact-unwind-generated.test @@ -16,6 +16,6 @@ # RUN: %python %S/tools/generate-cfi-funcs.py --seed=johnnyapple >%t.s # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 -o %t.o %t.s -# RUN: %lld -platform_version macos 10.15 11.0 -Z -L%S/Inputs/MacOSX.sdk/usr/lib -lSystem -o %t %t.o +# RUN: %lld -Z -L%S/Inputs/MacOSX.sdk/usr/lib -lSystem -o %t %t.o # RUN: llvm-objdump --unwind-info --syms %t %t.o >%t.dump # RUN: %python %S/tools/validate-unwind-info.py %t.dump diff --git a/lld/test/MachO/compact-unwind.s b/lld/test/MachO/compact-unwind.s index 246887a..1da965f2 100644 --- a/lld/test/MachO/compact-unwind.s +++ b/lld/test/MachO/compact-unwind.s @@ -2,16 +2,16 @@ # RUN: rm -rf %t; split-file %s %t # 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 -# RUN: %lld -platform_version macos 10.15 11.0 -arch x86_64 -pie -lSystem -lc++ %t/x86_64-my-personality.o %t/x86_64-main.o -o %t/x86_64-personality-first +# 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 # 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 -# RUN: %lld -platform_version macos 10.15 11.0 -arch x86_64 -pie -lSystem -lc++ %t/x86_64-main.o %t/x86_64-my-personality.o -o %t/x86_64-personality-second +# RUN: %lld -arch x86_64 -pie -lSystem -lc++ %t/x86_64-main.o %t/x86_64-my-personality.o -o %t/x86_64-personality-second # 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 # 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 -# RUN: %lld -platform_version macos 10.15 11.0 -arch arm64 -pie -lSystem -lc++ %t/arm64-my-personality.o %t/arm64-main.o -o %t/arm64-personality-first +# RUN: %lld -arch arm64 -pie -lSystem -lc++ %t/arm64-my-personality.o %t/arm64-main.o -o %t/arm64-personality-first # RUN: llvm-objdump --macho --unwind-info --syms --indirect-symbols --rebase %t/arm64-personality-first | FileCheck %s --check-prefixes=FIRST,CHECK -D#%x,BASE=0x100000000 -# RUN: %lld -platform_version macos 10.15 11.0 -arch arm64 -pie -lSystem -lc++ %t/arm64-main.o %t/arm64-my-personality.o -o %t/arm64-personality-second +# RUN: %lld -arch arm64 -pie -lSystem -lc++ %t/arm64-main.o %t/arm64-my-personality.o -o %t/arm64-personality-second # 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 diff --git a/lld/test/MachO/export-trie.s b/lld/test/MachO/export-trie.s index cab8312..cfa6724 100644 --- a/lld/test/MachO/export-trie.s +++ b/lld/test/MachO/export-trie.s @@ -15,9 +15,9 @@ # EXPORTS-DAG: [[#%x, HELLO_WORLD_ADDR:]] {{.*}} _hello_world # EXPORTS-DAG: [[#%x, HELLO_ITS_ME_ADDR:]] {{.*}} _hello_its_me # EXPORTS-DAG: [[#%x, HELLO_ITS_YOU_ADDR:]] {{.*}} _hello_its_you -# EXPORTS-DAG: {{0+}} g *ABS* __mh_execute_header +# EXPORTS-DAG: [[#%x, HEADER_ADDR:]] g F __TEXT,__text __mh_execute_header # EXPORTS-LABEL: Exports trie: -# EXPORTS-DAG: 0x{{0+}} __mh_execute_header [absolute] +# EXPORTS-DAG: 0x{{0*}}[[#%X, HEADER_ADDR]] __mh_execute_header # EXPORTS-DAG: 0x{{0*}}[[#%X, MAIN_ADDR]] _main # EXPORTS-DAG: 0x{{0*}}[[#%X, HELLO_ADDR]] _hello # EXPORTS-DAG: 0x{{0*}}[[#%X, HELLO_WORLD_ADDR]] _hello_world diff --git a/lld/test/MachO/internalize.ll b/lld/test/MachO/internalize.ll index 8dce7f6..74c39be 100644 --- a/lld/test/MachO/internalize.ll +++ b/lld/test/MachO/internalize.ll @@ -36,7 +36,7 @@ ; SYMTAB-EMPTY: ;--- test.s -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" declare void @baz() @@ -60,7 +60,7 @@ define void @used_in_regular_obj() { } ;--- baz.s -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define void @baz() { diff --git a/lld/test/MachO/invalid/compact-unwind-bad-reloc.s b/lld/test/MachO/invalid/compact-unwind-bad-reloc.s index 605935b..9204caf 100644 --- a/lld/test/MachO/invalid/compact-unwind-bad-reloc.s +++ b/lld/test/MachO/invalid/compact-unwind-bad-reloc.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %s -o %t.o -# RUN: not %lld -platform_version macos 10.15 11.0 -pie -lSystem -lc++ %t.o -o %t 2>&1 | FileCheck %s -DFILE=%t.o +# RUN: not %lld -pie -lSystem -lc++ %t.o -o %t 2>&1 | FileCheck %s -DFILE=%t.o # CHECK: error: compact unwind references address in [[FILE]]:(__data) which is not in segment __TEXT .globl _main, _not_a_function diff --git a/lld/test/MachO/invalid/compact-unwind-personalities.s b/lld/test/MachO/invalid/compact-unwind-personalities.s index 23f8291..744a4ed 100644 --- a/lld/test/MachO/invalid/compact-unwind-personalities.s +++ b/lld/test/MachO/invalid/compact-unwind-personalities.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %s -o %t.o -# RUN: not %lld -platform_version macos 10.15 11.0 -pie -lSystem -lc++ %t.o -o %t 2>&1 | FileCheck %s --check-prefix=TOO-MANY -# RUN: not %lld -platform_version macos 10.15 11.0 -pie -lSystem %t.o -o %t 2>&1 | FileCheck %s --check-prefix=UNDEF +# RUN: not %lld -pie -lSystem -lc++ %t.o -o %t 2>&1 | FileCheck %s --check-prefix=TOO-MANY +# RUN: not %lld -pie -lSystem %t.o -o %t 2>&1 | FileCheck %s --check-prefix=UNDEF # TOO-MANY: error: too many personalities (4) for compact unwind to encode # UNDEF: error: undefined symbol: ___gxx_personality_v0 diff --git a/lld/test/MachO/invalid/invalid-relocation-length.yaml b/lld/test/MachO/invalid/invalid-relocation-length.yaml index 49b081a..ff8759b 100644 --- a/lld/test/MachO/invalid/invalid-relocation-length.yaml +++ b/lld/test/MachO/invalid/invalid-relocation-length.yaml @@ -52,7 +52,7 @@ LoadCommands: - cmd: LC_BUILD_VERSION cmdsize: 24 platform: 1 - minos: 655360 + minos: 659200 sdk: 0 ntools: 0 - cmd: LC_SYMTAB diff --git a/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml b/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml index 3adc207..4b3ad19 100644 --- a/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml +++ b/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml @@ -54,7 +54,7 @@ LoadCommands: - cmd: LC_BUILD_VERSION cmdsize: 24 platform: 1 - minos: 655360 + minos: 659200 sdk: 0 ntools: 0 - cmd: LC_SYMTAB diff --git a/lld/test/MachO/lc-linker-option.ll b/lld/test/MachO/lc-linker-option.ll index 7fb80dd..48f93c3 100644 --- a/lld/test/MachO/lc-linker-option.ll +++ b/lld/test/MachO/lc-linker-option.ll @@ -28,7 +28,7 @@ # INVALID: error: -why_load is not allowed in LC_LINKER_OPTION #--- framework.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" !0 = !{!"-framework", !"CoreFoundation"} @@ -39,7 +39,7 @@ define void @main() { } #--- l.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" !0 = !{!"-lSystem"} @@ -51,7 +51,7 @@ define void @main() { #--- invalid.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" !0 = !{!"-why_load"} diff --git a/lld/test/MachO/linkonce.ll b/lld/test/MachO/linkonce.ll index 760b747..a1f4c50 100644 --- a/lld/test/MachO/linkonce.ll +++ b/lld/test/MachO/linkonce.ll @@ -12,7 +12,7 @@ #--- first.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define linkonce void @foo() section "__TEXT,first" { @@ -21,7 +21,7 @@ define linkonce void @foo() section "__TEXT,first" { #--- second.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define linkonce void @foo() section "__TEXT,second" { diff --git a/lld/test/MachO/lit.local.cfg b/lld/test/MachO/lit.local.cfg index 17e6317..a45fbae 100644 --- a/lld/test/MachO/lit.local.cfg +++ b/lld/test/MachO/lit.local.cfg @@ -16,7 +16,7 @@ config.substitutions.append(('%lld-watchos', # Since most of our tests are written around x86_64, we give this platform the # shortest substitution of "%lld". -lld = ('ld64.lld -arch x86_64 -platform_version macos 10.0 11.0 -syslibroot ' + +lld = ('ld64.lld -arch x86_64 -platform_version macos 10.15 11.0 -syslibroot ' + os.path.join(config.test_source_root, "MachO", "Inputs", "MacOSX.sdk")) config.substitutions.append(('%lld', lld + ' -fatal_warnings')) config.substitutions.append(('%no_fatal_warnings_lld', lld)) diff --git a/lld/test/MachO/load-command-sequence.s b/lld/test/MachO/load-command-sequence.s index 81051bf..734b7d1 100644 --- a/lld/test/MachO/load-command-sequence.s +++ b/lld/test/MachO/load-command-sequence.s @@ -47,7 +47,7 @@ # DYLIB: cmd LC_ID_DYLIB # COMMON: cmd LC_UUID -# COMMON: cmd LC_VERSION_MIN_MACOSX +# COMMON: cmd LC_BUILD_VERSION # COMMON: cmd LC_LOAD_DYLIB .section __TEXT,__cstring diff --git a/lld/test/MachO/local-got.s b/lld/test/MachO/local-got.s index e4a1c5e..ef231f0 100644 --- a/lld/test/MachO/local-got.s +++ b/lld/test/MachO/local-got.s @@ -5,40 +5,37 @@ # RUN: %lld -lSystem -dylib -install_name \ # RUN: @executable_path/libhello.dylib %t/libhello.o -o %t/libhello.dylib # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o + # RUN: %lld -lSystem -o %t/test %t/test.o -L%t -lhello -# RUN: llvm-objdump --full-contents --rebase --bind %t/test | FileCheck %s --match-full-lines +# RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,PIE --match-full-lines +# RUN: %lld -no_pie -lSystem -o %t/test %t/test.o -L%t -lhello +# RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,NO-PIE --match-full-lines ## Check that the GOT references the cstrings. --full-contents displays the ## address offset and the contents at that address very similarly, so am using ## --match-full-lines to make sure we match on the right thing. # CHECK: Contents of section __TEXT,__cstring: -# CHECK-NEXT: 100000424 {{.*}} +# CHECK-NEXT: 100000434 {{.*}} ## 1st 8 bytes refer to the start of __cstring + 0xe, 2nd 8 bytes refer to the ## start of __cstring # CHECK: Contents of section __DATA_CONST,__got: -# CHECK-NEXT: [[#%X,ADDR:]] 32040000 01000000 24040000 01000000 {{.*}} +# CHECK-NEXT: [[#%X,ADDR:]] 42040000 01000000 34040000 01000000 {{.*}} # CHECK-NEXT: [[#ADDR + 16]] 00000000 00000000 {{.*}} ## Check that the rebase table is empty. -# CHECK: Rebase table: -# CHECK-NEXT: segment section address type - -## Check that a non-locally-defined symbol is still bound at the correct offset: -# CHECK-NEXT: Bind table: -# CHECK-NEXT: segment section address type addend dylib symbol -# CHECK-NEXT: __DATA_CONST __got 0x[[#ADDR+16]] pointer 0 libhello _hello_its_me +# NO-PIE: Rebase table: +# NO-PIE-NEXT: segment section address type -# RUN: %lld -pie -lSystem -o %t/test %t/test.o -L%t -lhello -# RUN: llvm-objdump --macho --rebase --bind %t/test | FileCheck %s --check-prefix=PIE --match-full-lines # PIE: Rebase table: # PIE-NEXT: segment section address type # PIE-NEXT: __DATA_CONST __got 0x[[#%X,ADDR:]] pointer # PIE-NEXT: __DATA_CONST __got 0x[[#ADDR + 8]] pointer -# PIE-NEXT: Bind table: -# PIE-NEXT: segment section address type addend dylib symbol -# PIE-NEXT: __DATA_CONST __got 0x[[#ADDR+16]] pointer 0 libhello _hello_its_me +## Check that a non-locally-defined symbol is still bound at the correct offset: +# CHECK-NEXT: Bind table: +# CHECK-NEXT: segment section address type addend dylib symbol +# CHECK-NEXT: __DATA_CONST __got 0x[[#ADDR+16]] pointer 0 libhello _hello_its_me .globl _main diff --git a/lld/test/MachO/lto-archive.ll b/lld/test/MachO/lto-archive.ll index 372da3b..98ec4de 100644 --- a/lld/test/MachO/lto-archive.ll +++ b/lld/test/MachO/lto-archive.ll @@ -30,7 +30,7 @@ ;--- foo.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define void @foo() { @@ -39,7 +39,7 @@ define void @foo() { ;--- has-objc-symbol.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" %struct._class_t = type { i8 } @@ -47,7 +47,7 @@ target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16 ;--- has-objc-category.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" %struct._category_t = type { i8 } diff --git a/lld/test/MachO/lto-object-path.ll b/lld/test/MachO/lto-object-path.ll index df8f9dd..b21b38f 100644 --- a/lld/test/MachO/lto-object-path.ll +++ b/lld/test/MachO/lto-object-path.ll @@ -19,7 +19,7 @@ ; CHECK-NEXT: 0000000000000000 - 01 0000 SO ; CHECK-NEXT: {{[0-9a-f]+}} T _main -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define void @main() #0 !dbg !4 { diff --git a/lld/test/MachO/lto-save-temps.ll b/lld/test/MachO/lto-save-temps.ll index 7375351..d1b2cad 100644 --- a/lld/test/MachO/lto-save-temps.ll +++ b/lld/test/MachO/lto-save-temps.ll @@ -31,7 +31,7 @@ ;--- foo.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define void @foo() { @@ -40,7 +40,7 @@ define void @foo() { ;--- bar.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define void @bar() { diff --git a/lld/test/MachO/map-file.s b/lld/test/MachO/map-file.s index 215d193..610ed9b 100644 --- a/lld/test/MachO/map-file.s +++ b/lld/test/MachO/map-file.s @@ -29,7 +29,7 @@ _main: # CHECK-NEXT: [[#%x,MAIN:]] g F __TEXT,__text _main # CHECK-NEXT: [[#%x,NUMBER:]] g O __DATA,__common _number # CHECK-NEXT: [[#%x,FOO:]] g O __TEXT,obj _foo -# CHECK-NEXT: {{0+}} g *ABS* __mh_execute_header +# CHECK-NEXT: [[#%x,HEADER:]] g F __TEXT,__text __mh_execute_header # CHECK-NEXT: # Path: {{.*}}{{/|\\}}map-file.s.tmp/test-map # CHECK-NEXT: # Arch: x86_64 diff --git a/lld/test/MachO/mh-header-link.s b/lld/test/MachO/mh-header-link.s index 4f51d1d..5c313e2 100644 --- a/lld/test/MachO/mh-header-link.s +++ b/lld/test/MachO/mh-header-link.s @@ -8,7 +8,7 @@ ## Test that in a dylib, we can link against __mh_dylib_header ## (but not in other types of files) -# RUN: llvm-mc %t/dylib.s -triple=x86_64-apple-macos10.0 -filetype=obj -o %t/dylib.o +# RUN: llvm-mc %t/dylib.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/dylib.o # RUN: %lld -pie -dylib %t/dylib.o -o %t/dylib.out # RUN: llvm-objdump -m --syms %t/dylib.out | FileCheck %s --check-prefix DYLIB @@ -20,7 +20,7 @@ # ERR-DYLIB: error: undefined symbol: __mh_dylib_header ## Test that in an executable, we can link against __mh_execute_header -# RUN: llvm-mc %t/main.s -triple=x86_64-apple-macos10.0 -filetype=obj -o %t/exec.o +# RUN: llvm-mc %t/main.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/exec.o # RUN: %lld -pie %t/exec.o -o %t/exec.out ## But it would be an error trying to reference __mh_execute_header in a dylib diff --git a/lld/test/MachO/module-asm.ll b/lld/test/MachO/module-asm.ll index 466d3e1..01adcc4 100644 --- a/lld/test/MachO/module-asm.ll +++ b/lld/test/MachO/module-asm.ll @@ -9,7 +9,7 @@ ; CHECK: <_main>: ; CHECK-NEXT: jmp {{.*}} <_foo> -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" module asm ".text" diff --git a/lld/test/MachO/objc.s b/lld/test/MachO/objc.s index 8a7226f..d727497 100644 --- a/lld/test/MachO/objc.s +++ b/lld/test/MachO/objc.s @@ -32,7 +32,7 @@ # NO-OBJC-EMPTY: # NO-OBJC-NEXT: SYMBOL TABLE: # NO-OBJC-NEXT: g F __TEXT,__text _main -# NO-OBJC-NEXT: g *ABS* __mh_execute_header +# NO-OBJC-NEXT: g F __TEXT,__text __mh_execute_header # NO-OBJC-EMPTY: #--- has-objc-symbol.s diff --git a/lld/test/MachO/symtab.s b/lld/test/MachO/symtab.s index 7083341..7dff1b0 100644 --- a/lld/test/MachO/symtab.s +++ b/lld/test/MachO/symtab.s @@ -59,12 +59,12 @@ # CHECK-NEXT: Symbol { # CHECK-NEXT: Name: __mh_execute_header (81) # CHECK-NEXT: Extern -# CHECK-NEXT: Type: Abs (0x2) -# CHECK-NEXT: Section: (0x0) +# CHECK-NEXT: Type: Section (0xE) +# CHECK-NEXT: Section: __text (0x1) # CHECK-NEXT: RefType: UndefinedNonLazy (0x0) # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] -# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Value: 0x100000000 # CHECK-NEXT: } # CHECK-NEXT: Symbol { # CHECK-NEXT: Name: dyld_stub_binder diff --git a/lld/test/MachO/t.s b/lld/test/MachO/t.s index 14a56e2..7ff97da 100644 --- a/lld/test/MachO/t.s +++ b/lld/test/MachO/t.s @@ -33,7 +33,7 @@ _bar: #--- baz.ll -target triple = "x86_64-apple-macosx10.0.0" +target triple = "x86_64-apple-macosx10.15.0" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" define void @baz() { diff --git a/lld/test/MachO/x86-64-reloc-unsigned.s b/lld/test/MachO/x86-64-reloc-unsigned.s index 5fdbdf1..1d2f0fb 100644 --- a/lld/test/MachO/x86-64-reloc-unsigned.s +++ b/lld/test/MachO/x86-64-reloc-unsigned.s @@ -23,9 +23,6 @@ # CHECK-NEXT: 100001000 08100000 01000000 # CHECK: Contents of section __DATA,bar: # CHECK-NEXT: 100001008 011000f0 11211111 02000000 -# CHECK: Rebase table: -# CHECK-NEXT: segment section address type -# CHECK-EMPTY: # PIE: Rebase table: # PIE-NEXT: segment section address type diff --git a/lld/test/MachO/x86-64-relocs.s b/lld/test/MachO/x86-64-relocs.s index c5627c4..8e94744 100644 --- a/lld/test/MachO/x86-64-relocs.s +++ b/lld/test/MachO/x86-64-relocs.s @@ -21,7 +21,7 @@ # RUN: llvm-objdump --section=__const --full-contents %t | FileCheck %s --check-prefix=NONPCREL # NONPCREL: Contents of section __DATA,__const: -# NONPCREL-NEXT: 100001000 08040000 01000000 08040000 01000000 +# NONPCREL-NEXT: 100001000 18040000 01000000 18040000 01000000 .section __TEXT,__text .globl _main, _f diff --git a/lld/test/MachO/x86-64-stubs.s b/lld/test/MachO/x86-64-stubs.s index 62f70f1f..905ace5 100644 --- a/lld/test/MachO/x86-64-stubs.s +++ b/lld/test/MachO/x86-64-stubs.s @@ -1,5 +1,5 @@ # REQUIRES: x86 -# RUN: mkdir -p %t +# RUN: rm -rf %t; mkdir -p %t # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \ # RUN: -o %t/libhello.o # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \ @@ -12,20 +12,21 @@ # RUN: -o %t/libgoodbye.dylib # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/dylink-lazy.o -# RUN: %lld -o %t/dylink-lazy \ +# RUN: %lld -no_pie -o %t/dylink-lazy-no-pie \ # RUN: -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem ## When looking at the __stubs section alone, we are unable to easily tell which ## symbol each entry points to. So we call objdump twice in order to get the ## disassembly of __text and the bind tables first, which allow us to check for ## matching entries in __stubs. +# RUN: llvm-objdump -d --no-show-raw-insn --syms --rebase --bind --lazy-bind %t/dylink-lazy-no-pie > %t/objdump-no-pie +# RUN: llvm-objdump -D --no-show-raw-insn %t/dylink-lazy-no-pie >> %t/objdump-no-pie +# RUN: FileCheck %s --check-prefixes=CHECK,NO-PIE < %t/objdump-no-pie + +# RUN: %lld -o %t/dylink-lazy -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem # RUN: llvm-objdump -d --no-show-raw-insn --syms --rebase --bind --lazy-bind %t/dylink-lazy > %t/objdump # RUN: llvm-objdump -D --no-show-raw-insn %t/dylink-lazy >> %t/objdump -# RUN: FileCheck %s < %t/objdump - -# RUN: %lld -pie -o %t/dylink-lazy-pie \ -# RUN: -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem -# RUN: llvm-objdump --macho --rebase %t/dylink-lazy-pie | FileCheck %s --check-prefix=PIE +# RUN: FileCheck %s --check-prefixes=CHECK,PIE < %t/objdump # CHECK-LABEL: SYMBOL TABLE: # CHECK: {{0*}}[[#%x, IMGLOADER:]] l {{.*}} __DATA,__data __dyld_private @@ -35,8 +36,13 @@ # CHECK-NEXT: callq 0x[[#%x, GOODBYE_STUB:]] ## Check that the rebase table is empty. -# CHECK-LABEL: Rebase table: -# CHECK-NEXT: segment section address type +# NO-PIE-LABEL: Rebase table: +# NO-PIE-NEXT: segment section address type + +# PIE-LABEL: Rebase table: +# PIE-NEXT: segment section address type +# PIE-NEXT: __DATA __la_symbol_ptr 0x[[#%X, ADDR:]] pointer +# PIE-NEXT: __DATA __la_symbol_ptr 0x[[#ADDR + 8]] pointer # CHECK-NEXT: Bind table: # CHECK: __DATA_CONST __got 0x[[#%x, BINDER:]] pointer 0 libSystem dyld_stub_binder @@ -60,11 +66,6 @@ # CHECK-NEXT: pushq $21 # CHECK-NEXT: jmp 0x[[#STUB_HELPER_ENTRY]] -# PIE: Rebase table: -# PIE-NEXT: segment section address type -# PIE-NEXT: __DATA __la_symbol_ptr 0x[[#%X, ADDR:]] pointer -# PIE-NEXT: __DATA __la_symbol_ptr 0x[[#ADDR + 8]] pointer - .text .globl _main -- 2.7.4