[llvm-branch-commits] [lld] a817594 - [lld-macho][nfc] Clean up tests

Jez Ng via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Dec 21 11:48:50 PST 2020


Author: Jez Ng
Date: 2020-12-21T14:44:08-05:00
New Revision: a817594de9269b9ac8055a2ff2a22ab824cf143d

URL: https://github.com/llvm/llvm-project/commit/a817594de9269b9ac8055a2ff2a22ab824cf143d
DIFF: https://github.com/llvm/llvm-project/commit/a817594de9269b9ac8055a2ff2a22ab824cf143d.diff

LOG: [lld-macho][nfc] Clean up tests

* Migrate most of our tests to use `split-file` instead of `echo`
* Remove individual `rm -f %t/libfoo.a` commands in favor of a top-level `rm -rf %t`
* Remove unused `Inputs/libfunction.s`

Reviewed By: #lld-macho, compnerd

Differential Revision: https://reviews.llvm.org/D93604

Added: 
    

Modified: 
    lld/test/MachO/archive.s
    lld/test/MachO/common-symbol-resolution.s
    lld/test/MachO/filelist.s
    lld/test/MachO/force-load.s
    lld/test/MachO/framework.s
    lld/test/MachO/invalid/archive-no-index.s
    lld/test/MachO/invalid/bad-archive-member.s
    lld/test/MachO/lto-archive.ll
    lld/test/MachO/objc.s
    lld/test/MachO/order-file.s
    lld/test/MachO/resolution.s
    lld/test/MachO/section-merge.s
    lld/test/MachO/stabs.s
    lld/test/MachO/subsections-section-relocs.s
    lld/test/MachO/subsections-symbol-relocs.s
    lld/test/MachO/symbol-order.s
    lld/test/MachO/weak-definition-direct-fetch.s
    lld/test/MachO/weak-definition-indirect-fetch.s
    lld/test/MachO/weak-definition-order.s
    lld/test/MachO/weak-definition-over-dysym.s

Removed: 
    lld/test/MachO/Inputs/libfunction.s


################################################################################
diff  --git a/lld/test/MachO/Inputs/libfunction.s b/lld/test/MachO/Inputs/libfunction.s
deleted file mode 100644
index fe0b3879a41a..000000000000
--- a/lld/test/MachO/Inputs/libfunction.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.section __TEXT,__text
-.globl _some_function
-
-_some_function:
-  mov $1, %rax
-  ret

diff  --git a/lld/test/MachO/archive.s b/lld/test/MachO/archive.s
index abde623b07f4..2ac2d302b88d 100644
--- a/lld/test/MachO/archive.s
+++ b/lld/test/MachO/archive.s
@@ -1,11 +1,10 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
-# RUN: echo ".global _boo; _boo: ret"                           | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/2.o
-# RUN: echo ".global _bar; _bar: ret"                           | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/3.o
-# RUN: echo ".global _undefined; .global _unused; _unused: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/4.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/3.s -o %t/3.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/4.s -o %t/4.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
 
-# RUN: rm -f %t/test.a
 # RUN: llvm-ar rcs %t/test.a %t/2.o %t/3.o %t/4.o
 # RUN: %lld %t/main.o %t/test.a -o %t/test.out
 
@@ -33,9 +32,24 @@
 # ALL-LOAD: T _main
 # ALL-LOAD: T _unused
 
-.global _main
+#--- 2.s
+.globl _boo
+_boo:
+  ret
+
+#--- 3.s
+.globl _bar
+_bar:
+  ret
+
+#--- 4.s
+.globl _undefined, _unused
+_unused:
+  ret
+
+#--- main.s
+.globl _main
 _main:
   callq _boo
   callq _bar
-  mov $0, %rax
   ret

diff  --git a/lld/test/MachO/common-symbol-resolution.s b/lld/test/MachO/common-symbol-resolution.s
index 2a88ef51e460..1dc015816da4 100644
--- a/lld/test/MachO/common-symbol-resolution.s
+++ b/lld/test/MachO/common-symbol-resolution.s
@@ -1,5 +1,5 @@
 # REQUIRES: x86
-# RUN: split-file %s %t
+# RUN: rm -rf %t; split-file %s %t
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/common.s -o %t/common.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak-common.s -o %t/weak-common.o
@@ -11,7 +11,6 @@
 
 # RUN: %lld -lSystem -order_file %t/order -dylib %t/libfoo.o -o %t/libfoo.dylib
 
