diff --git a/lld/test/MachO/export-trie.s b/lld/test/MachO/export-trie.s --- 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/lit.local.cfg b/lld/test/MachO/lit.local.cfg --- a/lld/test/MachO/lit.local.cfg +++ b/lld/test/MachO/lit.local.cfg @@ -16,7 +16,7 @@ # 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 --- 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 --- 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/map-file.s b/lld/test/MachO/map-file.s --- a/lld/test/MachO/map-file.s +++ b/lld/test/MachO/map-file.s @@ -29,7 +29,7 @@ # 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 --- 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-macos11.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-macos11.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/objc.s b/lld/test/MachO/objc.s --- 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 --- 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/x86-64-reloc-unsigned.s b/lld/test/MachO/x86-64-reloc-unsigned.s --- 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 --- 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 --- 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