brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 889f6b6 Raw
113 lines · plain
1// This test checks that the constant island offset and value is updated if2// it has dynamic relocation. The tests checks both .rela.dyn and relr.dyn3// dynamic relocations.4// Also check that we don't duplicate CI if it has dynamic relocations.5 6# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o7// .rela.dyn8# RUN: %clang %cflags -fPIC -pie %t.o -o %t.rela.exe -nostdlib \9# RUN:   -Wl,-q -Wl,-z,notext10# RUN: llvm-bolt %t.rela.exe -o %t.rela.bolt --use-old-text=0 --lite=011# RUN: llvm-objdump -j .text -d -z --show-all-symbols %t.rela.bolt | FileCheck %s12# RUN: llvm-readelf -rsW %t.rela.bolt | FileCheck --check-prefix=ELFCHECK %s13// .relr.dyn14# RUN: %clang %cflags -fPIC -pie %t.o -o %t.relr.exe -nostdlib \15# RUN:   -Wl,-q -Wl,-z,notext -Wl,--pack-dyn-relocs=relr16# RUN: llvm-objcopy --remove-section .rela.mytext %t.relr.exe17# RUN: llvm-bolt %t.relr.exe -o %t.relr.bolt --use-old-text=0 --lite=018# RUN: llvm-objdump -j .text -d -z --show-all-symbols %t.relr.bolt | FileCheck %s19# RUN: llvm-objdump -j .text -d -z %t.relr.bolt | \20# RUN:   FileCheck %s --check-prefix=ADDENDCHECK21# RUN: llvm-readelf -rsW %t.relr.bolt | FileCheck --check-prefix=RELRELFCHECK %s22# RUN: llvm-readelf -SW %t.relr.bolt | FileCheck --check-prefix=RELRSZCHECK %s23 24// Check that the CI value was updated25# CHECK: [[#%x,ADDR:]] <exitLocal>:26# CHECK: {{.*}} <$d>:27# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]28# CHECK-NEXT: {{.*}} .word 0x0000000029# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]30# CHECK-NEXT: {{.*}} .word 0x0000000031# CHECK-NEXT: {{.*}} .word 0x0000000032# CHECK-NEXT: {{.*}} .word 0x0000000033# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]34# CHECK-NEXT: {{.*}} .word 0x0000000035 36// Check that addend was properly patched in mytextP with stripped relocations37# ADDENDCHECK: [[#%x,ADDR:]] <exitLocal>:38# ADDENDCHECK: {{.*}} <mytextP>:39# ADDENDCHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]40# ADDENDCHECK-NEXT: {{.*}} .word 0x0000000041 42// Check that we've relaxed adr to adrp + add to refer external CI43# CHECK: <addressDynCi>:44# CHECK-NEXT: adrp45# CHECK-NEXT: add46 47// Check that relocation offsets were updated48# ELFCHECK: [[#%x,OFF:]] [[#%x,INFO_DYN:]] R_AARCH64_RELATIVE49# ELFCHECK-NEXT: [[#OFF + 8]] {{0*}}[[#INFO_DYN]] R_AARCH64_RELATIVE50# ELFCHECK-NEXT: [[#OFF + 24]] {{0*}}[[#INFO_DYN]] R_AARCH64_RELATIVE51# ELFCHECK-NEXT: {{.*}} R_AARCH64_RELATIVE52# ELFCHECK: {{.*}}[[#OFF]] {{.*}} $d53 54# RELRELFCHECK:       $d{{$}}55# RELRELFCHECK-NEXT:  $d + 0x8{{$}}56# RELRELFCHECK-NEXT:  $d + 0x18{{$}}57# RELRELFCHECK-NEXT:  mytextP58# RELRELFCHECK-EMPTY:59 60// Check that .relr.dyn size is 2 bytes to ensure that last 3 relocations were61// encoded as a bitmap so the total section size for 3 relocations is 2 bytes.62# RELRSZCHECK: .relr.dyn RELR [[#%x,ADDR:]] [[#%x,OFF:]] {{0*}}1063 64  .text65  .align 466  .local exitLocal67  .type exitLocal, %function68exitLocal:69  add x1, x1, #170  add x1, x1, #171  nop72  nop73  ret74  .size exitLocal, .-exitLocal75 76  .global _start77  .type _start, %function78_start:79  mov x0, #080  adr x1, .Lci81  ldr x1, [x1]82  blr x183  mov x0, #184  bl exitLocal85  nop86.Lci:87  .xword exitLocal88  .xword exitLocal89  .xword 090  .xword exitLocal91  .size _start, .-_start92 93  .global addressDynCi94  .type addressDynCi, %function95addressDynCi:96  adr x1, .Lci97  bl _start98.size addressDynCi, .-addressDynCi99 100  .section ".mytext", "ax"101  .balign 8102  .global dummy103  .type dummy, %function104dummy:105  nop106  .word 0107  .size dummy, .-dummy108 109  .global mytextP110mytextP:111  .xword exitLocal112  .size mytextP, .-mytextP113