brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · 211b05a Raw
109 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t.o3// RUN: ld.lld %t.o -o %t4// The output file is large, most of it zeroes. We dissassemble only the5// parts we need to speed up the test and avoid a large output file6// RUN: llvm-objdump -d %t --print-imm-hex --start-address=0x80000 --stop-address=0x80010 | FileCheck --check-prefix=CHECK1 %s7// RUN: llvm-objdump -d %t --print-imm-hex --start-address=0x100000 --stop-address=0x100008 | FileCheck --check-prefix=CHECK2 %s8// RUN: llvm-objdump -d %t --print-imm-hex --start-address=0x180000 --stop-address=0x18000a | FileCheck --check-prefix=CHECK3 %s9// RUN: llvm-objdump -d %t --print-imm-hex --start-address=0x500004 --stop-address=0x500008 | FileCheck --check-prefix=CHECK4 %s10// RUN: llvm-objdump -d %t --print-imm-hex --start-address=0x580000 --stop-address=0x580006 | FileCheck --check-prefix=CHECK5 %s11// RUN: llvm-objdump -d %t --print-imm-hex --start-address=0x1000004 --stop-address=0x100000c | FileCheck --check-prefix=CHECK6 %s12// RUN: llvm-objdump -d %t --print-imm-hex --start-address=0x1100000 --stop-address=0x1100006 | FileCheck --check-prefix=CHECK7 %s13// Test Range extension Thunks for the Thumb conditional branch instruction.14// This instruction only has a range of 1Mb whereas all the other Thumb wide15// Branch instructions have 16Mb range. We still place our pre-created Thunk16// Sections at 16Mb intervals as conditional branches to a target defined17// in a different section are rare.18 .syntax unified19// Define a function aligned on a half megabyte boundary20 .macro FUNCTION suff21 .section .text.\suff\(), "ax", %progbits22 .thumb23 .balign 0x8000024 .globl tfunc\suff\()25 .type  tfunc\suff\(), %function26tfunc\suff\():27 bx lr28 .endm29 30 .globl _start31_start:32 FUNCTION 0033// Long Range Thunk needed for 16Mb range branch, can reach pre-created Thunk34// Section35 bl tfunc3336// CHECK1: Disassembly of section .text:37// CHECK1-EMPTY:38// CHECK1-NEXT: <tfunc00>:39// CHECK1-NEXT:    80000:       4770    bx      lr40// CHECK1-NEXT:    80002:       f37f d7ff       bl      0x1000004 <__Thumbv7ABSLongThunk_tfunc33>41// CHECK1: <__Thumbv7ABSLongThunk_tfunc05>:42// CHECK1-NEXT:    80008:       f27f bffa       b.w     0x300000 <tfunc05>43// CHECK1: <__Thumbv7ABSLongThunk_tfunc00>:44// CHECK1-NEXT:    8000c:       f7ff bff8       b.w     0x80000 <tfunc00>45 FUNCTION 0146// tfunc02 is within range of tfunc0247 beq.w tfunc0248// tfunc05 is out of range, and we can't reach the pre-created Thunk Section49// create a new one.50 bne.w tfunc0551// CHECK2:  <tfunc01>:52// CHECK2-NEXT:   100000:       4770    bx      lr53// CHECK2-NEXT:   100002:       f03f a7fd       beq.w   0x180000 <tfunc02>54// CHECK2-NEXT:   100006:       f47f a7ff       bne.w   0x80008 <__Thumbv7ABSLongThunk_tfunc05>55 FUNCTION 0256// We can reach the Thunk Section created for bne.w tfunc0557 bne.w tfunc0558 beq.w tfunc0059// CHECK3:        180000:       4770    bx      lr60// CHECK3-NEXT:   180002:       f440 8001       bne.w   0x80008 <__Thumbv7ABSLongThunk_tfunc05>61// CHECK3-NEXT:   180006:       f400 8001       beq.w   0x8000c <__Thumbv7ABSLongThunk_tfunc00>62 FUNCTION 0363 FUNCTION 0464 FUNCTION 0565 FUNCTION 0666 FUNCTION 0767 FUNCTION 0868 FUNCTION 0969// CHECK4:  <__Thumbv7ABSLongThunk_tfunc03>:70// CHECK4-NEXT:   500004:       f4ff bffc       b.w     0x200000 <tfunc03>71 FUNCTION 1072// We can't reach any Thunk Section, create a new one73 beq.w tfunc0374// CHECK5: <tfunc10>:75// CHECK5-NEXT:   580000:       4770    bx      lr76// CHECK5-NEXT:   580002:       f43f a7ff       beq.w   0x500004 <__Thumbv7ABSLongThunk_tfunc03>77 FUNCTION 1178 FUNCTION 1279 FUNCTION 1380 FUNCTION 1481 FUNCTION 1582 FUNCTION 1683 FUNCTION 1784 FUNCTION 1885 FUNCTION 1986 FUNCTION 2087 FUNCTION 2188 FUNCTION 2289 FUNCTION 2390 FUNCTION 2491 FUNCTION 2592 FUNCTION 2693 FUNCTION 2794 FUNCTION 2895 FUNCTION 2996 FUNCTION 3097 FUNCTION 3198// CHECK6:  <__Thumbv7ABSLongThunk_tfunc33>:99// CHECK6-NEXT:  1000004:       f0ff bffc       b.w     0x1100000 <tfunc33>100// CHECK6: <__Thumbv7ABSLongThunk_tfunc00>:101// CHECK6-NEXT:  1000008:       f47f 97fa       b.w     0x80000 <tfunc00>102 FUNCTION 32103 FUNCTION 33104 // We should be able to reach an existing ThunkSection.105 b.w tfunc00106// CHECK7: <tfunc33>:107// CHECK7-NEXT:  1100000:       4770            bx      lr108// CHECK7-NEXT:  1100002:       f700 b801       b.w     0x1000008 <__Thumbv7ABSLongThunk_tfunc00>109