Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / mh-header-link.s
blob7683d7a4343610c293e418a5006edd47794bca5b
1 # REQUIRES: x86
3 ## This tests that we can link against these synthetic symbols even
4 ## if they are not in the symbol table.
6 # RUN: rm -rf %t; split-file %s %t
8 ## Test that in a dylib, we can link against __mh_dylib_header
9 ## (but not in other types of files)
11 # RUN: llvm-mc %t/dylib.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/dylib.o
12 # RUN: %lld -dylib -dead_strip %t/dylib.o -o %t/dylib.out
13 # RUN: llvm-objdump -m --syms %t/dylib.out | FileCheck %s --check-prefix DYLIB
15 # RUN: not %lld -o /dev/null %t/dylib.o 2>&1 | FileCheck %s --check-prefix ERR-DYLIB
17 # DYLIB: SYMBOL TABLE:
18 # DYLIB-NEXT: {{[0-9a-f]+}} g F __TEXT,__text _main
19 # DYLIB-NEXT-EMPTY:
20 # ERR-DYLIB: error: undefined symbol: __mh_dylib_header
22 ## Test that in an executable, we can link against __mh_execute_header
23 # RUN: llvm-mc %t/main.s -triple=x86_64-apple-macos10.15 -filetype=obj -o %t/exec.o
24 # RUN: %lld -dead_strip -lSystem %t/exec.o -o %t/exec.out
26 ## But it would be an error trying to reference __mh_execute_header in a dylib
27 # RUN: not %lld -o /dev/null -dylib %t/exec.o 2>&1 | FileCheck %s --check-prefix ERR-EXEC
29 # ERR-EXEC: error: undefined symbol: __mh_execute_header
31 #--- main.s
32 .text
33 .globl _main
34 _main:
35 mov __mh_execute_header@GOTPCREL(%rip), %rax
36 ret
37 .subsections_via_symbols
39 #--- dylib.s
40 .text
41 .globl _main
42 _main:
43 mov __mh_dylib_header@GOTPCREL(%rip), %rax
44 ret
45 .subsections_via_symbols