99 changes: 99 additions & 0 deletions lld/test/MachO/invalid/invalid-relocation-length.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# REQUIRES: x86
# RUN: yaml2obj %s -o %t.o
# RUN: not lld -flavor darwinnew -arch x86_64 -o %t %t.o 2>&1 | FileCheck %s -DFILE=%t.o
#
# CHECK: error: invalid relocation at offset 1 of __TEXT,__text in [[FILE]]: relocations of type 0 must have r_length of 2 or 3

!mach-o
FileHeader:
magic: 0xFEEDFACF
cputype: 0x01000007
cpusubtype: 0x00000003
filetype: 0x00000001
ncmds: 4
sizeofcmds: 280
flags: 0x00000000
reserved: 0x00000000
LoadCommands:
- cmd: LC_SEGMENT_64
cmdsize: 152
segname: ''
vmaddr: 0
vmsize: 9
fileoff: 312
filesize: 9
maxprot: 7
initprot: 7
nsects: 1
flags: 0
Sections:
- sectname: __text
segname: __TEXT
addr: 0x0000000000000000
size: 9
offset: 0x00000138
align: 0
reloff: 0x00000144
nreloc: 1
flags: 0x80000000
reserved1: 0x00000000
reserved2: 0x00000000
reserved3: 0x00000000
content: '000000000000000000'
relocations:
- address: 0x00000001
symbolnum: 1
pcrel: false
length: 1
extern: true
type: 0
scattered: false
value: 0
- cmd: LC_BUILD_VERSION
cmdsize: 24
platform: 1
minos: 659200
sdk: 0
ntools: 0
- cmd: LC_SYMTAB
cmdsize: 24
symoff: 332
nsyms: 2
stroff: 364
strsize: 12
- cmd: LC_DYSYMTAB
cmdsize: 80
ilocalsym: 0
nlocalsym: 0
iextdefsym: 0
nextdefsym: 2
iundefsym: 2
nundefsym: 0
tocoff: 0
ntoc: 0
modtaboff: 0
nmodtab: 0
extrefsymoff: 0
nextrefsyms: 0
indirectsymoff: 0
nindirectsyms: 0
extreloff: 0
nextrel: 0
locreloff: 0
nlocrel: 0
LinkEditData:
NameList:
- n_strx: 1
n_type: 0x0F
n_sect: 1
n_desc: 0
n_value: 1
- n_strx: 6
n_type: 0x0F
n_sect: 1
n_desc: 0
n_value: 9
StringTable:
- ''
- _foo
- _main
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: yaml2obj %s -o %t.o
# RUN: not lld -flavor darwinnew -arch x86_64 -o %t %t.o 2>&1 | FileCheck %s -DFILE=%t.o
# RUN: not lld -flavor darwinnew -o %t %t.o 2>&1 | FileCheck %s -DFILE=%t.o
#
# CHECK: error: invalid relocation at offset 1 of __TEXT,__text in [[FILE]]: relocations of type 0 must not be pcrel

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/missing-dylib.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: not lld -flavor darwinnew -arch x86_64 -Z -o %t -lmissing %t.o 2>&1 | FileCheck %s
# RUN: not lld -flavor darwinnew -Z -o %t -lmissing %t.o 2>&1 | FileCheck %s

# CHECK: error: library not found for -lmissing
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/no-id-dylink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# RUN: mkdir -p %t
# RUN: yaml2obj %s -o %t/libnoid.dylib
# RUN: echo ".globl _main; .text; _main: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/no-id-dylink.o
# RUN: not lld -flavor darwinnew -arch x86_64 -o %t/no-id-dylink -Z -L%t -lnoid %t/no-id-dylink.o 2>&1 | FileCheck %s
# RUN: not lld -flavor darwinnew -o %t/no-id-dylink -Z -L%t -lnoid %t/no-id-dylink.o 2>&1 | FileCheck %s
# CHECK: error: dylib {{.*}}libnoid.dylib missing LC_ID_DYLIB load command

