79 lines · plain
1# REQUIRES: aarch642# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o3 4# RUN: ld.lld --no-relax %t.o -o %t5# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck %s --check-prefix=PDE6# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=PDE-RELOC7 8# RUN: ld.lld -pie --no-relax %t.o -o %t9# RUN: ld.lld -pie --no-relax --apply-dynamic-relocs %t.o -o %t.apply10# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck %s --check-prefix=PIE11# RUN: llvm-readobj -r -x .got.plt %t | FileCheck %s --check-prefixes=PIE-RELOC,NO-APPLY12# RUN: llvm-readobj -r -x .got.plt %t.apply | FileCheck %s --check-prefixes=PIE-RELOC,APPLY13 14## When compiling with -fno-PIE or -fPIE, if the ifunc is in the same15## translation unit as the address taker, the compiler knows that ifunc is not16## defined in a shared library so it can use a non GOT generating relative reference.17.text18.globl myfunc19.type myfunc,@gnu_indirect_function20myfunc:21.globl myfunc_resolver22.type myfunc_resolver,@function23myfunc_resolver:24 ret25 26.text27.globl main28.type main,@function29main:30 adrp x8, myfunc31 add x8, x8, :lo12: myfunc32 ret33 34## The address of myfunc is the address of the PLT entry for myfunc.35# PDE: <myfunc_resolver>:36# PDE-NEXT: 210170: ret37# PDE: <main>:38# PDE-NEXT: 210174: adrp x8, 0x21000039# PDE-NEXT: 210178: add x8, x8, #38440# PDE-NEXT: 21017c: ret41# PDE-EMPTY:42# PDE-NEXT: Disassembly of section .iplt:43# PDE-EMPTY:44# PDE-NEXT: <myfunc>:45## page(.got.plt) - page(0x210010) = 6553646# PDE-NEXT: 210180: adrp x16, 0x22000047# PDE-NEXT: 210184: ldr x17, [x16, #400]48# PDE-NEXT: 210188: add x16, x16, #40049# PDE-NEXT: 21018c: br x1750 51## The adrp to myfunc should generate a PLT entry and a GOT entry with an52## irelative relocation.53# PDE-RELOC: .rela.dyn {54# PDE-RELOC-NEXT: 0x220190 R_AARCH64_IRELATIVE - 0x21017055# PDE-RELOC-NEXT: }56 57# PIE: <myfunc_resolver>:58# PIE-NEXT: 10260: ret59# PIE: <main>:60# PIE-NEXT: 10264: adrp x8, 0x1000061# PIE-NEXT: 10268: add x8, x8, #62462# PIE-NEXT: 1026c: ret63# PIE-EMPTY:64# PIE-NEXT: Disassembly of section .iplt:65# PIE-EMPTY:66# PIE-NEXT: <myfunc>:67# PIE-NEXT: 10270: adrp x16, 0x3000068# PIE-NEXT: ldr x17, [x16, #832]69# PIE-NEXT: add x16, x16, #83270# PIE-NEXT: br x1771 72# PIE-RELOC: .rela.dyn {73# PIE-RELOC-NEXT: 0x30340 R_AARCH64_IRELATIVE - 0x1026074# PIE-RELOC-NEXT: }75# PIE-RELOC: Hex dump of section '.got.plt':76# NO-APPLY: 0x00030340 00000000 0000000077# APPLY: 0x00030340 60020100 0000000078# PIE-RELOC-EMPTY:79