brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · d29f689 Raw
81 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o3# RUN: %lld -lSystem -o %t %t.o4# RUN: llvm-objdump --no-print-imm-hex --section-headers --syms -d %t | FileCheck %s5 6# CHECK-LABEL: Sections:7# CHECK:       __branch_target {{[0-9a-z]+}} [[#%x, BRANCH_SECT:]]8# CHECK:       __data {{[0-9a-z]+}} [[#%x, DATA_ADDR:]]9 10# CHECK-LABEL: SYMBOL TABLE:11# CHECK-DAG:   [[#%x, F_ADDR:]] {{.*}} _f12# CHECK-DAG:   [[#%x, G_ADDR:]] {{.*}} _g13 14# CHECK-LABEL: <_main>:15## Test X86_64_RELOC_BRANCH16## Test symbol (extern) relocations first (most common case)17# CHECK:       callq 0x[[#%x, F_ADDR]] <_f>18# CHECK:       jrcxz 0x[[#%x, F_ADDR]] <_f>19# CHECK:       callq 0x[[#%x, G_ADDR]] <_g>20# CHECK:       jrcxz 0x[[#%x, G_ADDR]] <_g>21## Test section (local) BRANCH relocations22# CHECK:       callq 0x[[#%x, BRANCH_SECT]]23## NOTE: ld64 rejects 1-byte local branch relocations as unsupported, but it24## doesn't take any extra code for us to support it25# CHECK:       jrcxz 0x[[#%x, BRANCH_SECT]]26 27# CHECK-LABEL: <_f>:28## Test extern (symbol) X86_64_RELOC_SIGNED29# CHECK:       leaq [[#%u, LOCAL_OFF:]](%rip), %rsi30# CHECK-NEXT:  [[#%x, DATA_ADDR - LOCAL_OFF]]31## Test non-extern (section) X86_64_RELOC_SIGNED32# CHECK:       leaq [[#%u, PRIVATE_OFF:]](%rip), %rsi33# CHECK-NEXT:  [[#%x, DATA_ADDR + 8 - PRIVATE_OFF]]34 35# RUN: llvm-objdump --section=__const --full-contents %t | FileCheck %s --check-prefix=NONPCREL36# NONPCREL:      Contents of section __DATA_CONST,__const:37# NONPCREL-NEXT: 100001000 08200000 01000000 08200000 0100000038 39.section __TEXT,__text40.globl _main, _f, _g41 42_main:43  callq _f # X86_64_RELOC_BRANCH with r_length=244  jrcxz _f # X86_64_RELOC_BRANCH with r_length=045  # Test negative addends46  callq _f - 147  jrcxz _f - 148  # Test section relocations49  callq L_.branch_target50  jrcxz L_.branch_target51  mov $0, %rax52  ret53 54_g:55 .byte 0x056 57_f:58  leaq _local(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel symbol relocation59  leaq L_.private(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel section relocation60  movq L_.ptr_1(%rip), %rsi61  ret62 63.section __TEXT,__branch_target64L_.branch_target:65  ret66 67.data68## References to this generate a symbol relocation69_local:70  .quad 12371## References to this generate a section relocation72L_.private:73  .quad 12374 75.section __DATA,__const76## These generate X86_64_RELOC_UNSIGNED non-pcrel section relocations77L_.ptr_1:78  .quad L_.private79L_.ptr_2:80  .quad L_.private81