99 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t && split-file %s %t && cd %t3# RUN: llvm-mc -filetype=obj -triple=x86_64 -crel a.s -o a.o4# RUN: llvm-mc -filetype=obj -triple=x86_64 -crel b.s -o b.o5# RUN: ld.lld -pie a.o b.o -o out6# RUN: llvm-objdump -d out | FileCheck %s7# RUN: llvm-readelf -Srs out | FileCheck %s --check-prefix=RELOC8# RUN: llvm-dwarfdump --eh-frame out | FileCheck %s --check-prefix=UNWIND9 10# CHECK: <_start>:11# CHECK-NEXT: callq {{.*}} <foo>12# CHECK-NEXT: callq {{.*}} <foo>13# CHECK-EMPTY:14# CHECK-NEXT: <foo>:15# CHECK-NEXT: leaq {{.*}} # 0x27c16# CHECK-NEXT: leaq {{.*}} # 0x27817 18# RELOC: .data PROGBITS {{0*}}[[#%x,DATA:]]19 20# RELOC: {{0*}}[[#DATA+8]] 0000000000000008 R_X86_64_RELATIVE [[#%x,DATA+0x8000000000000000]]21 22# RELOC: 00000000000012f4 0 NOTYPE GLOBAL DEFAULT [[#]] _start23# RELOC-NEXT: 00000000000012fe 0 NOTYPE GLOBAL DEFAULT [[#]] foo24 25## initial_location fields in FDEs are correctly relocated.26# UNWIND: 00000018 00000010 0000001c FDE cie=00000000 pc=000012f4...000012fe27# UNWIND: 0000002c 00000010 00000030 FDE cie=00000000 pc=000012fe...0000130c28 29# RUN: ld.lld -pie --emit-relocs a.o b.o -o out130# RUN: llvm-objdump -dr out1 | FileCheck %s --check-prefix=CHECKE31# RUN: llvm-readelf -Sr out1 | FileCheck %s --check-prefix=RELOCE32 33# CHECKE: <_start>:34# CHECKE-NEXT: callq {{.*}} <foo>35# CHECKE-NEXT: R_X86_64_PLT32 foo-0x436# CHECKE-NEXT: callq {{.*}} <foo>37# CHECKE-NEXT: R_X86_64_PLT32 .text+0x638# CHECKE-EMPTY:39# CHECKE-NEXT: <foo>:40# CHECKE-NEXT: leaq {{.*}}41# CHECKE-NEXT: R_X86_64_PC32 .L.str-0x442# CHECKE-NEXT: leaq {{.*}}43# CHECKE-NEXT: R_X86_64_PC32 .L.str1-0x444 45# RELOCE: .rodata PROGBITS {{0*}}[[#%x,RO:]]46# RELOCE: .eh_frame PROGBITS {{0*}}[[#%x,EHFRAME:]]47# RELOCE: .data PROGBITS {{0*}}[[#%x,DATA:]]48 49# RELOCE: Relocation section '.crel.data' at offset {{.*}} contains 2 entries:50# RELOCE-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend51# RELOCE-NEXT: {{0*}}[[#DATA+8]] {{.*}} R_X86_64_64 {{.*}} .data - 800000000000000052# RELOCE-NEXT: {{0*}}[[#DATA+24]]{{.*}} R_X86_64_64 {{.*}} .data - 153# RELOCE: Relocation section '.crel.eh_frame' at offset {{.*}} contains 2 entries:54# RELOCE-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend55# RELOCE-NEXT: {{0*}}[[#EHFRAME+32]] {{.*}} R_X86_64_PC32 {{.*}} .text + 056# RELOCE-NEXT: {{0*}}[[#EHFRAME+52]] {{.*}} R_X86_64_PC32 {{.*}} .text + a57# RELOCE: Relocation section '.crel.rodata' at offset {{.*}} contains 4 entries:58# RELOCE-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend59# RELOCE-NEXT: {{0*}}[[#RO+8]] {{.*}} R_X86_64_PC32 {{.*}} foo + 060# RELOCE-NEXT: {{0*}}[[#RO+23]] {{.*}} R_X86_64_PC32 {{.*}} foo + 3f61# RELOCE-NEXT: {{0*}}[[#RO+39]] {{.*}} R_X86_64_PC64 {{.*}} foo + 7f62# RELOCE-NEXT: {{0*}}[[#RO+47]] {{.*}} R_X86_64_PC32 {{.*}} _start - 1f8163 64#--- a.s65.global _start, foo66_start:67 .cfi_startproc # Test .eh_frame68 call foo69 call .text.foo70 .cfi_endproc71 72.section .text.foo,"ax"73foo:74 .cfi_startproc75 leaq .L.str(%rip), %rsi76 leaq .L.str1(%rip), %rsi77 .cfi_endproc78 79.section .rodata.str1.1,"aMS",@progbits,180.L.str:81 .asciz "abc"82.L.str1:83 .asciz "def"84 85.data86.quad 087.quad .data - 0x800000000000000088.quad 089.quad .data - 190 91#--- b.s92.section .rodata,"a"93.long foo - .94.space 15-495.long foo - . + 63 # offset+=1596.space 16-497.quad foo - . + 127 # offset+=1698.long _start - . - 806599