-# RUN: rm -f %t/defined.a %t/weak-defined-and-common.a
 # RUN: llvm-ar rcs %t/defined.a %t/defined.o
 # RUN: llvm-ar rcs %t/weak-defined-and-common.a %t/weak-defined.o %t/common.o
 

diff  --git a/lld/test/MachO/filelist.s b/lld/test/MachO/filelist.s
index 32be332aa507..3d4846c4505a 100644
--- a/lld/test/MachO/filelist.s
+++ b/lld/test/MachO/filelist.s
@@ -3,10 +3,10 @@
 ## This test verifies that the paths in -filelist get processed in command-line
 ## order.
 
-# RUN: mkdir -p %t
-# RUN: echo ".globl _foo; .weak_definition _foo; .section __TEXT,first; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/first.o
-# RUN: echo ".globl _foo; .weak_definition _foo; .section __TEXT,second; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/second.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/first.s -o %t/first.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/second.s -o %t/second.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 
 # FIRST: __TEXT,first _foo
 # SECOND: __TEXT,second _foo
@@ -34,7 +34,19 @@
 # RUN: %lld -filelist filelist-2 -filelist filelist-1 %t/test.o -o %t/test
 # RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=SECOND
 
-.globl _main
+#--- first.s
+.globl _foo
+.weak_definition _foo
+.section __TEXT,first
+_foo:
+
+#--- second.s
+.globl _foo
+.weak_definition _foo
+.section __TEXT,second
+_foo:
 
+#--- test.s
+.globl _main
 _main:
   ret

diff  --git a/lld/test/MachO/force-load.s b/lld/test/MachO/force-load.s
index ffc2019eacd9..1cedae3173bc 100644
--- a/lld/test/MachO/force-load.s
+++ b/lld/test/MachO/force-load.s
@@ -1,10 +1,9 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
-# RUN: echo ".section __TEXT,archive; .globl _foo; .weak_definition _foo; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/archive-foo.o
-# RUN: rm -f %t/foo.a
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/archive-foo.s -o %t/archive-foo.o
 # RUN: llvm-ar rcs %t/foo.a %t/archive-foo.o
-# RUN: echo ".section __TEXT,obj; .globl _foo; .weak_definition _foo; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
-# 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 %t/foo.s -o %t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 
 # RUN: %lld -force_load %t/foo.a %t/foo.o %t/test.o -o %t/test-force-load-first
 # FORCE-LOAD-FIRST:  __TEXT,archive _foo
@@ -14,6 +13,19 @@
 # RUN: llvm-objdump --syms %t/test-force-load-second | FileCheck %s --check-prefix=FORCE-LOAD-SECOND
 # FORCE-LOAD-SECOND: __TEXT,obj _foo
 
+#--- archive-foo.s
+.section __TEXT,archive
+.globl _foo
+.weak_definition _foo
+_foo:
+
+#--- foo.s
+.section __TEXT,obj
+.globl _foo
+.weak_definition _foo
+_foo:
+
+#--- test.s
 .globl _main
 _main:
   ret

diff  --git a/lld/test/MachO/framework.s b/lld/test/MachO/framework.s
index 43e1ec4fccaf..7244387a022b 100644
--- a/lld/test/MachO/framework.s
+++ b/lld/test/MachO/framework.s
@@ -1,13 +1,13 @@
 # REQUIRES: x86, shell
-# RUN: mkdir -p %t
-# RUN: echo ".globl _foo; _foo: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
 # RUN: mkdir -p %t/Foo.framework/Versions/A
 # RUN: %lld -dylib -install_name %t/Foo.framework/Versions/A/Foo %t/foo.o -o %t/Foo.framework/Versions/A/Foo
 # RUN: %lld -dylib -install_name %t/Foo.framework/Versions/A/Foobar %t/foo.o -o %t/Foo.framework/Versions/A/Foobar
 # RUN: ln -sf %t/Foo.framework/Versions/A %t/Foo.framework/Versions/Current
 # RUN: ln -sf %t/Foo.framework/Versions/Current/Foo %t/Foo.framework/Foo
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/test.o %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 # RUN: %lld -lSystem -F%t -framework Foo %t/test.o -o %t/test
 # RUN: llvm-objdump --macho --lazy-bind %t/test | FileCheck %s --check-prefix=NOSUFFIX
 # NOSUFFIX: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} {{.*}}Foo _foo
