Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / discard-llvm-sections.s
bloba05456dc966725c1ed6231953c5f0c6ffd11c664
1 # REQUIRES: x86
2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/bar.s -o %t/bar.o
6 ## "_llvm." symbols are not special. LLD would produce duplicate symbol errors
7 ## if they were not within the LLVM segment.
9 ## 1/ Test that LLD does not produce duplicate symbols errors when linking global symbols
10 ## with the same name under the LLVM segment.
11 # RUN: %lld -dylib %t/foo.o %t/bar.o -o %t/libDuplicate.dylib
13 ## 2/ Test that all sections within an LLVM segment are dropped.
14 # RUN: llvm-objdump --section-headers %t/libDuplicate.dylib | FileCheck %s
16 # CHECK-LABEL: Sections:
17 # CHECK-NEXT: Idx Name Size VMA Type
18 # CHECK-NEXT: 0 __text 00000000 {{[0-9a-f]+}} TEXT
20 ## 3/ Test that linking global symbol that is not under the LLVM segment produces duplicate
21 ## symbols
22 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin --defsym TEXT=0 %t/foo.s -o %t/foo.o
23 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin --defsym TEXT=0 %t/bar.s -o %t/bar.o
24 # RUN: not %lld -dylib %t/foo.o %t/bar.o -o %t/libDuplicate.dylib 2>&1 | FileCheck %s --check-prefix=DUP
26 # DUP: error: duplicate symbol: _llvm.foo
28 #--- foo.s
29 .globl _llvm.foo
30 .ifdef TEXT
31 .section __TEXT,__cstring
32 .else
33 .section __LLVM,__bitcode
34 .endif
35 _llvm.foo:
36 .asciz "test"
38 #--- bar.s
39 .globl _llvm.foo
40 .ifdef TEXT
41 .section __TEXT,__cstring
42 .else
43 .section __LLVM,__bitcode
44 .endif
45 _llvm.foo:
46 .asciz "test"