## This YAML file was originally generated from linking the following source
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/no-such-file.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# REQUIRES: x86
# RUN: not lld -flavor darwinnew -arch x86_64 -o /dev/null %t-no-such-file.o 2>&1 | FileCheck %s
# RUN: not lld -flavor darwinnew -o /dev/null %t-no-such-file.o 2>&1 | FileCheck %s

# CHECK: error: cannot open {{.*}}no-such-file.o
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/order-file-bad-arch.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: echo ".globl _main; .text; _main: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t.o
# RUN: not lld -flavor darwinnew -arch x86_64 -o %t %t.o -order_file %s 2>&1 | FileCheck %s
# RUN: not lld -flavor darwinnew -o %t %t.o -order_file %s 2>&1 | FileCheck %s
# CHECK: error: invalid arch "sparc" in order file: expected one of arm, arm64, i386, x86_64, ppc, ppc64
# CHECK-EMPTY:

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/order-file-bad-objfile.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: echo ".globl _main; .text; _main: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t.o
# RUN: not lld -flavor darwinnew -arch x86_64 -o %t %t.o -order_file %s 2>&1 | FileCheck %s
# RUN: not lld -flavor darwinnew -o %t %t.o -order_file %s 2>&1 | FileCheck %s
# CHECK: invalid object file name "helloo" in order file: should end with .o
# CHECK: invalid object file name "z80" in order file: should end with .o
# CHECK-EMPTY:
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/stub-link.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: mkdir -p %t
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-ios %s -o %t/test.o
# RUN: not lld -flavor darwinnew -arch x86_64 -o %t/test -Z -L%S/../Inputs/iPhoneSimulator.sdk/usr/lib -lSystem %t/test.o 2>&1 | FileCheck %s
# RUN: not lld -flavor darwinnew -o %t/test -Z -L%S/../Inputs/iPhoneSimulator.sdk/usr/lib -lSystem %t/test.o 2>&1 | FileCheck %s

# CHECK: error: undefined symbol __cache_handle_memory_pressure_event

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/invalid/undefined-symbol.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: not lld -flavor darwinnew -arch x86_64 -Z -o %t %t.o 2>&1 | FileCheck %s -DBASENAME=%basename_t
# RUN: not lld -flavor darwinnew -Z -o %t %t.o 2>&1 | FileCheck %s -DBASENAME=%basename_t
# CHECK: error: undefined symbol _foo, referenced from [[BASENAME]]

.globl _main
Expand Down
6 changes: 3 additions & 3 deletions lld/test/MachO/link-search-order.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
# RUN: mkdir -p %t
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %p/Inputs/libhello.s -o %t/hello.o
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -install_name @executable_path/libhello.dylib %t/hello.o -o %t/libhello.dylib
# RUN: lld -flavor darwinnew -dylib -install_name @executable_path/libhello.dylib %t/hello.o -o %t/libhello.dylib
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %p/Inputs/libgoodbye.s -o %t/goodbye.o
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -install_name @executable_path/libgoodbye.dylib %t/goodbye.o -o %t/libgoodbye.dylib
# RUN: lld -flavor darwinnew -dylib -install_name @executable_path/libgoodbye.dylib %t/goodbye.o -o %t/libgoodbye.dylib
# RUN: llvm-ar --format=darwin crs %t/libgoodbye.a %t/goodbye.o
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test -Z -L%t -lhello -lgoodbye %t/test.o
# RUN: lld -flavor darwinnew -o %t/test -Z -L%t -lhello -lgoodbye %t/test.o
#
# RUN: llvm-objdump --macho --dylibs-used %t/test | FileCheck %s

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/load-commands.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t %t.o
# RUN: lld -flavor darwinnew -o %t %t.o

## Check for the presence of load commands that are essential for a working
## executable.
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/no-exports-dylib.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -dylib %t.o -o %t.dylib
# RUN: lld -flavor darwinnew -dylib %t.o -o %t.dylib

# RUN: obj2yaml %t.dylib | FileCheck %s
# CHECK: export_size: 0
56 changes: 28 additions & 28 deletions lld/test/MachO/order-file.s
Original file line number Diff line number Diff line change
Expand Up @@ -14,67 +14,67 @@

