2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: aarch64
|
2016-12-08 20:58:55 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %S/Inputs/shared2.s -o %t1.o
|
2019-07-19 14:33:36 +08:00
|
|
|
// RUN: ld.lld %t1.o --shared --soname=t.so -o %t.so
|
2016-12-08 20:58:55 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o
|
2017-10-06 17:37:44 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout
|
2019-07-19 14:33:36 +08:00
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
|
2016-12-08 20:58:55 +08:00
|
|
|
// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
|
2020-03-04 11:49:14 +08:00
|
|
|
// RUN: llvm-readobj --dynamic-table -r %tout | FileCheck %s
|
|
|
|
|
2021-02-09 00:55:28 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/shared2.s -o %t1.be.o
|
|
|
|
// RUN: ld.lld %t1.be.o --shared --soname=t.so -o %t.be.so
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
|
|
|
|
// RUN: ld.lld --hash-style=sysv %t.be.so %t.be.o -o %t.be
|
|
|
|
// RUN: llvm-objdump -d --no-show-raw-insn %t.be | FileCheck %s --check-prefix=DISASM
|
|
|
|
// RUN: llvm-objdump -s %t.be | FileCheck %s --check-prefix=GOTPLT_BE
|
|
|
|
// RUN: llvm-readobj --dynamic-table -r %t.be | FileCheck %s
|
|
|
|
|
2020-03-04 11:49:14 +08:00
|
|
|
// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
|
|
|
|
// CHECK: DynamicSection [
|
|
|
|
// CHECK: 0x0000000000000008 RELASZ 48 (bytes)
|
|
|
|
// CHECK: 0x0000000000000002 PLTRELSZ 48 (bytes)
|
2016-12-08 20:58:55 +08:00
|
|
|
|
|
|
|
// Check that the IRELATIVE relocations are after the JUMP_SLOT in the plt
|
|
|
|
// CHECK: Relocations [
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Section (4) .rela.dyn {
|
2019-08-20 16:34:56 +08:00
|
|
|
// CHECK-NEXT: 0x230468 R_AARCH64_IRELATIVE - 0x2102D8
|
|
|
|
// CHECK-NEXT: 0x230470 R_AARCH64_IRELATIVE - 0x2102DC
|
2016-12-08 20:58:55 +08:00
|
|
|
// CHECK-NEXT: }
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: Section (5) .rela.plt {
|
2019-08-20 16:34:56 +08:00
|
|
|
// CHECK-NEXT: 0x230458 R_AARCH64_JUMP_SLOT bar2 0x0
|
|
|
|
// CHECK-NEXT: 0x230460 R_AARCH64_JUMP_SLOT zed2 0x0
|
2019-08-03 10:26:52 +08:00
|
|
|
// CHECK-NEXT: }
|
2016-12-08 20:58:55 +08:00
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
|
|
|
// Check that .got.plt entries point back to PLT header
|
|
|
|
// GOTPLT: Contents of section .got.plt:
|
2019-08-20 16:34:56 +08:00
|
|
|
// GOTPLT-NEXT: 230440 00000000 00000000 00000000 00000000
|
|
|
|
// GOTPLT-NEXT: 230450 00000000 00000000 f0022100 00000000
|
2020-01-10 03:59:28 +08:00
|
|
|
// GOTPLT-NEXT: 230460 f0022100 00000000 00000000 00000000
|
|
|
|
// GOTPLT-NEXT: 230470 00000000 00000000
|
2016-12-08 20:58:55 +08:00
|
|
|
|
2021-02-09 00:55:28 +08:00
|
|
|
// GOTPLT_BE: Contents of section .got.plt:
|
|
|
|
// GOTPLT_BE-NEXT: 230440 00000000 00000000 00000000 00000000
|
|
|
|
// GOTPLT_BE-NEXT: 230450 00000000 00000000 00000000 002102f0
|
|
|
|
// GOTPLT_BE-NEXT: 230460 00000000 002102f0 00000000 00000000
|
|
|
|
// GOTPLT_BE-NEXT: 230470 00000000 00000000
|
|
|
|
|
2016-12-08 20:58:55 +08:00
|
|
|
// Check that a PLT header is written and the ifunc entries appear last
|
|
|
|
// DISASM: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <foo>:
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 2102d8: ret
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM: <bar>:
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 2102dc: ret
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM: <_start>:
|
2020-04-10 09:46:35 +08:00
|
|
|
// DISASM-NEXT: 2102e0: bl 0x210330 <zed2+0x210330>
|
|
|
|
// DISASM-NEXT: 2102e4: bl 0x210340 <zed2+0x210340>
|
|
|
|
// DISASM-NEXT: 2102e8: bl 0x210310 <bar2@plt>
|
|
|
|
// DISASM-NEXT: 2102ec: bl 0x210320 <zed2@plt>
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2016-12-08 20:58:55 +08:00
|
|
|
// DISASM-NEXT: Disassembly of section .plt:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <.plt>:
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 2102f0: stp x16, x30, [sp, #-16]!
|
2020-12-17 01:20:55 +08:00
|
|
|
// DISASM-NEXT: 2102f4: adrp x16, 0x230000
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 2102f8: ldr x17, [x16, #1104]
|
|
|
|
// DISASM-NEXT: 2102fc: add x16, x16, #1104
|
|
|
|
// DISASM-NEXT: 210300: br x17
|
|
|
|
// DISASM-NEXT: 210304: nop
|
|
|
|
// DISASM-NEXT: 210308: nop
|
|
|
|
// DISASM-NEXT: 21030c: nop
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <bar2@plt>:
|
2020-12-17 01:20:55 +08:00
|
|
|
// DISASM-NEXT: 210310: adrp x16, 0x230000
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 210314: ldr x17, [x16, #1112]
|
|
|
|
// DISASM-NEXT: 210318: add x16, x16, #1112
|
|
|
|
// DISASM-NEXT: 21031c: br x17
|
2018-08-25 00:22:42 +08:00
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <zed2@plt>:
|
2020-12-17 01:20:55 +08:00
|
|
|
// DISASM-NEXT: 210320: adrp x16, 0x230000
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 210324: ldr x17, [x16, #1120]
|
|
|
|
// DISASM-NEXT: 210328: add x16, x16, #1120
|
|
|
|
// DISASM-NEXT: 21032c: br x17
|
2019-12-15 08:19:03 +08:00
|
|
|
// DISASM-EMPTY:
|
|
|
|
// DISASM-NEXT: Disassembly of section .iplt:
|
|
|
|
// DISASM-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DISASM-NEXT: <.iplt>:
|
2020-12-17 01:20:55 +08:00
|
|
|
// DISASM-NEXT: 210330: adrp x16, 0x230000
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 210334: ldr x17, [x16, #1128]
|
|
|
|
// DISASM-NEXT: 210338: add x16, x16, #1128
|
|
|
|
// DISASM-NEXT: 21033c: br x17
|
2020-12-17 01:20:55 +08:00
|
|
|
// DISASM-NEXT: 210340: adrp x16, 0x230000
|
2019-08-20 16:34:56 +08:00
|
|
|
// DISASM-NEXT: 210344: ldr x17, [x16, #1136]
|
|
|
|
// DISASM-NEXT: 210348: add x16, x16, #1136
|
|
|
|
// DISASM-NEXT: 21034c: br x17
|
2016-12-08 20:58:55 +08:00
|
|
|
|
|
|
|
.text
|
|
|
|
.type foo STT_GNU_IFUNC
|
|
|
|
.globl foo
|
|
|
|
foo:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.type bar STT_GNU_IFUNC
|
|
|
|
.globl bar
|
|
|
|
bar:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
bl foo
|
|
|
|
bl bar
|
|
|
|
bl bar2
|
|
|
|
bl zed2
|