xref: /llvm-project/lld/test/MachO/subsections-symbol-relocs.s (revision 75cdab6dc2453a508157a9c383b93373a93078d6)
1# REQUIRES: x86
2# RUN: rm -rf %t; split-file %s %t
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
4
5# RUN: %lld -o %t/test-1 %t/test.o -order_file %t/order-file-1
6# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t/test-1 | FileCheck %s
7# RUN: %lld -o %t/test-2 %t/test.o -order_file %t/order-file-2
8# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t/test-2 | FileCheck %s
9# CHECK-LABEL: Disassembly of section __TEXT,__text:
10# CHECK:       <_ba{{r|z}}>:
11# CHECK-NEXT:    callq {{.*}} <_foo>
12# CHECK-EMPTY:
13# CHECK-NEXT:  <_qux>:
14# CHECK-NEXT:    retq
15# CHECK:       <_foo>:
16# CHECK-NEXT:    retq
17# CHECK:       <_main>:
18# CHECK-NEXT:    callq {{.*}} <_ba{{r|z}}>
19# CHECK-NEXT:    movq $0, %rax
20# CHECK-NEXT:    retq
21
22#--- order-file-1
23_bar
24_foo
25_main
26## _qux is marked as .alt_entry, so it should not create a new subsection and
27## its contents should move with _bar to the start of the output despite the
28## order file listing it at the end.
29_qux
30
31#--- order-file-2
32## _bar and _baz point to the same address, so both order files should achieve
33## the same result.
34_baz
35_foo
36_main
37_qux
38
39#--- test.s
40.text
41.globl _main, _foo, _bar, _qux
42.alt_entry _qux
43
44_foo:
45  retq
46
47_main:
48  callq _bar
49  movq $0, %rax
50  retq
51
52_bar:
53_baz:
54  callq _foo
55_qux:
56  retq
57
58.subsections_via_symbols
59