# RUN: echo "_foo # just a comment" > %t/ord-1
# RUN: echo "_main # another comment" >> %t/ord-1
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-1
# RUN: lld -flavor darwinnew -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-1
# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST
## Output should be the same regardless of the command-line order of object files
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-1
# RUN: lld -flavor darwinnew -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-1
# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST

# RUN: echo "_main # just a comment" > %t/ord-2
# RUN: echo "_foo # another comment" >> %t/ord-2
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-2
# RUN: lld -flavor darwinnew -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-2
# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-SECOND
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-2
# RUN: lld -flavor darwinnew -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-2
# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-SECOND

# RUN: echo "foo.o:_foo" > %t/ord-file-match
# RUN: echo "_main" >> %t/ord-file-match
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-file-match %t/test.o %t/foo.o -order_file %t/ord-file-match
# RUN: lld -flavor darwinnew -o %t/test-file-match %t/test.o %t/foo.o -order_file %t/ord-file-match
# RUN: llvm-objdump -d %t/test-file-match | FileCheck %s --check-prefix=FOO-FIRST
## Output should be the same regardless of the command-line order of object files
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-file-match %t/foo.o %t/test.o -order_file %t/ord-file-match
# RUN: lld -flavor darwinnew -o %t/test-file-match %t/foo.o %t/test.o -order_file %t/ord-file-match
# RUN: llvm-objdump -d %t/test-file-match | FileCheck %s --check-prefix=FOO-FIRST

# RUN: echo "bar.o:_foo" > %t/ord-file-nomatch
# RUN: echo "_main" >> %t/ord-file-nomatch
# RUN: echo "_foo" >> %t/ord-file-nomatch
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-file-nomatch %t/test.o %t/foo.o -order_file %t/ord-file-nomatch
# RUN: lld -flavor darwinnew -o %t/test-file-nomatch %t/test.o %t/foo.o -order_file %t/ord-file-nomatch
# RUN: llvm-objdump -d %t/test-file-nomatch | FileCheck %s --check-prefix=FOO-SECOND
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-file-nomatch %t/foo.o %t/test.o -order_file %t/ord-file-nomatch
# RUN: lld -flavor darwinnew -o %t/test-file-nomatch %t/foo.o %t/test.o -order_file %t/ord-file-nomatch
# RUN: llvm-objdump -d %t/test-file-nomatch | FileCheck %s --check-prefix=FOO-SECOND

# RUN: echo "x86_64:_foo" > %t/ord-arch-match
# RUN: echo "_main" >> %t/ord-arch-match
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match
# RUN: lld -flavor darwinnew -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match
# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match
# RUN: lld -flavor darwinnew -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match
# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST

# RUN: echo "ppc:_foo" > %t/ord-arch-nomatch
# RUN: echo "_main" >> %t/ord-arch-nomatch
# RUN: echo "_foo" >> %t/ord-arch-nomatch
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-arch-nomatch %t/test.o %t/foo.o -order_file %t/ord-arch-nomatch
# RUN: lld -flavor darwinnew -o %t/test-arch-nomatch %t/test.o %t/foo.o -order_file %t/ord-arch-nomatch
# RUN: llvm-objdump -d %t/test-arch-nomatch | FileCheck %s --check-prefix=FOO-SECOND
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-arch-nomatch %t/foo.o %t/test.o -order_file %t/ord-arch-nomatch
# RUN: lld -flavor darwinnew -o %t/test-arch-nomatch %t/foo.o %t/test.o -order_file %t/ord-arch-nomatch
# RUN: llvm-objdump -d %t/test-arch-nomatch | FileCheck %s --check-prefix=FOO-SECOND

# RUN: echo "x86_64:bar.o:_foo" > %t/ord-arch-file-match
# RUN: echo "_main" >> %t/ord-arch-match
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match
# RUN: lld -flavor darwinnew -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match
# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match
# RUN: lld -flavor darwinnew -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match
# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST

## Test archives

# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-archive-1 %t/test.o %t/foo.a -order_file %t/ord-1
# RUN: lld -flavor darwinnew -o %t/test-archive-1 %t/test.o %t/foo.a -order_file %t/ord-1
# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-archive-1 %t/foo.a %t/test.o -order_file %t/ord-1
# RUN: lld -flavor darwinnew -o %t/test-archive-1 %t/foo.a %t/test.o -order_file %t/ord-1
# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST

# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-archive-file-no-match %t/test.o %t/foo.a -order_file %t/ord-file-nomatch
# RUN: lld -flavor darwinnew -o %t/test-archive-file-no-match %t/test.o %t/foo.a -order_file %t/ord-file-nomatch
# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-archive %t/foo.a %t/test.o -order_file %t/ord-file-nomatch
# RUN: lld -flavor darwinnew -o %t/test-archive %t/foo.a %t/test.o -order_file %t/ord-file-nomatch
# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND

## The following tests check that if an address is matched by multiple order
Expand All @@ -83,33 +83,33 @@
# RUN: echo "_foo" > %t/ord-multiple-1
# RUN: echo "_main" >> %t/ord-multiple-1
# RUN: echo "foo.o:_foo" >> %t/ord-multiple-1
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-multiple-1
# RUN: lld -flavor darwinnew -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-multiple-1
# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-multiple-1
# RUN: lld -flavor darwinnew -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-multiple-1
# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST

# RUN: echo "foo.o:_foo" > %t/ord-multiple-2
# RUN: echo "_main" >> %t/ord-multiple-2
# RUN: echo "_foo" >> %t/ord-multiple-2
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-multiple-2
# RUN: lld -flavor darwinnew -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-multiple-2
# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-multiple-2
# RUN: lld -flavor darwinnew -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-multiple-2
# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-FIRST

# RUN: echo "_foo" > %t/ord-multiple-3
# RUN: echo "_main" >> %t/ord-multiple-3
# RUN: echo "_foo" >> %t/ord-multiple-3
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-3 %t/test.o %t/foo.o -order_file %t/ord-multiple-3
# RUN: lld -flavor darwinnew -o %t/test-3 %t/test.o %t/foo.o -order_file %t/ord-multiple-3
# RUN: llvm-objdump -d %t/test-3 | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-3 %t/foo.o %t/test.o -order_file %t/ord-multiple-3
# RUN: lld -flavor darwinnew -o %t/test-3 %t/foo.o %t/test.o -order_file %t/ord-multiple-3
# RUN: llvm-objdump -d %t/test-3 | FileCheck %s --check-prefix=FOO-FIRST

# RUN: echo "foo.o:_foo" > %t/ord-multiple-4
# RUN: echo "_main" >> %t/ord-multiple-4
# RUN: echo "foo.o:_foo" >> %t/ord-multiple-4
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-4 %t/test.o %t/foo.o -order_file %t/ord-multiple-4
# RUN: lld -flavor darwinnew -o %t/test-4 %t/test.o %t/foo.o -order_file %t/ord-multiple-4
# RUN: llvm-objdump -d %t/test-4 | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-4 %t/foo.o %t/test.o -order_file %t/ord-multiple-4
# RUN: lld -flavor darwinnew -o %t/test-4 %t/foo.o %t/test.o -order_file %t/ord-multiple-4
# RUN: llvm-objdump -d %t/test-4 | FileCheck %s --check-prefix=FOO-FIRST

## _foo and _bar both point to the same location. When both symbols appear in
Expand All @@ -118,9 +118,9 @@
# RUN: echo "_bar" > %t/ord-alias
# RUN: echo "_main" >> %t/ord-alias
# RUN: echo "_foo" >> %t/ord-alias
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-alias %t/test.o %t/foo.o -order_file %t/ord-alias
# RUN: lld -flavor darwinnew -o %t/test-alias %t/test.o %t/foo.o -order_file %t/ord-alias
# RUN: llvm-objdump -d %t/test-alias | FileCheck %s --check-prefix=FOO-FIRST
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-alias %t/foo.o %t/test.o -order_file %t/ord-alias
# RUN: lld -flavor darwinnew -o %t/test-alias %t/foo.o %t/test.o -order_file %t/ord-alias
# RUN: llvm-objdump -d %t/test-alias | FileCheck %s --check-prefix=FOO-FIRST