@@ -19,6 +19,12 @@
 # RUN: llvm-objdump --macho --lazy-bind %t/test-suffix | FileCheck %s --check-prefix=SUFFIX
 # SUFFIX: __DATA __la_symbol_ptr 0x{{[0-9a-f]*}} {{.*}}Foobar _foo
 
+#--- foo.s
+.globl _foo
+_foo:
+  ret
+
+#--- test.s
 .globl _main
 .text
 _main:

diff  --git a/lld/test/MachO/invalid/archive-no-index.s b/lld/test/MachO/invalid/archive-no-index.s
index d4d2afb449b7..9cda94565250 100644
--- a/lld/test/MachO/invalid/archive-no-index.s
+++ b/lld/test/MachO/invalid/archive-no-index.s
@@ -1,16 +1,31 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
-# RUN: echo ".global _boo; _boo: ret"                           | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/2.o
-# RUN: echo ".global _bar; _bar: ret"                           | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/3.o
-# RUN: echo ".global _undefined; .global _unused; _unused: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/4.o
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/3.s -o %t/3.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/4.s -o %t/4.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
 
-# RUN: rm -f %t/test.a
 # RUN: llvm-ar rcS %t/test.a %t/2.o %t/3.o %t/4.o
 
 # RUN: not %lld %t/test.o %t/test.a -o /dev/null 2>&1 | FileCheck %s
 # CHECK: error: {{.*}}.a: archive has no index; run ranlib to add one
 
+#--- 2.s
+.globl _boo
+_boo:
+  ret
+
+#--- 3.s
+.globl _bar
+_bar:
+  ret
+
+#--- 4.s
+.globl _undefined, _unused
+_unused:
+  ret
+
+#--- main.s
 .global _main
 _main:
   mov $0, %rax

diff  --git a/lld/test/MachO/invalid/bad-archive-member.s b/lld/test/MachO/invalid/bad-archive-member.s
index 15ab524476d3..a76cecf239b7 100644
--- a/lld/test/MachO/invalid/bad-archive-member.s
+++ b/lld/test/MachO/invalid/bad-archive-member.s
@@ -1,9 +1,8 @@
 # REQUIRES: x86
-# RUN: split-file %s %t
+# RUN: rm -rf %t; split-file %s %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 # RUN: %lld -dylib -lSystem %t/foo.o -o %t/foo.dylib
-# RUN: rm -f %t/foo.a
 # RUN: llvm-ar rcs %t/foo.a %t/foo.dylib
 # RUN: not %lld %t/test.o %t/foo.a -o /dev/null 2>&1 | FileCheck %s -DFILE=%t/foo.a
 # CHECK: error: [[FILE]]: archive member foo.dylib has unhandled file type

diff  --git a/lld/test/MachO/lto-archive.ll b/lld/test/MachO/lto-archive.ll
index 42b2c0fb5759..2aa7beb0c951 100644
--- a/lld/test/MachO/lto-archive.ll
+++ b/lld/test/MachO/lto-archive.ll
@@ -1,8 +1,7 @@
 ; REQUIRES: x86
-; RUN: split-file %s %t
+; RUN: rm -rf %t; split-file %s %t
 ; RUN: llvm-as %t/foo.ll -o %t/foo.o
 ; RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
-; RUN: rm -f %t/foo.a
 ; RUN: llvm-ar rcs %t/foo.a %t/foo.o
 ; RUN: %lld -save-temps -lSystem %t/test.o %t/foo.a -o %t/test
 ; RUN: llvm-objdump -d --macho --no-show-raw-insn %t/test | FileCheck %s

diff  --git a/lld/test/MachO/objc.s b/lld/test/MachO/objc.s
index 48ca60bc0322..53dd12e8f190 100644
--- a/lld/test/MachO/objc.s
+++ b/lld/test/MachO/objc.s
@@ -1,12 +1,10 @@
 # REQUIRES: x86
-# RUN: split-file %s %t
+# RUN: rm -rf %t; split-file %s %t
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-symbol.s -o %t/has-objc-symbol.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-objc-category.s -o %t/has-objc-category.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/has-swift.s -o %t/has-swift.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-objc.s -o %t/no-objc.o
-
-# RUN: rm -f %t/libHasSomeObjC.a
 # RUN: llvm-ar rcs %t/libHasSomeObjC.a %t/has-objc-symbol.o %t/has-objc-category.o %t/has-swift.o %t/no-objc.o
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o

