Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / aarch64-combined-dynrel-ifunc.s
blobfa0f10eb8941b037c6db11ec35ace31e8efd7b3d
1 // REQUIRES: aarch64
2 // RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %p/Inputs/shared.s -o %t-lib.o
3 // RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t.o
4 // RUN: ld.lld %t-lib.o --shared -o %t.so
5 // RUN: echo "SECTIONS { \
6 // RUN: .text : { *(.text) } \
7 // RUN: .rela.dyn : { *(.rela.dyn) *(.rela.plt) } \
8 // RUN: } " > %t.script
9 // RUN: ld.lld %t.o -o %t.axf %t.so --script %t.script
10 // RUN: llvm-readobj --section-headers --dynamic-table %t.axf | FileCheck %s
12 // The linker script above combines the .rela.dyn and .rela.plt into a single
13 // table. ELF is clear that the DT_PLTRELSZ should match the subset of
14 // relocations that is associated with the PLT. It is less clear about what
15 // the value of DT_RELASZ should be. ELF implies that it should be the size
16 // of the single table so that DT_RELASZ includes DT_PLTRELSZ. The loader in
17 // glibc permits this as long as .rela.plt comes after .rela.dyn in the
18 // combined table. In the ARM case irelative relocations do not count as PLT
19 // relocs. In the AArch64 case irelative relocations count as PLT relocs.
21 .text
22 .globl indirect
23 .type indirect,@gnu_indirect_function
24 indirect:
25 ret
27 .globl bar // from Inputs/shared.s
29 .text
30 .globl _start
31 .type _start,@function
32 main:
33 bl indirect
34 bl bar
35 adrp x8, :got:indirect
36 ldr x8, [x8, :got_lo12:indirect]
37 adrp x8, :got:bar
38 ldr x8, [x8, :got_lo12:bar]
39 ret
41 // CHECK: Name: .rela.dyn
42 // CHECK-NEXT: Type: SHT_RELA
43 // CHECK-NEXT: Flags [
44 // CHECK-NEXT: SHF_ALLOC
45 // CHECK-NEXT: SHF_INFO_LINK
46 // CHECK-NEXT: ]
47 // CHECK-NEXT: Address:
48 // CHECK-NEXT: Offset:
49 // CHECK-NEXT: Size: 72
51 // CHECK: 0x0000000000000008 RELASZ 72
52 // CHECK: 0x0000000000000002 PLTRELSZ 24