.text
Expand Down
12 changes: 6 additions & 6 deletions lld/test/MachO/platform-version.test
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# RUN: not lld -flavor darwinnew -arch x86_64 -platform_version 2>&1 \
# RUN: not lld -flavor darwinnew -platform_version 2>&1 \
# RUN: | FileCheck --check-prefix=FAIL %s
# RUN: not lld -flavor darwinnew -arch x86_64 -platform_version macos 2>&1 \
# RUN: not lld -flavor darwinnew -platform_version macos 2>&1 \
# RUN: | FileCheck --check-prefix=FAIL %s
# RUN: not lld -flavor darwinnew -arch x86_64 -platform_version macos 10.15 2>&1 \
# RUN: not lld -flavor darwinnew -platform_version macos 10.15 2>&1 \
# RUN: | FileCheck --check-prefix=FAIL %s
# RUN: not lld -flavor darwinnew -arch x86_64 -platform_version macos -lfoo 10.15 2>&1 \
# RUN: not lld -flavor darwinnew -platform_version macos -lfoo 10.15 2>&1 \
# RUN: | FileCheck --check-prefix=FAIL %s
# RUN: not lld -flavor darwinnew -arch x86_64 -platform_version macos 10.15 10.15.4 2>&1 \
# RUN: not lld -flavor darwinnew -platform_version macos 10.15 10.15.4 2>&1 \
# RUN: | FileCheck --check-prefix=GOOD %s
# RUN: not lld -flavor darwinnew -arch x86_64 -platform_version macos 10.15 10.15.4 foobar 2>&1 \
# RUN: not lld -flavor darwinnew -platform_version macos 10.15 10.15.4 foobar 2>&1 \
# RUN: | FileCheck --check-prefix=FAIL_FILE %s

FAIL: usage: -platform_version platform min_version sdk_version
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/relocations.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t %t.o
# RUN: lld -flavor darwinnew -o %t %t.o
# RUN: llvm-objdump --section-headers --syms -d %t | FileCheck %s

# CHECK-LABEL: Sections:
Expand Down
10 changes: 5 additions & 5 deletions lld/test/MachO/resolution.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
# RUN: mkdir -p %t
# RUN: echo '.globl _foo, _bar, _baz; _foo: _bar: _baz:' | \
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/libresolution.o
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -install_name \
# RUN: lld -flavor darwinnew -dylib -install_name \
# RUN: @executable_path/libresolution.dylib %t/libresolution.o -o %t/libresolution.dylib
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -install_name \
# RUN: lld -flavor darwinnew -dylib -install_name \
# RUN: @executable_path/libresolution2.dylib %t/libresolution.o -o %t/libresolution2.dylib
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/resolution.o

## Check that we select the symbol defined in the first dylib passed on the
## command line.
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/dylib-first -Z -L%t -lresolution -lresolution2 %t/resolution.o
# RUN: lld -flavor darwinnew -o %t/dylib-first -Z -L%t -lresolution -lresolution2 %t/resolution.o
# RUN: llvm-objdump --macho --bind %t/dylib-first | FileCheck %s --check-prefix=DYLIB-FIRST
# DYLIB-FIRST: libresolution _foo

# RUN: lld -flavor darwinnew -arch x86_64 -o %t/dylib2-first -Z -L%t -lresolution2 -lresolution %t/resolution.o
# RUN: lld -flavor darwinnew -o %t/dylib2-first -Z -L%t -lresolution2 -lresolution %t/resolution.o
# RUN: llvm-objdump --macho --bind %t/dylib2-first | FileCheck %s --check-prefix=DYLIB2-FIRST
# DYLIB2-FIRST: libresolution2 _foo

Expand All @@ -24,7 +24,7 @@