diff  --git a/lld/test/MachO/order-file.s b/lld/test/MachO/order-file.s
index 83e6840c9786..c185572c2389 100644
--- a/lld/test/MachO/order-file.s
+++ b/lld/test/MachO/order-file.s
@@ -2,7 +2,6 @@
 # RUN: rm -rf %t; split-file %s %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
-# RUN: rm -f %t/foo.a
 # RUN: llvm-ar rcs %t/foo.a %t/foo.o
 
 # FOO-FIRST: <_bar>:

diff  --git a/lld/test/MachO/resolution.s b/lld/test/MachO/resolution.s
index 056324bddbde..da6ed086548f 100644
--- a/lld/test/MachO/resolution.s
+++ b/lld/test/MachO/resolution.s
@@ -1,18 +1,17 @@
 # REQUIRES: x86
-# 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: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libresolution.s -o %t/libresolution.o
 # RUN: %lld -dylib -install_name \
 # RUN:   @executable_path/libresolution.dylib %t/libresolution.o -o %t/libresolution.dylib
 # RUN: %lld -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
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/resolution.s -o %t/resolution.o
 
 ## Check that we select the symbol defined in the first dylib passed on the
 ## command line.
 # RUN: %lld -o %t/dylib-first -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
+# DYLIB-FIRST: libresolution _foo
 
 # RUN: %lld -o %t/dylib2-first -L%t -lresolution2 -lresolution %t/resolution.o
 # RUN: llvm-objdump --macho --bind %t/dylib2-first | FileCheck %s --check-prefix=DYLIB2-FIRST
@@ -31,6 +30,13 @@
 # OBJ-FIRST-NOT: libresolution _bar
 # OBJ-FIRST-NOT: libresolution _baz
 
+#--- libresolution.s
+.globl _foo, _bar, _baz
+_foo:
+_bar:
+_baz:
+
+#--- resolution.s
 .globl _main, _bar
 # Global defined symbol
 _bar:

diff  --git a/lld/test/MachO/section-merge.s b/lld/test/MachO/section-merge.s
index 7db41573d675..4dc657a19b5c 100644
--- a/lld/test/MachO/section-merge.s
+++ b/lld/test/MachO/section-merge.s
@@ -1,10 +1,10 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
+# RUN: rm -rf %t; split-file %s %t
 ## Verify that we preserve alignment when merging sections.
-# RUN: echo ".globl _foo; .data; .p2align 0; _foo: .byte 0xca" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
-# RUN: echo ".globl _bar; .data; .p2align 2; _bar: .byte 0xfe" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/bar.o
-# RUN: echo ".globl _baz; .data; .p2align 3; _baz: .byte 0xba" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/baz.o
-# RUN: echo ".globl _qux; .data; .p2align 0; _qux: .quad 0xdeadbeef" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/qux.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/bar.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/baz.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/qux.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
 # RUN: %lld -o %t/output %t/foo.o %t/bar.o %t/baz.o %t/qux.o %t/main.o
 
@@ -18,8 +18,37 @@
 # CHECK:      Contents of section __DATA,__data:
 # CHECK-NEXT: {{0*}}[[#ADDR]] ca000000 fe000000 baefbead de000000
 
+#--- foo.s
+.globl _foo
+.data
+.p2align 0
+_foo:
+  .byte 0xca
+
+#--- bar.s
+.globl _bar
+.data
+.p2align 2
+_bar:
+  .byte 0xfe
+
+#--- baz.s
+.globl _baz
+.data
+.p2align 3
+_baz:
+  .byte 0xba
+
+#--- qux.s
+.globl _qux
+.data
+.p2align 0
+_qux:
+  .quad 0xdeadbeef
+
+#--- main.s
 .section __TEXT,__text
-.global _main
+.globl _main
 
 _main:
   mov $0, %rax

diff  --git a/lld/test/MachO/stabs.s b/lld/test/MachO/stabs.s
index 9634a95be4a2..ad9dacc62804 100644
--- a/lld/test/MachO/stabs.s
+++ b/lld/test/MachO/stabs.s
@@ -1,13 +1,12 @@
 # REQUIRES: x86, shell
 # UNSUPPORTED: system-windows
