brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.9 KiB · 6f4b668 Raw
246 lines · c
1// Test PLT section parsing on arm.2 3// REQUIRES: ld.lld4 5// RUN: %clang --target=armv6a-none-linux-gnueabi -fuse-ld=lld \6// RUN:   -nostdlib -nostdinc -shared %s -o %t.v6a7// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \8// RUN:   -d %t.v6a | FileCheck %s --check-prefixes=CHECK,LE9 10// Test PLT section parsing on armeb.11 12// RUN: %clang --target=armv6aeb-none-linux-gnueabi -fuse-ld=lld \13// RUN:   -nostdlib -nostdinc -shared %s -o %t.v6aeb14// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \15// RUN:   -d %t.v6aeb | FileCheck %s --check-prefixes=CHECK,BE16// RUN: obj2yaml %t.v6aeb | FileCheck %s --check-prefixes=NOBE817 18// Test PLT section parsing on armeb with be8.19 20// RUN: %clang --target=armv7aeb-none-linux-gnueabi -fuse-ld=lld \21// RUN:   -nostdlib -nostdinc -shared %s -o %t.v7aeb22// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \23// RUN:   -d %t.v7aeb | FileCheck %s --check-prefixes=CHECK,BE24// RUN: obj2yaml %t.v7aeb | FileCheck %s --check-prefixes=BE825 26// LE: file format elf32-littlearm27// BE: file format elf32-bigarm28// NOBE8-NOT: EF_ARM_BE829// BE8: EF_ARM_BE830 31// CHECK: Disassembly of section .text:32// CHECK-EMPTY:33// CHECK-NEXT:    <_start>:34// CHECK-NEXT:      push	{r11, lr}35// CHECK-NEXT:      mov	r11, sp36// CHECK-NEXT:      bl	{{.*}} <func1@plt>37// CHECK-NEXT:      bl	{{.*}} <func2@plt>38// CHECK-NEXT:      bl	{{.*}} <func3@plt>39 40// CHECK: Disassembly of section .plt:41// CHECK:      <func1@plt>:42// CHECK-NEXT:      add	r12, pc, #0, #1243// CHECK-NEXT:      add	r12, r12, #32, #2044// CHECK-NEXT:      ldr	pc, [r12, #132]!45// CHECK-NEXT:      .word	0xd4d4d4d446// CHECK-EMPTY:47// CHECK-NEXT: <func2@plt>:48// CHECK-NEXT:      add	r12, pc, #0, #1249// CHECK-NEXT:      add	r12, r12, #32, #2050// CHECK-NEXT:      ldr	pc, [r12, #120]!51// CHECK-NEXT:      .word	0xd4d4d4d452// CHECK-EMPTY:53// CHECK-NEXT: <func3@plt>:54// CHECK-NEXT:      add	r12, pc, #0, #1255// CHECK-NEXT:      add	r12, r12, #32, #2056// CHECK-NEXT:      ldr	pc, [r12, #108]!57// CHECK-NEXT:      .word	0xd4d4d4d458 59// Test PLT section parsing on thumb.60 61// RUN: %clang --target=thumbv8.1m.main-none-linux-eabi \62// RUN:   -c %s -o %t.v8.o63// RUN: ld.lld --shared %t.v8.o -o %t.v864// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \65// RUN:   -d %t.v8 | FileCheck %s --check-prefixes=THUMB,LE66 67// Test PLT section parsing on thumbeb.68 69// RUN: %clang --target=thumbebv8.1m.main-none-linux-eabi \70// RUN:   -c %s -o %t.v8eb.o71// RUN: ld.lld --shared %t.v8eb.o -o %t.v8eb72// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \73// RUN:   -d %t.v8eb | FileCheck %s --check-prefixes=THUMB,BE74// RUN: obj2yaml %t.v8eb | FileCheck %s --check-prefixes=NOBE875 76// Test PLT section parsing on thumbeb with be8.77 78// RUN: %clang --target=thumbebv8.1m.main-none-linux-eabi \79// RUN:   -c %s -o %t.v8eb.be8.o80// RUN: ld.lld --shared --be8 %t.v8eb.be8.o -o %t.v8eb.be881// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \82// RUN:   -d %t.v8eb.be8 | FileCheck %s --check-prefixes=THUMB,BE83// RUN: obj2yaml %t.v8eb.be8 | FileCheck %s --check-prefixes=BE884 85// THUMB: Disassembly of section .text:86// THUMB-EMPTY:87// THUMB-NEXT: <_start>:88// THUMB-NEXT:      push	{r7, lr}89// THUMB-NEXT:      mov r7, sp90// THUMB-NEXT:      bl	{{.*}} <func1@plt>91// THUMB-NEXT:      bl	{{.*}} <func2@plt>92// THUMB-NEXT:      bl	{{.*}} <func3@plt>93 94// THUMB: Disassembly of section .plt:95// THUMB-EMPTY:96// THUMB:      <func1@plt>:97// THUMB-NEXT:      movw	r12, #13698// THUMB-NEXT:      movt	r12, #299// THUMB-NEXT:      add	r12, pc100// THUMB-NEXT:      ldr.w	pc, [r12]101// THUMB-NEXT:      b	0x102// THUMB-EMPTY:103// THUMB-NEXT: <func2@plt>:104// THUMB-NEXT:      movw	r12, #124105// THUMB-NEXT:      movt	r12, #2106// THUMB-NEXT:      add	r12, pc107// THUMB-NEXT:      ldr.w	pc, [r12]108// THUMB-NEXT:      b	0x109// THUMB-EMPTY:110// THUMB-NEXT: <func3@plt>:111// THUMB-NEXT:      movw	r12, #112112// THUMB-NEXT:      movt	r12, #2113// THUMB-NEXT:      add	r12, pc114// THUMB-NEXT:      ldr.w	pc, [r12]115// THUMB-NEXT:      b	0x116 117// Test PLT section with long entries parsing on arm.118 119// RUN: echo "SECTIONS { \120// RUN:       .text 0x1000 : { *(.text) } \121// RUN:       .plt  0x2000 : { *(.plt) *(.plt.*) } \122// RUN:       .got.plt 0x9000000 : { *(.got.plt) } \123// RUN:       }" > %t.long.script124 125// RUN: %clang --target=armv6a-none-linux-gnueabi -fuse-ld=lld \126// RUN:   -Xlinker --script=%t.long.script -nostdlib -nostdinc \127// RUN:   -shared %s -o %t.v6a.long128// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \129// RUN:   -d %t.v6a.long | FileCheck %s --check-prefixes=CHECKLONG,LE130 131// Test PLT section with long entries parsing on armeb.132 133// RUN: %clang --target=armv6aeb-none-linux-gnueabi -fuse-ld=lld \134// RUN:   -Xlinker --script=%t.long.script -nostdlib -nostdinc \135// RUN:   -shared %s -o %t.v6aeb.long136// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \137// RUN:   -d %t.v6aeb.long | FileCheck %s --check-prefixes=CHECKLONG,BE138// RUN: obj2yaml %t.v6aeb.long | FileCheck %s --check-prefixes=NOBE8139 140// Test PLT section with long entries parsing on armeb with be8.141 142// RUN: %clang --target=armv7aeb-none-linux-gnueabi -fuse-ld=lld \143// RUN:   -Xlinker --script=%t.long.script -nostdlib -nostdinc \144// RUN:   -shared %s -o %t.v7aeb.long145// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \146// RUN:   -d %t.v7aeb.long | FileCheck %s --check-prefixes=CHECKLONG,BE147// RUN: obj2yaml %t.v7aeb.long | FileCheck %s --check-prefixes=BE8148 149// CHECKLONG:       Disassembly of section .text:150// CHECKLONG-EMPTY:151// CHECKLONG-NEXT:  <_start>:152// CHECKLONG-NEXT:      push	{r11, lr}153// CHECKLONG-NEXT:      mov	r11, sp154// CHECKLONG-NEXT:      bl	0x2020 <func1@plt>155// CHECKLONG-NEXT:      bl	0x2030 <func2@plt>156// CHECKLONG-NEXT:      bl	0x2040 <func3@plt>157 158// CHECKLONG:       Disassembly of section .plt:159// CHECKLONG:       00002020 <func1@plt>:160// CHECKLONG-NEXT:      ldr	r12, [pc, #4]161// CHECKLONG-NEXT:      add	r12, r12, pc162// CHECKLONG-NEXT:      ldr	pc, [r12]163// CHECKLONG-NEXT:      .word	0x08ffdfe0164// CHECKLONG-EMPTY:165// CHECKLONG-NEXT:  00002030 <func2@plt>:166// CHECKLONG-NEXT:      ldr	r12, [pc, #4]167// CHECKLONG-NEXT:      add	r12, r12, pc168// CHECKLONG-NEXT:      ldr	pc, [r12]169// CHECKLONG-NEXT:      .word	0x08ffdfd4170// CHECKLONG-EMPTY:171// CHECKLONG-NEXT:  00002040 <func3@plt>:172// CHECKLONG-NEXT:      ldr	r12, [pc, #4]173// CHECKLONG-NEXT:      add	r12, r12, pc174// CHECKLONG-NEXT:      ldr	pc, [r12]175// CHECKLONG-NEXT:      .word	0x08ffdfc8176 177// Test PLT section with mixed long and short entries parsing on arm.178 179// RUN: echo "SECTIONS { \180// RUN:       .text 0x1000 : { *(.text) } \181// RUN:       .plt  0x2000 : { *(.plt) *(.plt.*) } \182// RUN:       .got.plt 0x8002020 : { *(.got.plt) } \183// RUN:       }" > %t.mix.script184 185// RUN: %clang --target=armv6a-none-linux-gnueabi -fuse-ld=lld \186// RUN:   -Xlinker --script=%t.mix.script -nostdlib -nostdinc \187// RUN:   -shared %s -o %t.v6a.mix188// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \189// RUN:   -d %t.v6a.mix | FileCheck %s --check-prefixes=CHECKMIX,LE190 191// Test PLT section with mixed long and short entries parsing on armeb.192 193// RUN: %clang --target=armv6aeb-none-linux-gnueabi -fuse-ld=lld \194// RUN:   -Xlinker --script=%t.mix.script -nostdlib -nostdinc \195// RUN:   -shared %s -o %t.v6aeb.mix196// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \197// RUN:   -d %t.v6aeb.mix | FileCheck %s --check-prefixes=CHECKMIX,BE198// RUN: obj2yaml %t.v6aeb.mix | FileCheck %s --check-prefixes=NOBE8199 200// Test PLT section with mixed long and short entries parsing on armeb with be8.201 202// RUN: %clang --target=armv7aeb-none-linux-gnueabi -fuse-ld=lld \203// RUN:   -Xlinker --script=%t.mix.script -nostdlib -nostdinc \204// RUN:   -shared %s -o %t.v7aeb.mix205// RUN: llvm-objdump --no-show-raw-insn --no-print-imm-hex \206// RUN:   -d %t.v7aeb.mix | FileCheck %s --check-prefixes=CHECKMIX,BE207// RUN: obj2yaml %t.v7aeb.mix | FileCheck %s --check-prefixes=BE8208 209// CHECKMIX:        Disassembly of section .text:210// CHECKMIX-EMPTY:211// CHECKMIX-NEXT:   <_start>:212// CHECKMIX-NEXT:       push	{r11, lr}213// CHECKMIX-NEXT:       mov	r11, sp214// CHECKMIX-NEXT:       bl	0x2020 <func1@plt>215// CHECKMIX-NEXT:       bl	0x2030 <func2@plt>216// CHECKMIX-NEXT:       bl	0x2040 <func3@plt>217 218// CHECKMIX:        Disassembly of section .plt:219// CHECKMIX:        00002020 <func1@plt>:220// CHECKMIX-NEXT:       ldr	r12, [pc, #4]221// CHECKMIX-NEXT:       add	r12, r12, pc222// CHECKMIX-NEXT:       ldr	pc, [r12]223// CHECKMIX-NEXT:       .word	0x08000000224// CHECKMIX-EMPTY:225// CHECKMIX-NEXT:   00002030 <func2@plt>:226// CHECKMIX-NEXT:       add	r12, pc, #133169152227// CHECKMIX-NEXT:       add	r12, r12, #1044480228// CHECKMIX-NEXT:       ldr	pc, [r12, #4088]!229// CHECKMIX-NEXT:       .word	0xd4d4d4d4230// CHECKMIX-EMPTY:231// CHECKMIX-NEXT:   00002040 <func3@plt>:232// CHECKMIX-NEXT:       add	r12, pc, #133169152233// CHECKMIX-NEXT:       add	r12, r12, #1044480234// CHECKMIX-NEXT:       ldr	pc, [r12, #4076]!235// CHECKMIX-NEXT:       .word	0xd4d4d4d4236 237extern void *func1();238extern void *func2();239extern void *func3();240 241void _start() {242  func1();243  func2();244  func3();245}246