## Check that we pick the dylib symbol over the undefined symbol in the object
## file, even if the object file appears first on the command line.
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/obj-first -Z -L%t %t/resolution.o -lresolution
# RUN: lld -flavor darwinnew -o %t/obj-first -Z -L%t %t/resolution.o -lresolution
# RUN: llvm-objdump --macho --bind %t/obj-first | FileCheck %s --check-prefix=OBJ-FIRST
# OBJ-FIRST: libresolution _foo
## But defined symbols should still take precedence.
Expand Down
4 changes: 2 additions & 2 deletions lld/test/MachO/search-paths.test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
RUN: mkdir -p %t

RUN: lld -flavor darwinnew -arch x86_64 -v -L%t 2>&1 | FileCheck -DDIR=%t %s
RUN: lld -flavor darwinnew -v -L%t 2>&1 | FileCheck -DDIR=%t %s
CHECK: Library search paths:
CHECK-NEXT: [[DIR]]
CHECK-NEXT: /usr/lib
CHECK-NEXT: /usr/local/lib

RUN: lld -flavor darwinnew -arch x86_64 -v -L%t -Z 2>&1 | FileCheck -DDIR=%t --check-prefix=CHECK_Z %s
RUN: lld -flavor darwinnew -v -L%t -Z 2>&1 | FileCheck -DDIR=%t --check-prefix=CHECK_Z %s
CHECK_Z: Library search paths:
CHECK_Z-NEXT: [[DIR]]
CHECK_Z-NOT: /usr/
2 changes: 1 addition & 1 deletion lld/test/MachO/section-headers.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t %t.o
# RUN: lld -flavor darwinnew -o %t %t.o
# RUN: llvm-readobj --section-headers %t | FileCheck %s

# CHECK: Name: __text
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/section-merge.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# RUN: -o %t/libfunction.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s \
# RUN: -o %t/main.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/output %t/libfunction.o %t/libgoodbye.o %t/libhello.o %t/main.o
# RUN: lld -flavor darwinnew -o %t/output %t/libfunction.o %t/libgoodbye.o %t/libhello.o %t/main.o

# RUN: llvm-objdump --syms %t/output | FileCheck %s
# CHECK: SYMBOL TABLE:
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/segments.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t %t.o
# RUN: lld -flavor darwinnew -o %t %t.o
# RUN: llvm-readobj --macho-segment %t | FileCheck %s

## These two segments must always be present at the start of an executable.
Expand Down
4 changes: 2 additions & 2 deletions lld/test/MachO/silent-ignore.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
RUN: lld -flavor darwinnew -arch x86_64 -v \
RUN: lld -flavor darwinnew -v \
RUN: -demangle \
RUN: -dynamic \
RUN: -no_deduplicate \
RUN: -lto_library /lib/foo \
RUN: -macosx_version_min 0 \
RUN: -syslibroot /path/to/MacOSX.platform/Developer/SDKs/MacOSX.sdk
RUN: not lld -flavor darwinnew -arch x86_64 -v --not-an-ignored-argument 2>&1 | FileCheck %s
RUN: not lld -flavor darwinnew -v --not-an-ignored-argument 2>&1 | FileCheck %s
CHECK: error: unknown argument: --not-an-ignored-argument
2 changes: 1 addition & 1 deletion lld/test/MachO/static-link.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# RUN: llvm-ar --format=darwin crs %t/libgoodbye.a %t/goodbye.o
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test -Z -L%t -lgoodbye %t/test.o
# RUN: lld -flavor darwinnew -o %t/test -Z -L%t -lgoodbye %t/test.o
#
# RUN: llvm-objdump --syms -d -r %t/test | FileCheck %s

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/stub-link.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: mkdir -p %t
#
# RUN: llvm-mc -filetype obj -triple x86_64-apple-darwin %s -o %t/test.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test -Z -L%S/Inputs/MacOSX.sdk/usr/lib -lSystem %t/test.o
# RUN: lld -flavor darwinnew -o %t/test -Z -L%S/Inputs/MacOSX.sdk/usr/lib -lSystem %t/test.o
#
# RUN: llvm-objdump --bind --no-show-raw-insn -d -r %t/test | FileCheck %s