-# RUN: split-file %s %t
+# RUN: rm -rf %t; split-file %s %t
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/no-debug.s -o %t/no-debug.o
 ## Set modtimes of the files for deterministic test output.
 # RUN: env TZ=UTC touch -t "197001010000.16" %t/test.o
 # RUN: env TZ=UTC touch -t "197001010000.32" %t/foo.o
-# RUN: rm -f %t/foo.a
 # RUN: llvm-ar rcsU %t/foo.a %t/foo.o
 
 # RUN: %lld -lSystem %t/test.o %t/foo.o %t/no-debug.o -o %t/test

diff  --git a/lld/test/MachO/subsections-section-relocs.s b/lld/test/MachO/subsections-section-relocs.s
index 7b7ffe20e7ba..44ed5e56041d 100644
--- a/lld/test/MachO/subsections-section-relocs.s
+++ b/lld/test/MachO/subsections-section-relocs.s
@@ -1,9 +1,6 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
-
-# RUN: echo "_bar_str" > %t/order-file
-# RUN: echo "_foo_str" >> %t/order-file
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 
 # RUN: %lld -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
@@ -20,6 +17,11 @@
 # STRINGS: Private symbol
 # STRINGS: foo
 
+#--- order-file
+_bar_str
+_foo_str
+
+#--- test.s
 .text
 .globl _main, _foo_str, _bar_str
 

diff  --git a/lld/test/MachO/subsections-symbol-relocs.s b/lld/test/MachO/subsections-symbol-relocs.s
index 8010a50e7444..848ac756361b 100644
--- a/lld/test/MachO/subsections-symbol-relocs.s
+++ b/lld/test/MachO/subsections-symbol-relocs.s
@@ -1,21 +1,6 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
-
-# RUN: echo "_bar" > %t/order-file-1
-# RUN: echo "_foo" >> %t/order-file-1
-# RUN: echo "_main" >> %t/order-file-1
-## _qux is marked as .alt_entry, so it should not create a new subsection and
-## its contents should move with _bar to the start of the output despite the
-## order file listing it at the end.
-# RUN: echo "_qux" >> %t/order-file-1
-
-## _bar and _baz point to the same address, so both order files should achieve
-## the same result.
-# RUN: echo "_baz" > %t/order-file-2
-# RUN: echo "_foo" >> %t/order-file-2
-# RUN: echo "_main" >> %t/order-file-2
-# RUN: echo "_qux" >> %t/order-file-2
+# RUN: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 
 # RUN: %lld -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
@@ -34,6 +19,24 @@
 # CHECK-NEXT:    movq $0, %rax
 # CHECK-NEXT:    retq
 
+#--- order-file-1
+_bar
+_foo
+_main
+## _qux is marked as .alt_entry, so it should not create a new subsection and
+## its contents should move with _bar to the start of the output despite the
+## order file listing it at the end.
+_qux
+
+#--- order-file-2
+## _bar and _baz point to the same address, so both order files should achieve
+## the same result.
+_baz
+_foo
+_main
+_qux
+
+#--- test.s
 .text
 .globl _main, _foo, _bar, _qux
 .alt_entry _qux

diff  --git a/lld/test/MachO/symbol-order.s b/lld/test/MachO/symbol-order.s
index c61e7c830f6b..0c904560e524 100644
--- a/lld/test/MachO/symbol-order.s
+++ b/lld/test/MachO/symbol-order.s
@@ -1,16 +1,13 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
-# RUN: echo ".global f, g; .section __TEXT,test_g; g: callq f"          | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/g.o
-# RUN: echo ".global f; .section __TEXT,test_f1; f: ret"                | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/f1.o
-# 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: rm -rf %t; split-file %s %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/g.s  -o %t/g.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/f1.s -o %t/f1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/f2.s -o %t/f2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/fg.s -o %t/fg.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
 # RUN: %lld -dylib -o %t/libf1.dylib %t/f1.o -lSystem
 
-# 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 %t/libf1.dylib %t/libf2_g.a %t/test.o -o %t/test.out -lSystem
@@ -39,6 +36,33 @@
 # ARCHIVE-PRIORITY-NEXT: segment  section            address       dylib            symbol
 # ARCHIVE-PRIORITY-EMPTY:
 
