Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cross-project-tests/tools/llvm-objdump/ARM/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
if "ARM" not in config.targets_to_build:
config.unsupported = True
245 changes: 245 additions & 0 deletions cross-project-tests/tools/llvm-objdump/ARM/plt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
// Test PLT section parsing on arm.

// REQUIRES: ld.lld

// RUN: %clang --target=armv6a-none-linux-gnueabi -fuse-ld=lld \
// RUN: -nostdlib -nostdinc -shared %s -o %t.v6a
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
Copy link
Member

@MaskRay MaskRay Mar 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tet tests v6a/v8m & LE/BE. Perhaps use a more meaningful executable name, say, %tv6 %tv6.be than %t1.

// RUN: -d %t.v6a | FileCheck %s --check-prefixes=CHECK,LE

// Test PLT section parsing on armeb.

// RUN: %clang --target=armv6aeb-none-linux-gnueabi -fuse-ld=lld \
// RUN: -nostdlib -nostdinc -shared %s -o %t.v6aeb
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v6aeb | FileCheck %s --check-prefixes=CHECK,BE
// RUN: obj2yaml %t.v6aeb | FileCheck %s --check-prefixes=NOBE8

// Test PLT section parsing on armeb with be8.

// RUN: %clang --target=armv7aeb-none-linux-gnueabi -fuse-ld=lld \
// RUN: -nostdlib -nostdinc -shared %s -o %t.v7aeb
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v7aeb | FileCheck %s --check-prefixes=CHECK,BE
// RUN: obj2yaml %t.v7aeb | FileCheck %s --check-prefixes=BE8

// LE: file format elf32-littlearm
// BE: file format elf32-bigarm
// NOBE8-NOT: EF_ARM_BE8
// BE8: EF_ARM_BE8

// CHECK: Disassembly of section .text:
// CHECK-EMPTY:
// CHECK-NEXT: <_start>:
// CHECK-NEXT: push {r11, lr}
// CHECK-NEXT: mov r11, sp
// CHECK-NEXT: bl {{.*}} <func1@plt>
// CHECK-NEXT: bl {{.*}} <func2@plt>
// CHECK-NEXT: bl {{.*}} <func3@plt>

// CHECK: Disassembly of section .plt:
// CHECK: <func1@plt>:
// CHECK-NEXT: add r12, pc, #0, #12
// CHECK-NEXT: add r12, r12, #32, #20
// CHECK-NEXT: ldr pc, [r12, #132]!
// CHECK-NEXT: .word 0xd4d4d4d4
// CHECK-EMPTY:
// CHECK-NEXT: <func2@plt>:
// CHECK-NEXT: add r12, pc, #0, #12
// CHECK-NEXT: add r12, r12, #32, #20
// CHECK-NEXT: ldr pc, [r12, #120]!
// CHECK-NEXT: .word 0xd4d4d4d4
// CHECK-EMPTY:
// CHECK-NEXT: <func3@plt>:
// CHECK-NEXT: add r12, pc, #0, #12
// CHECK-NEXT: add r12, r12, #32, #20
// CHECK-NEXT: ldr pc, [r12, #108]!
// CHECK-NEXT: .word 0xd4d4d4d4

// Test PLT section parsing on thumb.

// RUN: %clang --target=thumbv8.1m.main-none-linux-eabi \
// RUN: -c %s -o %t.v8.o
// RUN: ld.lld --shared %t.v8.o -o %t.v8
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v8 | FileCheck %s --check-prefixes=THUMB,LE

// Test PLT section parsing on thumbeb.

// RUN: %clang --target=thumbebv8.1m.main-none-linux-eabi \
// RUN: -c %s -o %t.v8eb.o
// RUN: ld.lld --shared %t.v8eb.o -o %t.v8eb
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v8eb | FileCheck %s --check-prefixes=THUMB,BE
// RUN: obj2yaml %t.v8eb | FileCheck %s --check-prefixes=NOBE8

// Test PLT section parsing on thumbeb with be8.

// RUN: %clang --target=thumbebv8.1m.main-none-linux-eabi \
// RUN: -c %s -o %t.v8eb.be8.o
// RUN: ld.lld --shared --be8 %t.v8eb.be8.o -o %t.v8eb.be8
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v8eb.be8 | FileCheck %s --check-prefixes=THUMB,BE
// RUN: obj2yaml %t.v8eb.be8 | FileCheck %s --check-prefixes=BE8

// THUMB: Disassembly of section .text:
// THUMB-EMPTY:
// THUMB-NEXT: <_start>:
// THUMB-NEXT: push {r7, lr}
// THUMB-NEXT: mov r7, sp
// THUMB-NEXT: bl {{.*}} <func1@plt>
// THUMB-NEXT: bl {{.*}} <func2@plt>
// THUMB-NEXT: bl {{.*}} <func3@plt>

