2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: arm
|
2016-06-16 17:53:46 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %p/Inputs/arm-plt-reloc.s -o %t1
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t2
|
|
|
|
// RUN: ld.lld %t1 %t2 -o %t
|
2020-03-16 08:47:44 +08:00
|
|
|
// RUN: llvm-objdump --triple=thumbv7a-none-linux-gnueabi -d %t | FileCheck %s
|
2019-08-27 19:52:36 +08:00
|
|
|
// RUN: ld.lld -shared %t1 %t2 -o %t.so
|
2020-03-16 08:47:44 +08:00
|
|
|
// RUN: llvm-objdump --triple=thumbv7a-none-linux-gnueabi -d %t.so | FileCheck --check-prefix=DSO %s
|
2019-08-27 19:50:27 +08:00
|
|
|
// RUN: llvm-readobj -S -r %t.so | FileCheck -check-prefix=DSOREL %s
|
2016-06-16 17:53:46 +08:00
|
|
|
//
|
|
|
|
// Test PLT entry generation
|
|
|
|
.syntax unified
|
|
|
|
.text
|
|
|
|
.align 2
|
|
|
|
.globl _start
|
|
|
|
.type _start,%function
|
|
|
|
_start:
|
|
|
|
// FIXME, interworking is only supported for BL via BLX at the moment, when
|
|
|
|
// interworking thunks are available for b.w and b<cond>.w this can be altered
|
|
|
|
// to test the different forms of interworking.
|
|
|
|
bl func1
|
|
|
|
bl func2
|
|
|
|
bl func3
|
|
|
|
|
|
|
|
// Executable, expect no PLT
|
|
|
|
// CHECK: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK-NEXT: <func1>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// CHECK-NEXT: 200b4: 70 47 bx lr
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <func2>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// CHECK-NEXT: 200b6: 70 47 bx lr
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <func3>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// CHECK-NEXT: 200b8: 70 47 bx lr
|
|
|
|
// CHECK-NEXT: 200ba: d4 d4
|
2020-03-06 06:18:38 +08:00
|
|
|
// CHECK: <_start>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// . + 4 -12 = 0x200b4 = func1
|
|
|
|
// CHECK-NEXT: 200bc: ff f7 fa ff bl #-12
|
|
|
|
// . + 4 -14 = 0x200b6 = func2
|
|
|
|
// CHECK-NEXT: 200c0: ff f7 f9 ff bl #-14
|
|
|
|
// . + 4 -16 = 0x200b8 = func3
|
|
|
|
// CHECK-NEXT: 200c4: ff f7 f8 ff bl #-16
|
2016-06-16 17:53:46 +08:00
|
|
|
|
|
|
|
// Expect PLT entries as symbols can be preempted
|
|
|
|
// .text is Thumb and .plt is ARM, llvm-objdump can currently only disassemble
|
|
|
|
// as ARM or Thumb. Work around by disassembling twice.
|
2019-08-21 23:30:55 +08:00
|
|
|
// DSO: Disassembly of section .text:
|
|
|
|
// DSO-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO-NEXT: <func1>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 10214: 70 47 bx lr
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <func2>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 10216: 70 47 bx lr
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <func3>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 10218: 70 47 bx lr
|
|
|
|
// DSO-NEXT: 1021a: d4 d4 bmi #-88
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <_start>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// . + 48 + 4 = 0x10250 = PLT func1
|
|
|
|
// DSO-NEXT: 1021c: 00 f0 18 e8 blx #48
|
|
|
|
// . + 60 + 4 = 0x10260 = PLT func2
|
|
|
|
// DSO-NEXT: 10220: 00 f0 1e e8 blx #60
|
|
|
|
// . + 72 + 4 = 0x10270 = PLT func3
|
|
|
|
// DSO-NEXT: 10224: 00 f0 24 e8 blx #72
|
2019-08-21 23:30:55 +08:00
|
|
|
// DSO: Disassembly of section .plt:
|
|
|
|
// DSO-EMPTY:
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO-NEXT: <$a>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 10230: 04 e0 2d e5 str lr, [sp, #-4]!
|
|
|
|
// (0x10234 + 8) + (0 RoR 12) + 8192 + 164 = 0x32e0 = .got.plt[3]
|
|
|
|
// DSO-NEXT: 10234: 00 e6 8f e2 add lr, pc, #0, #12
|
|
|
|
// DSO-NEXT: 10238: 20 ea 8e e2 add lr, lr, #32
|
|
|
|
// DSO-NEXT: 1023c: a4 f0 be e5 ldr pc, [lr, #164]!
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <$d>:
|
2017-12-18 22:46:27 +08:00
|
|
|
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 10240: d4 d4 d4 d4 .word 0xd4d4d4d4
|
|
|
|
// DSO-NEXT: 10244: d4 d4 d4 d4 .word 0xd4d4d4d4
|
|
|
|
// DSO-NEXT: 10248: d4 d4 d4 d4 .word 0xd4d4d4d4
|
|
|
|
// DSO-NEXT: 1024c: d4 d4 d4 d4 .word 0xd4d4d4d4
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <$a>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// (0x10250 + 8) + (0 RoR 12) + 8192 + 140 = 0x32e4
|
|
|
|
// DSO-NEXT: 10250: 00 c6 8f e2 add r12, pc, #0, #12
|
|
|
|
// DSO-NEXT: 10254: 20 ca 8c e2 add r12, r12, #32
|
|
|
|
// DSO-NEXT: 10258: 8c f0 bc e5 ldr pc, [r12, #140]!
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <$d>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 1025c: d4 d4 d4 d4 .word 0xd4d4d4d4
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <$a>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// (0x10260 + 8) + (0 RoR 12) + 8192 + 128 = 0x32e8
|
|
|
|
// DSO-NEXT: 10260: 00 c6 8f e2 add r12, pc, #0, #12
|
|
|
|
// DSO-NEXT: 10264: 20 ca 8c e2 add r12, r12, #32
|
|
|
|
// DSO-NEXT: 10268: 80 f0 bc e5 ldr pc, [r12, #128]!
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <$d>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 1026c: d4 d4 d4 d4 .word 0xd4d4d4d4
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <$a>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// (0x10270 + 8) + (0 RoR 12) + 8192 + 116 = 0x32ec
|
|
|
|
// DSO-NEXT: 10270: 00 c6 8f e2 add r12, pc, #0, #12
|
|
|
|
// DSO-NEXT: 10274: 20 ca 8c e2 add r12, r12, #32
|
|
|
|
// DSO-NEXT: 10278: 74 f0 bc e5 ldr pc, [r12, #116]!
|
2020-03-06 06:18:38 +08:00
|
|
|
// DSO: <$d>:
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSO-NEXT: 1027c: d4 d4 d4 d4 .word 0xd4d4d4d4
|
2016-06-16 17:53:46 +08:00
|
|
|
|
|
|
|
// DSOREL: Name: .got.plt
|
|
|
|
// DSOREL-NEXT: Type: SHT_PROGBITS
|
|
|
|
// DSOREL-NEXT: Flags [
|
|
|
|
// DSOREL-NEXT: SHF_ALLOC
|
|
|
|
// DSOREL-NEXT: SHF_WRITE
|
|
|
|
// DSOREL-NEXT: ]
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSOREL-NEXT: Address: 0x302D8
|
2016-06-16 17:53:46 +08:00
|
|
|
// DSOREL-NEXT: Offset:
|
|
|
|
// DSOREL-NEXT: Size: 24
|
|
|
|
// DSOREL-NEXT: Link:
|
|
|
|
// DSOREL-NEXT: Info:
|
|
|
|
// DSOREL-NEXT: AddressAlignment: 4
|
|
|
|
// DSOREL-NEXT: EntrySize:
|
|
|
|
// DSOREL: Relocations [
|
2019-08-27 19:52:36 +08:00
|
|
|
// DSOREL-NEXT: Section (5) .rel.plt {
|
2020-04-18 23:06:37 +08:00
|
|
|
// DSOREL-NEXT: 0x302E4 R_ARM_JUMP_SLOT func1 0x0
|
|
|
|
// DSOREL-NEXT: 0x302E8 R_ARM_JUMP_SLOT func2 0x0
|
|
|
|
// DSOREL-NEXT: 0x302EC R_ARM_JUMP_SLOT func3 0x0
|