Expand Down
12 changes: 6 additions & 6 deletions lld/test/MachO/sub-library.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \
# RUN: -o %t/libgoodbye.o
# RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/libsuper.o
# RUN: lld -flavor darwinnew -arch x86_64 -dylib %t/libhello.o -o %t/libhello.dylib
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -L%t -sub_library libhello -lhello \
# RUN: lld -flavor darwinnew -dylib %t/libhello.o -o %t/libhello.dylib
# RUN: lld -flavor darwinnew -dylib -L%t -sub_library libhello -lhello \
# RUN: %t/libgoodbye.o -o %t/libgoodbye.dylib
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -L%t -sub_library libgoodbye -lgoodbye -install_name \
# RUN: lld -flavor darwinnew -dylib -L%t -sub_library libgoodbye -lgoodbye -install_name \
# RUN: @executable_path/libsuper.dylib %t/libsuper.o -o %t/libsuper.dylib


Expand All @@ -37,7 +37,7 @@
# SUPER-HEADERS: name [[DIR]]/libgoodbye.dylib

# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/sub-library.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/sub-library -L%t -lsuper %t/sub-library.o
# RUN: lld -flavor darwinnew -o %t/sub-library -L%t -lsuper %t/sub-library.o

# RUN: llvm-objdump --macho --bind %t/sub-library | FileCheck %s
# CHECK-LABEL: Bind table:
Expand All @@ -46,11 +46,11 @@


## Check that we fail gracefully if the sub-library is missing
# RUN: not lld -flavor darwinnew -arch x86_64 -dylib -Z -o %t/sub-library -sub_library libmissing %t/sub-library.o 2>&1 \
# RUN: not lld -flavor darwinnew -dylib -Z -o %t/sub-library -sub_library libmissing %t/sub-library.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=MISSING-SUB-LIBRARY
# MISSING-SUB-LIBRARY: error: -sub_library libmissing does not match a supplied dylib
# RUN: rm -f %t/libgoodbye.dylib
# RUN: not lld -flavor darwinnew -arch x86_64 -o %t/sub-library -Z -L%t -lsuper %t/sub-library.o 2>&1 \
# RUN: not lld -flavor darwinnew -o %t/sub-library -Z -L%t -lsuper %t/sub-library.o 2>&1 \
# RUN: | FileCheck %s --check-prefix=MISSING-REEXPORT -DDIR=%t
# MISSING-REEXPORT: error: unable to read re-exported dylib at [[DIR]]/libgoodbye.dylib

Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/subsections-section-relocs.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# RUN: echo "_bar_str" > %t/order-file
# RUN: echo "_foo_str" >> %t/order-file

# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test %t/test.o -order_file %t/order-file
# RUN: lld -flavor darwinnew -o %t/test %t/test.o -order_file %t/order-file
# RUN: llvm-objdump --section-headers -d --no-show-raw-insn %t/test | FileCheck %s
# CHECK-LABEL: Sections:
# CHECK: __cstring {{[^ ]*}} {{0*}}[[#%x, CSTRING_ADDR:]]
Expand Down
4 changes: 2 additions & 2 deletions lld/test/MachO/subsections-symbol-relocs.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
# RUN: echo "_main" >> %t/order-file-2
# RUN: echo "_qux" >> %t/order-file-2

# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-1 %t/test.o -order_file %t/order-file-1
# RUN: lld -flavor darwinnew -o %t/test-1 %t/test.o -order_file %t/order-file-1
# RUN: llvm-objdump -d --no-show-raw-insn %t/test-1 | FileCheck %s
# RUN: lld -flavor darwinnew -arch x86_64 -o %t/test-2 %t/test.o -order_file %t/order-file-2
# RUN: lld -flavor darwinnew -o %t/test-2 %t/test.o -order_file %t/order-file-2
# RUN: llvm-objdump -d --no-show-raw-insn %t/test-2 | FileCheck %s
# CHECK-LABEL: Disassembly of section __TEXT,__text:
# CHECK: <_bar>:
Expand Down
8 changes: 4 additions & 4 deletions lld/test/MachO/symbol-order.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
# RUN: echo ".global f; .section __TEXT,test_f2; f: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/f2.o
# RUN: echo ".global f, g; .section __TEXT,test_fg; f: ret; g: callq f" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/fg.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
# RUN: lld -flavor darwinnew -arch x86_64 -dylib -o %t/libf1.dylib %t/f1.o
# RUN: lld -flavor darwinnew -dylib -o %t/libf1.dylib %t/f1.o