// THUMB: Disassembly of section .plt:
// THUMB-EMPTY:
// THUMB: <func1@plt>:
// THUMB-NEXT: movw r12, #136
// THUMB-NEXT: movt r12, #2
// THUMB-NEXT: add r12, pc
// THUMB-NEXT: ldr.w pc, [r12]
// THUMB-NEXT: b 0x
// THUMB-EMPTY:
// THUMB-NEXT: <func2@plt>:
// THUMB-NEXT: movw r12, #124
// THUMB-NEXT: movt r12, #2
// THUMB-NEXT: add r12, pc
// THUMB-NEXT: ldr.w pc, [r12]
// THUMB-NEXT: b 0x
// THUMB-EMPTY:
// THUMB-NEXT: <func3@plt>:
// THUMB-NEXT: movw r12, #112
// THUMB-NEXT: movt r12, #2
// THUMB-NEXT: add r12, pc
// THUMB-NEXT: ldr.w pc, [r12]
// THUMB-NEXT: b 0x

// Test PLT section with long entries parsing on arm.

// RUN: echo "SECTIONS { \
// RUN: .text 0x1000 : { *(.text) } \
// RUN: .plt 0x2000 : { *(.plt) *(.plt.*) } \
// RUN: .got.plt 0x9000000 : { *(.got.plt) } \
// RUN: }" > %t.long.script

// RUN: %clang --target=armv6a-none-linux-gnueabi -fuse-ld=lld \
// RUN: -Xlinker --script=%t.long.script -nostdlib -nostdinc \
// RUN: -shared %s -o %t.v6a.long
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v6a.long | FileCheck %s --check-prefixes=CHECKLONG,LE

// Test PLT section with long entries parsing on armeb.

// RUN: %clang --target=armv6aeb-none-linux-gnueabi -fuse-ld=lld \
// RUN: -Xlinker --script=%t.long.script -nostdlib -nostdinc \
// RUN: -shared %s -o %t.v6aeb.long
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v6aeb.long | FileCheck %s --check-prefixes=CHECKLONG,BE
// RUN: obj2yaml %t.v6aeb.long | FileCheck %s --check-prefixes=NOBE8

// Test PLT section with long entries parsing on armeb with be8.

// RUN: %clang --target=armv7aeb-none-linux-gnueabi -fuse-ld=lld \
// RUN: -Xlinker --script=%t.long.script -nostdlib -nostdinc \
// RUN: -shared %s -o %t.v7aeb.long
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v7aeb.long | FileCheck %s --check-prefixes=CHECKLONG,BE
// RUN: obj2yaml %t.v7aeb.long | FileCheck %s --check-prefixes=BE8

// CHECKLONG: Disassembly of section .text:
// CHECKLONG-EMPTY:
// CHECKLONG-NEXT: <_start>:
// CHECKLONG-NEXT: push {r11, lr}
// CHECKLONG-NEXT: mov r11, sp
// CHECKLONG-NEXT: bl 0x2020 <func1@plt>
// CHECKLONG-NEXT: bl 0x2030 <func2@plt>
// CHECKLONG-NEXT: bl 0x2040 <func3@plt>

// CHECKLONG: Disassembly of section .plt:
// CHECKLONG: 00002020 <func1@plt>:
// CHECKLONG-NEXT: ldr r12, [pc, #4]
// CHECKLONG-NEXT: add r12, r12, pc
// CHECKLONG-NEXT: ldr pc, [r12]
// CHECKLONG-NEXT: .word 0x08ffdfe0
// CHECKLONG-EMPTY:
// CHECKLONG-NEXT: 00002030 <func2@plt>:
// CHECKLONG-NEXT: ldr r12, [pc, #4]
// CHECKLONG-NEXT: add r12, r12, pc
// CHECKLONG-NEXT: ldr pc, [r12]
// CHECKLONG-NEXT: .word 0x08ffdfd4
// CHECKLONG-EMPTY:
// CHECKLONG-NEXT: 00002040 <func3@plt>:
// CHECKLONG-NEXT: ldr r12, [pc, #4]
// CHECKLONG-NEXT: add r12, r12, pc
// CHECKLONG-NEXT: ldr pc, [r12]
// CHECKLONG-NEXT: .word 0x08ffdfc8

// Test PLT section with mixed long and short entries parsing on arm.

// RUN: echo "SECTIONS { \
// RUN: .text 0x1000 : { *(.text) } \
// RUN: .plt 0x2000 : { *(.plt) *(.plt.*) } \
// RUN: .got.plt 0x8002020 : { *(.got.plt) } \
// RUN: }" > %t.mix.script

