1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o 3# RUN: %lld -o %t %t.o 4# RUN: llvm-objdump -D %t | FileCheck %s 5 6# CHECK: <_main>: 7# CHECK-NEXT: movl {{.*}} # 100001000 <_s> 8# CHECK-NEXT: callq {{.*}} 9# CHECK-NEXT: movl {{.*}} # 100001002 <_s+0x2> 10# CHECK-NEXT: callq {{.*}} 11# CHECK-NEXT: movb {{.*}} # 100001000 <_s> 12# CHECK-NEXT: callq {{.*}} 13# CHECK: <__not_text>: 14# CHECK-NEXT: movl {{.*}} # 100001005 15# CHECK-NEXT: callq {{.*}} 16# CHECK-NEXT: movl {{.*}} # 100001007 17# CHECK-NEXT: callq {{.*}} 18# CHECK-NEXT: movb {{.*}} # 100001005 19# CHECK-NEXT: callq {{.*}} 20 21.section __TEXT,__text 22.globl _main 23_main: 24 ## Symbol relocations 25 movl $0x434241, _s(%rip) # X86_64_RELOC_SIGNED_4 26 callq _f 27 movl $0x44, _s+2(%rip) # X86_64_RELOC_SIGNED_2 28 callq _f 29 movb $0x45, _s(%rip) # X86_64_RELOC_SIGNED_1 30 callq _f 31 xorq %rax, %rax 32 ret 33 34_f: 35 movl $0x2000004, %eax # write() syscall 36 mov $1, %rdi # stdout 37 leaq _s(%rip), %rsi 38 mov $3, %rdx # length 39 syscall 40 ret 41 42.section __TEXT,__not_text 43 ## Section relocations. We intentionally put them in a separate section since 44 ## the __text section typically starts at an address of zero in object files, 45 ## and so does not fully exercise the relocation logic. 46 movl $0x434241, L._s(%rip) # X86_64_RELOC_SIGNED_4 47 callq _f 48 movl $0x44, L._s+2(%rip) # X86_64_RELOC_SIGNED_2 49 callq _f 50 movb $0x45, L._s(%rip) # X86_64_RELOC_SIGNED_1 51 callq _f 52 ret 53 54.section __DATA,__data 55.globl _s 56_s: 57 .space 5 58 59## Create a new section to force the assembler to use a section relocation for 60## the private symbol L._s. Otherwise, it will instead use a nearby non-private 61## symbol to create a symbol relocation plus an addend. 62.section __DATA,__foo 63L._s: 64 .space 5 65