# RUN: rm -f %t/libf2_g.a
# RUN: llvm-ar rcs %t/libf2_g.a %t/f2.o %t/g.o

# RUN: rm -f %t/libfg.a
# RUN: llvm-ar rcs %t/libfg.a %t/fg.o

# RUN: lld -flavor darwinnew -arch x86_64 %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out
# RUN: lld -flavor darwinnew %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out
# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix DYLIB-FIRST
# DYLIB-FIRST: SYMBOL TABLE:
# DYLIB-FIRST-DAG: __TEXT,test_g g
# DYLIB-FIRST: Lazy bind table:
# DYLIB-FIRST-NEXT: segment section address dylib symbol
# DYLIB-FIRST-NEXT: __DATA __la_symbol_ptr {{[0-9a-z]+}} libf1 f

# RUN: lld -flavor darwinnew -arch x86_64 %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out
# RUN: lld -flavor darwinnew %t/libf2_g.a %t/libf1.dylib %t/test.o -o %t/test.out
# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST
# ARCHIVE-FIRST: SYMBOL TABLE:
# ARCHIVE-FIRST-DAG: __TEXT,test_f2 f
Expand All @@ -30,7 +30,7 @@
# ARCHIVE-FIRST-NEXT: segment section address dylib symbol
# ARCHIVE-FIRST-EMPTY:

# RUN: lld -flavor darwinnew -arch x86_64 %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out
# RUN: lld -flavor darwinnew %t/libf1.dylib %t/libfg.a %t/test.o -o %t/test.out
# RUN: llvm-objdump --syms --macho --lazy-bind %t/test.out | FileCheck %s --check-prefix ARCHIVE-PRIORITY
# ARCHIVE-PRIORITY: SYMBOL TABLE:
# ARCHIVE-PRIORITY-DAG: __TEXT,test_fg f
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/symtab.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t %t.o
# RUN: lld -flavor darwinnew -o %t %t.o
# RUN: llvm-readobj -symbols %t | FileCheck %s

# CHECK: Symbols [
Expand Down
2 changes: 1 addition & 1 deletion lld/test/MachO/x86-64-reloc-signed.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t %t.o
# RUN: lld -flavor darwinnew -o %t %t.o
# RUN: llvm-objdump -D %t | FileCheck %s

# CHECK: <_main>:
Expand Down
13 changes: 10 additions & 3 deletions lld/test/MachO/x86-64-reloc-unsigned.s
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: lld -flavor darwinnew -arch x86_64 -o %t %t.o
# RUN: lld -flavor darwinnew -o %t %t.o
# RUN: llvm-objdump --full-contents %t | FileCheck %s
# CHECK: Contents of section foo:
# CHECK: 100001000 08100000 01000000
# CHECK: Contents of section bar:
# CHECK: 100001008 11211111 02000000
# CHECK: 100001008 011000f0 11211111 02000000

.globl _main, _foo, _bar

Expand All @@ -15,7 +15,14 @@ _foo:

.section __DATA,bar
_bar:
## The unsigned relocation should support 64-bit addends
## We create a .int symbol reference here -- with non-zero data immediately
## after -- to check that lld reads precisely 32 bits (and not more) of the
## implicit addend when handling unsigned relocations of r_length = 2.
## Note that __PAGEZERO occupies the lower 32 bits, so all symbols are above
## that. To get a final relocated address that fits within 32 bits, we need to
## subtract an offset here.
.int _foo - 0x0fffffff
## The unsigned relocation should support 64-bit addends too (r_length = 3).
.quad _foo + 0x111111111

.text
Expand Down