Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / MachO / x86-64-relocs.s
blobcdeee96c182f0d99ca63ec760a8195af806f6fbc
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
3 # RUN: %lld -lSystem -o %t %t.o
4 # RUN: llvm-objdump --no-print-imm-hex --section-headers --syms -d %t | FileCheck %s
6 # CHECK-LABEL: Sections:
7 # CHECK: __data {{[0-9a-z]+}} [[#%x, DATA_ADDR:]]
9 # CHECK-LABEL: SYMBOL TABLE:
10 # CHECK: [[#%x, F_ADDR:]] {{.*}} _f
12 # CHECK-LABEL: <_main>:
13 ## Test X86_64_RELOC_BRANCH
14 # CHECK: callq 0x[[#%x, F_ADDR]] <_f>
15 ## Test extern (symbol) X86_64_RELOC_SIGNED
16 # CHECK: leaq [[#%u, LOCAL_OFF:]](%rip), %rsi
17 # CHECK-NEXT: [[#%x, DATA_ADDR - LOCAL_OFF]]
18 ## Test non-extern (section) X86_64_RELOC_SIGNED
19 # CHECK: leaq [[#%u, PRIVATE_OFF:]](%rip), %rsi
20 # CHECK-NEXT: [[#%x, DATA_ADDR + 8 - PRIVATE_OFF]]
22 # RUN: llvm-objdump --section=__const --full-contents %t | FileCheck %s --check-prefix=NONPCREL
23 # NONPCREL: Contents of section __DATA_CONST,__const:
24 # NONPCREL-NEXT: 100001000 08200000 01000000 08200000 01000000
26 .section __TEXT,__text
27 .globl _main, _f
28 _main:
29 callq _f # X86_64_RELOC_BRANCH
30 mov $0, %rax
31 ret
33 _f:
34 leaq _local(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel symbol relocation
35 leaq L_.private(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel section relocation
36 movq L_.ptr_1(%rip), %rsi
37 ret
39 .data
40 ## References to this generate a symbol relocation
41 _local:
42 .quad 123
43 ## References to this generate a section relocation
44 L_.private:
45 .quad 123
47 .section __DATA,__const
48 ## These generate X86_64_RELOC_UNSIGNED non-pcrel section relocations
49 L_.ptr_1:
50 .quad L_.private
51 L_.ptr_2:
52 .quad L_.private