+#--- g.s
+.global f, g
+.section __TEXT,test_g
+g:
+  callq f
+
+#--- f1.s
+.global f
+.section __TEXT,test_f1
+f:
+  ret
+
+#--- f2.s
+.global f
+.section __TEXT,test_f2
+f:
+  ret
+
+#--- fg.s
+.global f, g
+.section __TEXT,test_fg
+f:
+  ret
+g:
+  callq f
+
+#--- test.s
 .global g
 .global _main
 _main:

diff  --git a/lld/test/MachO/weak-definition-direct-fetch.s b/lld/test/MachO/weak-definition-direct-fetch.s
index 38b809c96481..28bbe65f05f1 100644
--- a/lld/test/MachO/weak-definition-direct-fetch.s
+++ b/lld/test/MachO/weak-definition-direct-fetch.s
@@ -1,12 +1,12 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
+# RUN: rm -rf %t; split-file %s %t
 
 ## This test exercises the various possible combinations of weak and non-weak
 ## symbols that get referenced directly by a relocation in an object file.
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
-# RUN: echo ".globl _foo; .section __TEXT,nonweak; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
-# RUN: echo ".globl _foo; .weak_definition _foo; .section __TEXT,weak; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/weakfoo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weakfoo.s -o %t/weakfoo.o
 
 # RUN: %lld -dylib -install_name \
 # RUN:   @executable_path/libfoo.dylib %t/foo.o -o %t/libfoo.dylib
@@ -24,9 +24,7 @@
 # RUN: llvm-nm %t/libweakfoo.dylib 2>&1 | FileCheck %s --check-prefix=NOSYM
 # NOSYM: no symbols
 
-# RUN: rm -f %t/foo.a
 # RUN: llvm-ar --format=darwin rcs %t/foo.a %t/foo.o
-# RUN: rm -f %t/weakfoo.a
 # RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o
 
 ## End of input file setup. The following lines check which symbol "wins" when
@@ -84,6 +82,18 @@
 # RUN: %lld -lSystem -o %t/nonweak-ar-weak-obj -L%t %t/foo.a %t/weakfoo.o %t/test.o
 # RUN: llvm-objdump --macho --lazy-bind --syms %t/nonweak-ar-weak-obj | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT
 
+#--- foo.s
+.globl _foo
+.section __TEXT,nonweak
+_foo:
+
+#--- weakfoo.s
+.globl _foo
+.weak_definition _foo
+.section __TEXT,weak
+_foo:
+
+#--- test.s
 .globl _main
 _main:
   callq _foo

diff  --git a/lld/test/MachO/weak-definition-indirect-fetch.s b/lld/test/MachO/weak-definition-indirect-fetch.s
index 3a45852115e0..46ed62441b89 100644
--- a/lld/test/MachO/weak-definition-indirect-fetch.s
+++ b/lld/test/MachO/weak-definition-indirect-fetch.s
@@ -1,5 +1,5 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
+# RUN: rm -rf %t; split-file %s %t
 
 ## This tests examines the effect of .weak_definition on symbols in an archive
 ## that are not referenced directly, but which are still loaded due to some
@@ -9,13 +9,11 @@
 ## will be fetched when linking against the main test file due to its references
 ## to _bar and _baz.
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
-# RUN: echo ".globl _foo, _bar; .section __TEXT,nonweak; _bar: _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
-# RUN: echo ".globl _foo, _baz; .weak_definition _foo; .section __TEXT,weak; _baz: _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/weakfoo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weakfoo.s -o %t/weakfoo.o
 
-# RUN: rm -f %t/foo.a
 # RUN: llvm-ar --format=darwin rcs %t/foo.a %t/foo.o
-# RUN: rm -f %t/weakfoo.a
 # RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o
 
 # PREFER-NONWEAK-OBJECT: O __TEXT,nonweak _foo
@@ -35,6 +33,20 @@
 # RUN: %lld -lSystem -o %t/nonweak-ar-weak-obj -L%t %t/foo.a %t/weakfoo.o %t/test.o
 # RUN: llvm-objdump --syms %t/nonweak-ar-weak-obj | FileCheck %s --check-prefix=PREFER-NONWEAK-OBJECT
 
+#--- foo.s
+.globl _foo, _bar
+.section __TEXT,nonweak
+_bar:
+_foo:
+
+#--- weakfoo.s
+.globl _foo, _baz
+.weak_definition _foo
+.section __TEXT,weak
+_baz:
+_foo:
+
+#--- test.s
 .globl _main
 _main:
   callq _bar

