[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
This commit is contained in:
Jez Ng 2021-04-22 19:37:47 -04:00
parent 7b32e8b96a
commit fd28f71872
25 changed files with 64 additions and 69 deletions

View File

@ -16,6 +16,6 @@
# RUN: %python %S/tools/generate-cfi-funcs.py --seed=johnnyapple >%t.s # 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: 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: llvm-objdump --unwind-info --syms %t %t.o >%t.dump
# RUN: %python %S/tools/validate-unwind-info.py %t.dump # RUN: %python %S/tools/validate-unwind-info.py %t.dump

View File

@ -2,16 +2,16 @@
# RUN: rm -rf %t; split-file %s %t # 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/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: 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: 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-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/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: 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: 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-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/my-personality.s -o %t/arm64-32-my-personality.o

View File

@ -15,9 +15,9 @@
# EXPORTS-DAG: [[#%x, HELLO_WORLD_ADDR:]] {{.*}} _hello_world # EXPORTS-DAG: [[#%x, HELLO_WORLD_ADDR:]] {{.*}} _hello_world
# EXPORTS-DAG: [[#%x, HELLO_ITS_ME_ADDR:]] {{.*}} _hello_its_me # EXPORTS-DAG: [[#%x, HELLO_ITS_ME_ADDR:]] {{.*}} _hello_its_me
# EXPORTS-DAG: [[#%x, HELLO_ITS_YOU_ADDR:]] {{.*}} _hello_its_you # 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-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, MAIN_ADDR]] _main
# EXPORTS-DAG: 0x{{0*}}[[#%X, HELLO_ADDR]] _hello # EXPORTS-DAG: 0x{{0*}}[[#%X, HELLO_ADDR]] _hello
# EXPORTS-DAG: 0x{{0*}}[[#%X, HELLO_WORLD_ADDR]] _hello_world # EXPORTS-DAG: 0x{{0*}}[[#%X, HELLO_WORLD_ADDR]] _hello_world

View File

@ -36,7 +36,7 @@
; SYMTAB-EMPTY: ; SYMTAB-EMPTY:
;--- test.s ;--- 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" 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() declare void @baz()
@ -60,7 +60,7 @@ define void @used_in_regular_obj() {
} }
;--- baz.s ;--- 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" 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() { define void @baz() {

View File

@ -1,6 +1,6 @@
# REQUIRES: x86 # REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %s -o %t.o # 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 # CHECK: error: compact unwind references address in [[FILE]]:(__data) which is not in segment __TEXT
.globl _main, _not_a_function .globl _main, _not_a_function

View File

@ -1,7 +1,7 @@
# REQUIRES: x86 # REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin19.0.0 %s -o %t.o # 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 -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 %t.o -o %t 2>&1 | FileCheck %s --check-prefix=UNDEF
# TOO-MANY: error: too many personalities (4) for compact unwind to encode # TOO-MANY: error: too many personalities (4) for compact unwind to encode
# UNDEF: error: undefined symbol: ___gxx_personality_v0 # UNDEF: error: undefined symbol: ___gxx_personality_v0

View File

@ -52,7 +52,7 @@ LoadCommands:
- cmd: LC_BUILD_VERSION - cmd: LC_BUILD_VERSION
cmdsize: 24 cmdsize: 24
platform: 1 platform: 1
minos: 655360 minos: 659200
sdk: 0 sdk: 0
ntools: 0 ntools: 0
- cmd: LC_SYMTAB - cmd: LC_SYMTAB

View File

@ -54,7 +54,7 @@ LoadCommands:
- cmd: LC_BUILD_VERSION - cmd: LC_BUILD_VERSION
cmdsize: 24 cmdsize: 24
platform: 1 platform: 1
minos: 655360 minos: 659200
sdk: 0 sdk: 0
ntools: 0 ntools: 0
- cmd: LC_SYMTAB - cmd: LC_SYMTAB

