brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 7a15744 Raw
57 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o3# RUN: %lld -o %t %t.o4# RUN: llvm-objdump --macho --rebase --full-contents %t | FileCheck %s5 6# RUN: %lld -pie -o %t-pie %t.o7# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE8# RUN: %lld -pie -no_pie -o %t-no-pie %t.o9# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s --check-prefix=NO-PIE10# RUN: %lld -no_pie -pie -o %t-pie %t.o11# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE12 13# CHECK:       Contents of section __DATA,foo:14# CHECK-NEXT:  100001000 08100000 0100000015# CHECK:       Contents of section __DATA,bar:16# CHECK-NEXT:  100001008 011000f0 11211111 0200000017 18# PIE:      Rebase table:19# PIE-NEXT: segment  section            address           type20# PIE-DAG:  __DATA   foo                0x[[#%X,ADDR:]]   pointer21# PIE-DAG:  __DATA   bar                0x[[#ADDR + 8]]   pointer22# PIE-DAG:  __DATA   bar                0x[[#ADDR + 12]]  pointer23# PIE-DAG:  __DATA   baz                0x[[#ADDR + 20]]  pointer24 25# NO-PIE:      Rebase table:26# NO-PIE-NEXT: segment  section            address           type27# NO-PIE-EMPTY:28 29.globl _main, _foo, _bar30 31.section __DATA,foo32_foo:33.quad _bar34 35.section __DATA,bar36_bar:37## We create a .int symbol reference here -- with non-zero data immediately38## after -- to check that lld reads precisely 32 bits (and not more) of the39## implicit addend when handling unsigned relocations of r_length = 2.40## Note that __PAGEZERO occupies the lower 32 bits, so all symbols are above41## that. To get a final relocated address that fits within 32 bits, we need to42## subtract an offset here.43.int _foo - 0x0fffffff44## The unsigned relocation should support 64-bit addends too (r_length = 3).45.quad _foo + 0x11111111146 47.section __DATA,baz48## Generates a section relocation.49.quad L_.baz50L_.baz:51  .space 052 53.text54_main:55  mov $0, %rax56  ret57