brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · 00643c8 Raw
89 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o3# RUN: echo _t > %t.order4# RUN: %lld -o %t -order_file %t.order %t.o5# RUN: llvm-objdump --section-headers --syms -D %t | FileCheck %s6 7# CHECK-LABEL: Sections:8# CHECK:       __foo         {{[0-9a-f]+}}  [[#%x,FOO:]]  DATA9 10# CHECK-LABEL: SYMBOL TABLE:11# CHECK:       [[#%x,S:]]  g     O __DATA,__data _s12 13# CHECK-LABEL: Disassembly of section14# CHECK:      <_main>: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 {{.*}}30 31.section __TEXT,__text32.globl _main33_main:34  ## Symbol relocations35  movl $0x434241, _s(%rip)  # X86_64_RELOC_SIGNED_436  callq _f37  movl $0x44, _s+2(%rip)    # X86_64_RELOC_SIGNED_238  callq _f39  movb $0x45, _s(%rip)      # X86_64_RELOC_SIGNED_140  callq _f41  xorq %rax, %rax42  ret43 44_f:45  movl $0x2000004, %eax # write() syscall46  mov $1, %rdi # stdout47  leaq _s(%rip), %rsi48  mov $3, %rdx # length49  syscall50  ret51 52.section __TEXT,__not_text53  ## Section relocations. We intentionally put them in a separate section since54  ## 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_457  callq _f58  movl $0x44, L._s+2(%rip)    # X86_64_RELOC_SIGNED_259  callq _f60  movb $0x45, L._s(%rip)      # X86_64_RELOC_SIGNED_161  callq _f62  ret63 64.section __DATA,__data65.globl _s66_s:67  .space 568 69## Create a new section to force the assembler to use a section relocation for70## the private symbol L._s. Otherwise, it will instead use a nearby non-private71## symbol to create a symbol relocation plus an addend.72.section __DATA,__foo73L._s:74  .space 175 76## This symbol exists in order to split __foo into two subsections, thereby77## testing that our code matches the relocations with the right target78## subsection. In particular, although L._s+2 points to an address within _t's79## subsection, it's defined relative to L._s, and should therefore be associated80## with L._s' subsection.81##82## We furthermore use an order file to rearrange these subsections so that a83## mistake here will be obvious.84.globl _t85_t:86  .quad 12387 88.subsections_via_symbols89