// RUN: %clang --target=armv6a-none-linux-gnueabi -fuse-ld=lld \
// RUN: -Xlinker --script=%t.mix.script -nostdlib -nostdinc \
// RUN: -shared %s -o %t.v6a.mix
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v6a.mix | FileCheck %s --check-prefixes=CHECKMIX,LE

// Test PLT section with mixed long and short entries parsing on armeb.

// RUN: %clang --target=armv6aeb-none-linux-gnueabi -fuse-ld=lld \
// RUN: -Xlinker --script=%t.mix.script -nostdlib -nostdinc \
// RUN: -shared %s -o %t.v6aeb.mix
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v6aeb.mix | FileCheck %s --check-prefixes=CHECKMIX,BE
// RUN: obj2yaml %t.v6aeb.mix | FileCheck %s --check-prefixes=NOBE8

// Test PLT section with mixed long and short entries parsing on armeb with be8.

// RUN: %clang --target=armv7aeb-none-linux-gnueabi -fuse-ld=lld \
// RUN: -Xlinker --script=%t.mix.script -nostdlib -nostdinc \
// RUN: -shared %s -o %t.v7aeb.mix
// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \
// RUN: -d %t.v7aeb.mix | FileCheck %s --check-prefixes=CHECKMIX,BE
// RUN: obj2yaml %t.v7aeb.mix | FileCheck %s --check-prefixes=BE8

// CHECKMIX: Disassembly of section .text:
// CHECKMIX-EMPTY:
// CHECKMIX-NEXT: <_start>:
// CHECKMIX-NEXT: push {r11, lr}
// CHECKMIX-NEXT: mov r11, sp
// CHECKMIX-NEXT: bl 0x2020 <func1@plt>
// CHECKMIX-NEXT: bl 0x2030 <func2@plt>
// CHECKMIX-NEXT: bl 0x2040 <func3@plt>

// CHECKMIX: Disassembly of section .plt:
// CHECKMIX: 00002020 <func1@plt>:
// CHECKMIX-NEXT: ldr r12, [pc, #4]
// CHECKMIX-NEXT: add r12, r12, pc
// CHECKMIX-NEXT: ldr pc, [r12]
// CHECKMIX-NEXT: .word 0x08000000
// CHECKMIX-EMPTY:
// CHECKMIX-NEXT: 00002030 <func2@plt>:
// CHECKMIX-NEXT: add r12, pc, #133169152
// CHECKMIX-NEXT: add r12, r12, #1044480
// CHECKMIX-NEXT: ldr pc, [r12, #4088]!
// CHECKMIX-NEXT: .word 0xd4d4d4d4
// CHECKMIX-EMPTY:
// CHECKMIX-NEXT: 00002040 <func3@plt>:
// CHECKMIX-NEXT: add r12, pc, #133169152
// CHECKMIX-NEXT: add r12, r12, #1044480
// CHECKMIX-NEXT: ldr pc, [r12, #4076]!
// CHECKMIX-NEXT: .word 0xd4d4d4d4

extern void *func1();
extern void *func2();
extern void *func3();

void _start() {
func1();
func2();
func3();
}
4 changes: 4 additions & 0 deletions lld/test/ELF/arm-gnu-ifunc-plt.s
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@
// DISASM-NEXT: 20214: d4 d4 d4 d4 .word 0xd4d4d4d4
// DISASM-NEXT: 20218: d4 d4 d4 d4 .word 0xd4d4d4d4
// DISASM-NEXT: 2021c: d4 d4 d4 d4 .word 0xd4d4d4d4
// DISASM-EMPTY:
// DISASM-NEXT: <bar2@plt>:
// DISASM-NEXT: 20220: add r12, pc, #0, #12
// DISASM-NEXT: 20224: add r12, r12, #32
// DISASM-NEXT: 20228: ldr pc, [r12, #212]!
// DISASM-NEXT: 2022c: d4 d4 d4 d4 .word 0xd4d4d4d4
// DISASM-EMPTY:
// DISASM-NEXT: <zed2@plt>:
// DISASM-NEXT: 20230: add r12, pc, #0, #12
// DISASM-NEXT: 20234: add r12, r12, #32
// DISASM-NEXT: 20238: ldr pc, [r12, #200]!
Expand Down
2 changes: 2 additions & 0 deletions lld/test/ELF/arm-mixed-plts.s
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4
# CHECK-NEXT: d4 d4 d4 d4 .word 0xd4d4d4d4
# CHECK-EMPTY:
# CHECK-NEXT: <bar@plt>:
# CHECK-NEXT: e28fc600 add r12, pc, #0, #12
# CHECK-NEXT: e28cca20 add r12, r12, #32, #20
# CHECK-NEXT: e5bcf06c ldr pc, [r12, #0x6c]!
Expand Down
Loading