View File

@ -28,7 +28,7 @@
# INVALID: error: -why_load is not allowed in LC_LINKER_OPTION # INVALID: error: -why_load is not allowed in LC_LINKER_OPTION
#--- framework.ll #--- 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" 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"} !0 = !{!"-framework", !"CoreFoundation"}
@ -39,7 +39,7 @@ define void @main() {
} }
#--- l.ll #--- 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" 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"} !0 = !{!"-lSystem"}
@ -51,7 +51,7 @@ define void @main() {
#--- invalid.ll #--- 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" 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"} !0 = !{!"-why_load"}

View File

@ -12,7 +12,7 @@
#--- first.ll #--- 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" 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" { define linkonce void @foo() section "__TEXT,first" {
@ -21,7 +21,7 @@ define linkonce void @foo() section "__TEXT,first" {
#--- second.ll #--- 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" 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" { define linkonce void @foo() section "__TEXT,second" {

View File

@ -16,7 +16,7 @@ config.substitutions.append(('%lld-watchos',
# Since most of our tests are written around x86_64, we give this platform the # Since most of our tests are written around x86_64, we give this platform the
# shortest substitution of "%lld". # 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")) os.path.join(config.test_source_root, "MachO", "Inputs", "MacOSX.sdk"))
config.substitutions.append(('%lld', lld + ' -fatal_warnings')) config.substitutions.append(('%lld', lld + ' -fatal_warnings'))
config.substitutions.append(('%no_fatal_warnings_lld', lld)) config.substitutions.append(('%no_fatal_warnings_lld', lld))

View File

@ -47,7 +47,7 @@
# DYLIB: cmd LC_ID_DYLIB # DYLIB: cmd LC_ID_DYLIB
# COMMON: cmd LC_UUID # COMMON: cmd LC_UUID
# COMMON: cmd LC_VERSION_MIN_MACOSX # COMMON: cmd LC_BUILD_VERSION
# COMMON: cmd LC_LOAD_DYLIB # COMMON: cmd LC_LOAD_DYLIB
.section __TEXT,__cstring .section __TEXT,__cstring

View File

@ -5,40 +5,37 @@
# RUN: %lld -lSystem -dylib -install_name \ # RUN: %lld -lSystem -dylib -install_name \
# RUN: @executable_path/libhello.dylib %t/libhello.o -o %t/libhello.dylib # 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: 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: %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 ## Check that the GOT references the cstrings. --full-contents displays the
## address offset and the contents at that address very similarly, so am using ## 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. ## --match-full-lines to make sure we match on the right thing.
# CHECK: Contents of section __TEXT,__cstring: # 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 ## 1st 8 bytes refer to the start of __cstring + 0xe, 2nd 8 bytes refer to the
## start of __cstring ## start of __cstring
# CHECK: Contents of section __DATA_CONST,__got: # 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-NEXT: [[#ADDR + 16]] 00000000 00000000 {{.*}}
## Check that the rebase table is empty. ## Check that the rebase table is empty.
# CHECK: Rebase table: # NO-PIE: Rebase table:
# CHECK-NEXT: segment section address type # NO-PIE-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
# 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: Rebase table:
# PIE-NEXT: segment section address type # PIE-NEXT: segment section address type
# PIE-NEXT: __DATA_CONST __got 0x[[#%X,ADDR:]] pointer # PIE-NEXT: __DATA_CONST __got 0x[[#%X,ADDR:]] pointer
# PIE-NEXT: __DATA_CONST __got 0x[[#ADDR + 8]] pointer # PIE-NEXT: __DATA_CONST __got 0x[[#ADDR + 8]] pointer
# PIE-NEXT: Bind table: ## Check that a non-locally-defined symbol is still bound at the correct offset:
# PIE-NEXT: segment section address type addend dylib symbol # CHECK-NEXT: Bind table:
# PIE-NEXT: __DATA_CONST __got 0x[[#ADDR+16]] pointer 0 libhello _hello_its_me # 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 .globl _main

View File

@ -30,7 +30,7 @@
;--- foo.ll ;--- 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" 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() { define void @foo() {
@ -39,7 +39,7 @@ define void @foo() {
;--- has-objc-symbol.ll ;--- 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" 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 } %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 ;--- 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" 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 } %struct._category_t = type { i8 }

View File

@ -19,7 +19,7 @@
; CHECK-NEXT: 0000000000000000 - 01 0000 SO ; CHECK-NEXT: 0000000000000000 - 01 0000 SO
; CHECK-NEXT: {{[0-9a-f]+}} T _main ; 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" 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 { define void @main() #0 !dbg !4 {

View File

@ -31,7 +31,7 @@
;--- foo.ll ;--- 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" 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() { define void @foo() {
@ -40,7 +40,7 @@ define void @foo() {
;--- bar.ll ;--- 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" 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() { define void @bar() {

View File

@ -29,7 +29,7 @@ _main:
# CHECK-NEXT: [[#%x,MAIN:]] g F __TEXT,__text _main # CHECK-NEXT: [[#%x,MAIN:]] g F __TEXT,__text _main
# CHECK-NEXT: [[#%x,NUMBER:]] g O __DATA,__common _number # CHECK-NEXT: [[#%x,NUMBER:]] g O __DATA,__common _number
# CHECK-NEXT: [[#%x,FOO:]] g O __TEXT,obj _foo # 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: # Path: {{.*}}{{/|\\}}map-file.s.tmp/test-map
# CHECK-NEXT: # Arch: x86_64 # CHECK-NEXT: # Arch: x86_64

View File

@ -8,7 +8,7 @@
## Test that in a dylib, we can link against __mh_dylib_header ## Test that in a dylib, we can link against __mh_dylib_header
## (but not in other types of files) ## (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: %lld -pie -dylib %t/dylib.o -o %t/dylib.out
# RUN: llvm-objdump -m --syms %t/dylib.out | FileCheck %s --check-prefix DYLIB # 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 # ERR-DYLIB: error: undefined symbol: __mh_dylib_header
## Test that in an executable, we can link against __mh_execute_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 # 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 ## But it would be an error trying to reference __mh_execute_header in a dylib

View File

@ -9,7 +9,7 @@
; CHECK: <_main>: ; CHECK: <_main>:
; CHECK-NEXT: jmp {{.*}} <_foo> ; 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" 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" module asm ".text"

View File

@ -32,7 +32,7 @@
# NO-OBJC-EMPTY: # NO-OBJC-EMPTY:
# NO-OBJC-NEXT: SYMBOL TABLE: # NO-OBJC-NEXT: SYMBOL TABLE:
# NO-OBJC-NEXT: g F __TEXT,__text _main # 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: # NO-OBJC-EMPTY:
#--- has-objc-symbol.s #--- has-objc-symbol.s

View File

@ -59,12 +59,12 @@
# CHECK-NEXT: Symbol { # CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: __mh_execute_header (81) # CHECK-NEXT: Name: __mh_execute_header (81)
# CHECK-NEXT: Extern # CHECK-NEXT: Extern
# CHECK-NEXT: Type: Abs (0x2) # CHECK-NEXT: Type: Section (0xE)
# CHECK-NEXT: Section: (0x0) # CHECK-NEXT: Section: __text (0x1)
# CHECK-NEXT: RefType: UndefinedNonLazy (0x0) # CHECK-NEXT: RefType: UndefinedNonLazy (0x0)
# CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: Flags [ (0x0)
# CHECK-NEXT: ] # CHECK-NEXT: ]
# CHECK-NEXT: Value: 0x0 # CHECK-NEXT: Value: 0x100000000
# CHECK-NEXT: } # CHECK-NEXT: }
# CHECK-NEXT: Symbol { # CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: dyld_stub_binder # CHECK-NEXT: Name: dyld_stub_binder

View File

@ -33,7 +33,7 @@ _bar:
#--- baz.ll #--- 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" 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() { define void @baz() {

View File

@ -23,9 +23,6 @@
# CHECK-NEXT: 100001000 08100000 01000000 # CHECK-NEXT: 100001000 08100000 01000000
# CHECK: Contents of section __DATA,bar: # CHECK: Contents of section __DATA,bar:
# CHECK-NEXT: 100001008 011000f0 11211111 02000000 # CHECK-NEXT: 100001008 011000f0 11211111 02000000
# CHECK: Rebase table:
# CHECK-NEXT: segment section address type
# CHECK-EMPTY:
# PIE: Rebase table: # PIE: Rebase table:
# PIE-NEXT: segment section address type # PIE-NEXT: segment section address type

View File

@ -21,7 +21,7 @@
# RUN: llvm-objdump --section=__const --full-contents %t | FileCheck %s --check-prefix=NONPCREL # RUN: llvm-objdump --section=__const --full-contents %t | FileCheck %s --check-prefix=NONPCREL
# NONPCREL: Contents of section __DATA,__const: # NONPCREL: Contents of section __DATA,__const:
# NONPCREL-NEXT: 100001000 08040000 01000000 08040000 01000000 # NONPCREL-NEXT: 100001000 18040000 01000000 18040000 01000000
.section __TEXT,__text .section __TEXT,__text
.globl _main, _f .globl _main, _f

View File

@ -1,5 +1,5 @@
# REQUIRES: x86 # 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: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \
# RUN: -o %t/libhello.o # RUN: -o %t/libhello.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \ # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \
@ -12,20 +12,21 @@
# RUN: -o %t/libgoodbye.dylib # RUN: -o %t/libgoodbye.dylib
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/dylink-lazy.o # 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 # RUN: -L%t -lhello -lgoodbye %t/dylink-lazy.o -lSystem
## When looking at the __stubs section alone, we are unable to easily tell which ## 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 ## 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 ## disassembly of __text and the bind tables first, which allow us to check for
## matching entries in __stubs. ## 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 --syms --rebase --bind --lazy-bind %t/dylink-lazy > %t/objdump
# RUN: llvm-objdump -D --no-show-raw-insn %t/dylink-lazy >> %t/objdump # RUN: llvm-objdump -D --no-show-raw-insn %t/dylink-lazy >> %t/objdump
# RUN: FileCheck %s < %t/objdump # RUN: FileCheck %s --check-prefixes=CHECK,PIE < %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
# CHECK-LABEL: SYMBOL TABLE: # CHECK-LABEL: SYMBOL TABLE:
# CHECK: {{0*}}[[#%x, IMGLOADER:]] l {{.*}} __DATA,__data __dyld_private # CHECK: {{0*}}[[#%x, IMGLOADER:]] l {{.*}} __DATA,__data __dyld_private
@ -35,8 +36,13 @@
# CHECK-NEXT: callq 0x[[#%x, GOODBYE_STUB:]] # CHECK-NEXT: callq 0x[[#%x, GOODBYE_STUB:]]
## Check that the rebase table is empty. ## Check that the rebase table is empty.
# CHECK-LABEL: Rebase table: # NO-PIE-LABEL: Rebase table:
# CHECK-NEXT: segment section address type # 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-NEXT: Bind table:
# CHECK: __DATA_CONST __got 0x[[#%x, BINDER:]] pointer 0 libSystem dyld_stub_binder # CHECK: __DATA_CONST __got 0x[[#%x, BINDER:]] pointer 0 libSystem dyld_stub_binder
@ -60,11 +66,6 @@
# CHECK-NEXT: pushq $21 # CHECK-NEXT: pushq $21
# CHECK-NEXT: jmp 0x[[#STUB_HELPER_ENTRY]] # 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 .text
.globl _main .globl _main