diff  --git a/lld/test/MachO/weak-definition-order.s b/lld/test/MachO/weak-definition-order.s
index 01875e82d564..addf6ab8f8ec 100644
--- a/lld/test/MachO/weak-definition-order.s
+++ b/lld/test/MachO/weak-definition-order.s
@@ -1,13 +1,13 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
+# RUN: rm -rf %t; split-file %s %t
 
 ## This test demonstrates that when we have two weak symbols of the same type,
 ## we pick the one whose containing file appears earlier in the command-line
 ## invocation.
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
-# RUN: echo ".globl _foo; .weak_definition _foo; .section __TEXT,weak1; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/weak1.o
-# RUN: echo ".globl _foo; .weak_definition _foo; .section __TEXT,weak2; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/weak2.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak1.s -o %t/weak1.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak2.s -o %t/weak2.o
 
 # RUN: %lld -lSystem -o %t/obj12 -L%t %t/weak1.o %t/weak2.o %t/test.o
 # RUN: llvm-objdump --syms %t/obj12 | FileCheck %s --check-prefix=WEAK1
@@ -29,6 +29,19 @@
 # DYLIB1: __DATA   __la_symbol_ptr    0x{{[0-9a-f]*}} pointer 0 libweak1         _foo
 # DYLIB2: __DATA   __la_symbol_ptr    0x{{[0-9a-f]*}} pointer 0 libweak2         _foo
 
+#--- weak1.s
+.globl _foo
+.weak_definition _foo
+.section __TEXT,weak1;
+_foo:
+
+#--- weak2.s
+.globl _foo
+.weak_definition _foo
+.section __TEXT,weak2
+_foo:
+
+#--- test.s
 .globl _main
 _main:
   callq _foo

diff  --git a/lld/test/MachO/weak-definition-over-dysym.s b/lld/test/MachO/weak-definition-over-dysym.s
index ec1f3353c7c3..ff677a9d4a3f 100644
--- a/lld/test/MachO/weak-definition-over-dysym.s
+++ b/lld/test/MachO/weak-definition-over-dysym.s
@@ -1,22 +1,19 @@
 # REQUIRES: x86
-# RUN: mkdir -p %t
+# RUN: rm -rf %t; split-file %s %t
 
 ## This test demonstrates that when an archive file is fetched, its symbols
 ## always override any conflicting dylib symbols, regardless of any weak
 ## definition flags.
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
-# RUN: echo ".globl _foo; _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/libfoo.o
-# RUN: %lld -dylib -install_name \
-# RUN:   @executable_path/libfoo.dylib %t/libfoo.o -o %t/libfoo.dylib
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o %t/libfoo.o
+# RUN: %lld -dylib -install_name @executable_path/libfoo.dylib %t/libfoo.o -o %t/libfoo.dylib
 
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
-# RUN: echo ".globl _foo, _bar; .section __TEXT,nonweak; _bar: _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
-# RUN: echo ".globl _foo, _bar; .weak_definition _foo; .section __TEXT,weak; _bar: _foo:" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/weakfoo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weakfoo.s -o %t/weakfoo.o
 
-# RUN: rm -f %t/foo.a
 # RUN: llvm-ar --format=darwin rcs %t/foo.a %t/foo.o
-# RUN: rm -f %t/weakfoo.a
 # RUN: llvm-ar --format=darwin rcs %t/weakfoo.a %t/weakfoo.o
 
 # PREFER-WEAK-OBJECT: O __TEXT,weak _foo
@@ -32,6 +29,24 @@
 # RUN: %lld -lSystem -o %t/nonweak-dylib-weak-obj -L%t -lfoo %t/weakfoo.o %t/test.o
 # RUN: llvm-objdump --macho --lazy-bind --syms %t/nonweak-dylib-weak-obj | FileCheck %s --check-prefix=PREFER-WEAK-OBJECT
 
+#--- libfoo.s
+.globl _foo
+_foo:
+
+#--- foo.s
+.globl _foo, _bar
+.section __TEXT,nonweak
+_bar:
+_foo:
+
+#--- weakfoo.s
+.globl _foo, _bar
+.weak_definition _foo
+.section __TEXT,weak
+_bar:
+_foo:
+
+#--- test.s
 .globl _main
 _main:
   callq _foo


        


More information about the llvm-branch-commits mailing list