1# REQUIRES: aarch64
2# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
3# RUN: ld.lld %t.o -o %t
4# RUN: llvm-readelf -S -s %t | FileCheck %s --check-prefix=SEC
5# RUN: llvm-readelf -x .rodata -x .data %t | FileCheck --check-prefix=HEX %s
6# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=RELOC
7
8## ifunc is a non-preemptable STT_GNU_IFUNC. Check we create a canonical PLT
9## and redirect .rodata and .data references to it.
10
11# SEC: .text    PROGBITS 0000000000210178
12# SEC: .got.plt PROGBITS 0000000000220198
13# SEC: 0000000000210180 0 FUNC GLOBAL DEFAULT 4 ifunc
14
15## .rodata[0] and .data[0] store the address of the canonical PLT.
16# HEX:      section '.rodata':
17# HEX-NEXT: 0x00200170 80012100 00000000
18# HEX:      section '.data':
19# HEX-NEXT: 0x00220190 80012100 00000000
20
21# RELOC:      .rela.dyn {
22# RELOC-NEXT:   0x220198 R_AARCH64_IRELATIVE - 0x210178
23# RELOC-NEXT: }
24
25.globl ifunc
26.type ifunc,@gnu_indirect_function
27ifunc:
28  ret
29
30.rodata
31.p2align 3
32.xword ifunc
33
34.data
35.p2align 3
36.xword ifunc
37