# RUN: %lld -arch arm64 -dylib -adhoc_codesign -o %t/empty-arm64-iossimulator.dylib %t/empty-arm64-iossimulator.o
# RUN: %lld -arch x86_64 -dylib -adhoc_codesign -o %t/empty-x86_64-macos.dylib %t/empty-x86_64-macos.o
-# RUN: obj2yaml %t/empty-arm64-macos.dylib | FileCheck %s -D#DATA_OFFSET=16400 -D#DATA_SIZE=304
-# RUN: obj2yaml %t/empty-arm64-iossimulator.dylib | FileCheck %s -D#DATA_OFFSET=16400 -D#DATA_SIZE=304
-# RUN: obj2yaml %t/empty-x86_64-macos.dylib | FileCheck %s -D#DATA_OFFSET=4112 -D#DATA_SIZE=208
+# RUN: obj2yaml %t/empty-arm64-macos.dylib | FileCheck %s -D#DATA_OFFSET=16432 -D#DATA_SIZE=304
+# RUN: obj2yaml %t/empty-arm64-iossimulator.dylib | FileCheck %s -D#DATA_OFFSET=16432 -D#DATA_SIZE=304
+# RUN: obj2yaml %t/empty-x86_64-macos.dylib | FileCheck %s -D#DATA_OFFSET=4144 -D#DATA_SIZE=208
# CHECK: - cmd: LC_CODE_SIGNATURE
# CHECK-NEXT: cmdsize: 16
# CHECK-NEXT: dataoff: [[#DATA_OFFSET]]
# CHECK-NEXT: datasize: [[#DATA_SIZE]]
-# RUN: %python %p/Inputs/code-signature-check.py %t/empty-arm64-macos.dylib 16400 304 0 16400
-# RUN: %python %p/Inputs/code-signature-check.py %t/empty-arm64-iossimulator.dylib 16400 304 0 16400
-# RUN: %python %p/Inputs/code-signature-check.py %t/empty-x86_64-macos.dylib 4112 208 0 4112
+# RUN: %python %p/Inputs/code-signature-check.py %t/empty-arm64-macos.dylib 16432 304 0 16432
+# RUN: %python %p/Inputs/code-signature-check.py %t/empty-arm64-iossimulator.dylib 16432 304 0 16432
+# RUN: %python %p/Inputs/code-signature-check.py %t/empty-x86_64-macos.dylib 4144 208 0 4144
# REQUIRES: arm
# RUN: rm -rf %t; split-file %s %t
+# TODO: Replace %no-lsystem-lld with %lld
+
# RUN: llvm-mc -filetype=obj -triple=armv4t-apple-darwin %t/armv4t-dtrace.s -o %t/armv4t-dtrace.o
-# RUN: %lld -arch armv4t -o %t/armv4t-dtrace %t/armv4t-dtrace.o
+# RUN: %no-lsystem-lld -arch armv4t -o %t/armv4t-dtrace %t/armv4t-dtrace.o
## If references of dtrace symbols are handled by lld, their relocation should be replaced with the following instructions
# RUN: llvm-objdump --macho -D %t/armv4t-dtrace | FileCheck %s --check-prefix=CHECK-armv4t
# CHECK-armv4t: 00 00 a0 e1 mov r0, r0
# RUN: llvm-mc -filetype=obj -triple=thumbv7-apple-darwin %t/armv7-dtrace.s -o %t/armv7-dtrace.o
-# RUN: %lld -arch armv7 -o %t/armv7-dtrace %t/armv7-dtrace.o
+# RUN: %no-lsystem-lld -arch armv7 -o %t/armv7-dtrace %t/armv7-dtrace.o
## If references of dtrace symbols are handled by lld, their relocation should be replaced with the following instructions
# RUN: llvm-objdump --macho -D %t/armv7-dtrace | FileCheck %s --check-prefix=CHECK-armv7
# REQUIRES: aarch64
# RUN: rm -rf %t; split-file %s %t
-# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-darwin %t/arm64-32-dtrace.s -o %t/arm64-32-dtrace.o
-# RUN: %lld -arch arm64_32 -o %t/arm64-32-dtrace %t/arm64-32-dtrace.o
+# RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %t/arm64-32-dtrace.s -o %t/arm64-32-dtrace.o
+# RUN: %lld-watchos -arch arm64_32 -o %t/arm64-32-dtrace %t/arm64-32-dtrace.o
## If references of dtrace symbols are handled by lld, their relocation should be replaced with the following instructions
# RUN: llvm-objdump --macho -D %t/arm64-32-dtrace | FileCheck %s --check-prefix=CHECK
# CHECK32-NEXT: Imm: 1
# CHECK32-NEXT: Symbol: ''
# CHECK32-NEXT: Opcode: BIND_OPCODE_SET_DYLIB_ORDINAL_IMM
-# CHECK32-NEXT: Imm: 1
+# CHECK32-NEXT: Imm: 2
# CHECK32-NEXT: Symbol: ''
# CHECK32-NEXT: Opcode: BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
# CHECK32-NEXT: Imm: 1
# UNWIND-NEXT: l O __DATA,__data __dyld_private
# UNWIND-NEXT: g F __TEXT,__text _main
# UNWIND-NEXT: g F __TEXT,__text __mh_execute_header
+# UNWIND-NEXT: *UND* dyld_stub_binder
# UNWIND-NEXT: *UND* ___cxa_allocate_exception
# UNWIND-NEXT: *UND* ___cxa_end_catch
# UNWIND-NEXT: *UND* __ZTIi
# UNWIND-NEXT: *UND* ___cxa_throw
# UNWIND-NEXT: *UND* ___gxx_personality_v0
# UNWIND-NEXT: *UND* ___cxa_begin_catch
-# UNWIND-NEXT: *UND* dyld_stub_binder
# UNWIND-NOT: GCC_except_table0
## If a dead stripped function has a strong ref to a dylib symbol but
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/test.s -o %t/test.o
## Dylibs that don't do lazy dynamic calls don't need dyld_stub_binder.
-# RUN: %lld -arch arm64 -dylib %t/foo.o -o %t/libfoo.dylib
+# RUN: %no-lsystem-lld -arch arm64 -dylib %t/foo.o -o %t/libfoo.dylib
# RUN: llvm-nm -m %t/libfoo.dylib | FileCheck --check-prefix=NOSTUB %s
## Binaries that don't do lazy dynamic calls but are linked against
## Dylibs that do lazy dynamic calls do need dyld_stub_binder.
-# RUN: not %lld -arch arm64 -dylib %t/bar.o %t/libfoo.dylib \
+# RUN: not %no-lsystem-lld -arch arm64 -dylib %t/bar.o %t/libfoo.dylib \
# RUN: -o %t/libbar.dylib 2>&1 | FileCheck --check-prefix=MISSINGSTUB %s
# RUN: %lld -arch arm64 -lSystem -dylib %t/bar.o %t/libfoo.dylib \
# RUN: -o %t/libbar.dylib
# RUN: llvm-nm -m %t/libbar.dylib | FileCheck --check-prefix=STUB %s
## As do executables.
-# RUN: not %lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
+# RUN: not %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test 2>&1 | FileCheck --check-prefix=MISSINGSTUB %s
# RUN: %lld -arch arm64 -lSystem %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test
# RUN: llvm-nm -m %t/test | FileCheck --check-prefix=STUB %s
## Test dynamic lookup of dyld_stub_binder.
-# RUN: %lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
+# RUN: %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test -undefined dynamic_lookup
# RUN: llvm-nm -m %t/test | FileCheck --check-prefix=DYNSTUB %s
-# RUN: %lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
+# RUN: %no-lsystem-lld -arch arm64 %t/libfoo.dylib %t/libbar.dylib %t/test.o \
# RUN: -o %t/test -U dyld_stub_binder
# RUN: llvm-nm -m %t/test | FileCheck --check-prefix=DYNSTUB %s
# LOAD: cmd LC_LOAD_DYLIB
# LOAD-NEXT: cmdsize
+# LOAD-NEXT: name /usr/lib/libSystem.dylib
+# LOAD: cmd LC_LOAD_DYLIB
+# LOAD-NEXT: cmdsize
# LOAD-NEXT: name @executable_path/libhello.dylib
# LOAD-NEXT: time stamp
# LOAD-NEXT: current version 11.0.0
# PADx-NEXT: offset [[#%u, CMDSIZE + 0x20 + 0x20]]
################ Zero pad, no LCDylibs
-# RUN: %lld -o %t/test %t/test.o -headerpad 0
+# RUN: %no-lsystem-lld -o %t/test %t/test.o -headerpad 0
# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s --check-prefix=PAD0
-# RUN: %lld -o %t/test %t/test.o -headerpad 0 -headerpad_max_install_names
+# RUN: %no-lsystem-lld -o %t/test %t/test.o -headerpad 0 -headerpad_max_install_names
# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s --check-prefix=PAD0
#
# PAD0: magic {{.+}} ncmds sizeofcmds flags
# PAD0-NEXT: offset [[#%u, CMDSIZE + 0x20 + 0]]
################ Each lexical form of a hex number, no LCDylibs
-# RUN: %lld -o %t/test %t/test.o -headerpad 11
+# RUN: %no-lsystem-lld -o %t/test %t/test.o -headerpad 11
# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s --check-prefix=PAD11
-# RUN: %lld -o %t/test %t/test.o -headerpad 0x11
+# RUN: %no-lsystem-lld -o %t/test %t/test.o -headerpad 0x11
# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s --check-prefix=PAD11
-# RUN: %lld -o %t/test %t/test.o -headerpad 0X11 -headerpad_max_install_names
+# RUN: %no-lsystem-lld -o %t/test %t/test.o -headerpad 0X11 -headerpad_max_install_names
# RUN: llvm-objdump --macho --all-headers %t/test | FileCheck %s --check-prefix=PAD11
#
# PAD11: magic {{.+}} ncmds sizeofcmds flags
;; which needs -lSystem from LC_LINKER_OPTION to get resolved.
;; The reference to __cxa_allocate_exception will require -lc++ from
;; LC_LINKER_OPTION to get resolved.
-; RUN: %lld %t/l.o -o %t/l -framework CoreFoundation
+; RUN: %no-lsystem-lld %t/l.o -o %t/l -framework CoreFoundation
; RUN: llvm-otool -l %t/l | FileCheck --check-prefix=LIB %s \
; RUN: --implicit-check-not LC_LOAD_DYLIB
; LIB: cmd LC_LOAD_DYLIB
; LIB-NEXT: name /usr/lib/libc++abi.dylib
;; Check that we don't create duplicate LC_LOAD_DYLIBs.
-; RUN: %lld -lSystem %t/l.o -o %t/l -framework CoreFoundation
+; RUN: %no-lsystem-lld -lSystem %t/l.o -o %t/l -framework CoreFoundation
; RUN: llvm-otool -l %t/l | FileCheck --check-prefix=LIB2 %s \
; RUN: --implicit-check-not LC_LOAD_DYLIB
; LIB2: cmd LC_LOAD_DYLIB
; SYMS: SYMBOL TABLE:
; SYMS-NEXT: g F __TEXT,__text _main
; SYMS-NEXT: g F __TEXT,__text __mh_execute_header
+; SYMS-NEXT: *UND* dyld_stub_binder
; SYMS-EMPTY:
;; Make sure -all_load has effect when libraries are loaded via LC_LINKER_OPTION flags and explicitly passed as well
; SYMS_ALL_LOAD-NEXT: g F __TEXT,__text _main
; SYMS_ALL_LOAD-NEXT: g O __DATA,__objc_data _OBJC_CLASS_$_TestClass
; SYMS_ALL_LOAD-NEXT: g F __TEXT,__text __mh_execute_header
+; SYMS_ALL_LOAD-NEXT: *UND* dyld_stub_binder
; SYMS_ALL_LOAD-EMPTY:
;; Make sure -force_load has effect when libraries are loaded via LC_LINKER_OPTION flags and explicitly passed as well
; SYMS_FORCE_LOAD-NEXT: g F __TEXT,__text _main
; SYMS_FORCE_LOAD-NEXT: g O __DATA,__objc_data _OBJC_CLASS_$_TestClass
; SYMS_FORCE_LOAD-NEXT: g F __TEXT,__text __mh_execute_header
+; SYMS_FORCE_LOAD-NEXT: *UND* dyld_stub_binder
; SYMS_FORCE_LOAD-EMPTY:
;; Make sure -ObjC has effect when frameworks are loaded via LC_LINKER_OPTION flags and explicitly passed as well
; SYMS_OBJC_LOAD-NEXT: g F __TEXT,__text _main
; SYMS_OBJC_LOAD-NEXT: g O __DATA,__objc_data _OBJC_CLASS_$_TestClass
; SYMS_OBJC_LOAD-NEXT: g F __TEXT,__text __mh_execute_header
+; SYMS_OBJC_LOAD-NEXT: *UND* dyld_stub_binder
; SYMS_OBJC_LOAD-EMPTY:
;; Make sure that frameworks containing object files or bitcode instead of
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
################ default, which is the same as -search_paths_first
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tA -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o \
# RUN: --print-dylib-search | FileCheck --check-prefix=ARCHIVESEARCH -DPATH=%t %s
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s
################ Test all permutations of -L%t{A,D} with -search_paths_first
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tA -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tD -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_paths_first
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s
################ Test all permutations of -L%t{A,D} with -search_dylibs_first
-# RUN: env RC_TRACE_DYLIB_SEARCHING=1 %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: env RC_TRACE_DYLIB_SEARCHING=1 %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tA -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first \
# RUN: | FileCheck --check-prefix=DYLIBSEARCH -DPATH=%t %s
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tD -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tA -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=ARCHIVE %s
-# RUN: %lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
+# RUN: %no-lsystem-lld -L%S/Inputs/MacOSX.sdk/usr/lib -o %t/test -Z \
# RUN: -L%tD -L%t -lhello -lgoodbye -lSystem %t/test.o -search_dylibs_first
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck --check-prefix=DYLIB %s
# flag will append to the set of library roots. As such, we define a separate
# alias for each platform.
-lld_watchos = ('ld64.lld -arch arm64_32 -platform_version watchos 7.0 8.0 -syslibroot ' +
+lld_watchos = ('ld64.lld -lSystem -arch arm64_32 -platform_version watchos 7.0 8.0 -syslibroot ' +
os.path.join(config.test_source_root, "MachO", "Inputs", "WatchOS.sdk"))
config.substitutions.append(('%lld-watchos', lld_watchos + ' -fatal_warnings'))
config.substitutions.append(('%no-fatal-warnings-lld-watchos', lld_watchos))
# shortest substitution of "%lld".
lld = ('ld64.lld -arch x86_64 -platform_version macos 11.0 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))
+config.substitutions.append(('%lld', lld + ' -lSystem -fatal_warnings'))
+config.substitutions.append(('%no-lsystem-lld', lld + ' -fatal_warnings'))
+config.substitutions.append(('%no-fatal-warnings-lld', lld + ' -lSystem'))
# RUN: llvm-nm %t/strip_all_export_one.out | FileCheck --check-prefix STRIP-EXP %s
# STRIP-EXP: U _foo
+# STRIP-EXP: U dyld_stub_binder
# STRIP-EXP-EMPTY:
## Test interactions of -x and -non_global_symbols_strip_list with unexported_symbol.
## -unexported_symbol made _globby a local, therefore it should be stripped by -x too
# STRIP-UNEXP: T __mh_execute_header
# STRIP-UNEXP-DAG: T _main
+# STRIP-UNEXP-DAG: U dyld_stub_binder
# STRIP-UNEXP-EMPTY:
## Test interactions of -non_global_symbols_strip_list and unexported_symbol.
# NOSTRIP-UNEXP: T __mh_execute_header
# NOSTRIP-UNEXP-DAG: T _main
# NOSTRIP-UNEXP-DAG: t _globby
+# NOSTRIP-UNEXP-DAG: U dyld_stub_binder
# NOSTRIP-UNEXP-EMPTY:
#--- foo.txt
ret
_globby:
- ret
\ No newline at end of file
+ ret
# CHECK-NEXT: [[#%x,NUMBER:]] g O __DATA,__common _number
# CHECK-NEXT: [[#%x,FOO:]] g O __TEXT,obj _foo
# CHECK-NEXT: [[#%x,HEADER:]] g F __TEXT,__text __mh_execute_header
+# CHECK-NEXT: [[#%x,HEADER:]] *UND* dyld_stub_binder
# CHECK-NEXT: # Path: {{.*}}{{/|\\}}map-file.s.tmp/test-map
# CHECK-NEXT: # Arch: x86_64
RUN: rm -rf %t1 %t2; mkdir -p %t1 %t2
-RUN: %lld -v -dylib -o /dev/null -L%t1 -F%t2 2>&1 \
+RUN: %no-lsystem-lld -v -dylib -o /dev/null -L%t1 -F%t2 2>&1 \
RUN: | FileCheck -DLDIR=%t1 -DFDIR=%t2 %s
CHECK: Library search paths:
CHECK-NEXT: [[LDIR]]
CHECK-NEXT: [[FDIR]]
CHECK-NEXT: /System/Library/Frameworks
-RUN: %lld -v -dylib -o /dev/null -L%t1 -F%t2 -Z 2>&1 \
+RUN: %no-lsystem-lld -v -dylib -o /dev/null -L%t1 -F%t2 -Z 2>&1 \
RUN: | FileCheck -DLDIR=%t1 -DFDIR=%t2 --check-prefix=CHECK_Z %s
CHECK_Z: Library search paths:
CHECK_Z-NEXT: [[LDIR]]