2 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
3 # RUN: echo _t > %t.order
4 # RUN: %lld -o %t -order_file %t.order %t.o
5 # RUN: llvm-objdump --section-headers --syms -D %t | FileCheck %s
7 # CHECK-LABEL: Sections:
8 # CHECK: __foo {{[0-9a-f]+}} [[#%x,FOO:]] DATA
10 # CHECK-LABEL: SYMBOL TABLE:
11 # CHECK: [[#%x,S:]] g O __DATA,__data _s
13 # CHECK-LABEL: Disassembly of section
15 # CHECK-NEXT: movl {{.*}} ## imm =
16 # CHECK-NEXT: ## 0x[[#S]]
17 # CHECK-NEXT: callq {{.*}}
18 # CHECK-NEXT: movl {{.*}} ## 0x[[#S + 2]]
19 # CHECK-NEXT: callq {{.*}}
20 # CHECK-NEXT: movb {{.*}} ## 0x[[#S]]
21 # CHECK-NEXT: callq {{.*}}
22 # CHECK: <__not_text>:
23 # CHECK-NEXT: movl {{.*}} ## imm =
24 # CHECK-NEXT: ## 0x[[#FOO + 8]]
25 # CHECK-NEXT: callq {{.*}}
26 # CHECK-NEXT: movl {{.*}} ## 0x[[#FOO + 8 + 2]]
27 # CHECK-NEXT: callq {{.*}}
28 # CHECK-NEXT: movb {{.*}} ## 0x[[#FOO + 8]]
29 # CHECK-NEXT: callq {{.*}}
31 .section __TEXT,__text
35 movl $
0x434241, _s
(%rip
) # X86_64_RELOC_SIGNED_4
37 movl $
0x44, _s+
2(%rip
) # X86_64_RELOC_SIGNED_2
39 movb $
0x45, _s
(%rip
) # X86_64_RELOC_SIGNED_1
45 movl $
0x2000004, %eax
# write() syscall
52 .section __TEXT,__not_text
53 ## Section relocations. We intentionally put them in a separate section since
54 ## the __text section typically starts at an address of zero in object files,
55 ## and so does not fully exercise the relocation logic.
56 movl $
0x434241, L._s
(%rip
) # X86_64_RELOC_SIGNED_4
58 movl $
0x44, L._s+
2(%rip
) # X86_64_RELOC_SIGNED_2
60 movb $
0x45, L._s
(%rip
) # X86_64_RELOC_SIGNED_1
64 .section __DATA,__data
69 ## Create a new section to force the assembler to use a section relocation for
70 ## the private symbol L._s. Otherwise, it will instead use a nearby non-private
71 ## symbol to create a symbol relocation plus an addend.
76 ## This symbol exists in order to split __foo into two subsections, thereby
77 ## testing that our code matches the relocations with the right target
78 ## subsection. In particular, although L._s+2 points to an address within _t's
79 ## subsection, it's defined relative to L._s, and should therefore be associated
80 ## with L._s' subsection.
82 ## We furthermore use an order file to rearrange these subsections so that a
83 ## mistake here will be obvious.
88 .subsections_via_symbols