151 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t3// RUN: ld.lld %t -o %t24// 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 --no-print-imm-hex -d %t2 --start-address=0x100000 --stop-address=0x10000c | FileCheck --check-prefix=CHECK1 %s7// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x200000 --stop-address=0x200002 | FileCheck --check-prefix=CHECK2 %s8// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x300000 --stop-address=0x300002 | FileCheck --check-prefix=CHECK3 %s9// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x400000 --stop-address=0x400006 | FileCheck --check-prefix=CHECK4 %s10// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x1000000 --stop-address=0x1000036 | FileCheck --check-prefix=CHECK5 %s11// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x1100000 --stop-address=0x1100010 | FileCheck --check-prefix=CHECK6 %s12// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x1400004 --stop-address=0x140000c | FileCheck --check-prefix=CHECK7 %s13// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x1e00000 --stop-address=0x1e00006 | FileCheck --check-prefix=CHECK8 %s14// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x2200000 --stop-address=0x220000a | FileCheck --check-prefix=CHECK9 %s15// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x2300000 --stop-address=0x230000a | FileCheck --check-prefix=CHECK10 %s16 17// Test the Range extension Thunks for Thumb when all the code is in a single18// OutputSection. The Thumb unconditional branch b.w and branch and link bl19// instructions have a range of 16Mb. We create a series of Functions a20// megabyte apart. We expect range extension thunks to be created when a21// branch is out of range. Thunks will be reused whenever they are in range22 .syntax unified23 24// Define a function aligned on a megabyte boundary25 .macro FUNCTION suff26 .section .text.\suff\(), "ax", %progbits27 .thumb28 .balign 0x10000029 .globl tfunc\suff\()30 .type tfunc\suff\(), %function31tfunc\suff\():32 bx lr33 .endm34 35 .section .text, "ax", %progbits36 .thumb37 .globl _start38_start:39// tfunc00 and tfunc15 are within 16Mb no Range Thunks expected40 bl tfunc0041 bl tfunc1542// tfunc16 is > 16Mb away, expect a Range Thunk to be generated, to go into43// the first of the pre-created ThunkSections.44 bl tfunc1645// CHECK1: Disassembly of section .text:46// CHECK1-EMPTY:47// CHECK1-NEXT: <_start>:48// CHECK1-NEXT: 100000: f0ff fffe bl 0x200000 <tfunc00>49// CHECK1-NEXT: 100004: f3ff d7fc bl 0x1100000 <tfunc15>50// CHECK1-NEXT: 100008: f2ff d7fc bl 0x1000004 <__Thumbv7ABSLongThunk_tfunc16>51 52 FUNCTION 0053// CHECK2: <tfunc00>:54// CHECK2-NEXT: 200000: 4770 bx lr55 FUNCTION 0156// CHECK3: <tfunc01>:57// CHECK3-NEXT: 300000: 4770 bx lr58 FUNCTION 0259// tfunc28 is > 16Mb away, expect a Range Thunk to be generated, to go into60// the first of the pre-created ThunkSections.61 b.w tfunc2862// CHECK4: <tfunc02>:63// CHECK4-NEXT: 400000: 4770 bx lr64// CHECK4-NEXT: 400002: f000 9001 b.w 0x1000008 <__Thumbv7ABSLongThunk_tfunc28>65 FUNCTION 0366 FUNCTION 0467 FUNCTION 0568 FUNCTION 0669 FUNCTION 0770 FUNCTION 0871 FUNCTION 0972 FUNCTION 1073 FUNCTION 1174 FUNCTION 1275 FUNCTION 1376 FUNCTION 1477// Expect precreated ThunkSection here78// CHECK5: <__Thumbv7ABSLongThunk_tfunc16>:79// CHECK5-NEXT: 1000004: f1ff bffc b.w 0x1200000 <tfunc16>80// CHECK5: <__Thumbv7ABSLongThunk_tfunc28>:81// CHECK5-NEXT: 1000008: f1ff 97fa b.w 0x1e00000 <tfunc28>82// CHECK5: <__Thumbv7ABSLongThunk_tfunc32>:83// CHECK5-NEXT: 100000c: f240 0c01 movw r12, #184// CHECK5-NEXT: 1000010: f2c0 2c20 movt r12, #54485// CHECK5-NEXT: 1000014: 4760 bx r1286// CHECK5: <__Thumbv7ABSLongThunk_tfunc33>:87// CHECK5-NEXT: 1000016: f240 0c01 movw r12, #188// CHECK5-NEXT: 100001a: f2c0 2c30 movt r12, #56089// CHECK5-NEXT: 100001e: 4760 bx r1290// CHECK5: <__Thumbv7ABSLongThunk_tfunc02>:91// CHECK5-NEXT: 1000020: f7ff 97ee b.w 0x400000 <tfunc02>92 FUNCTION 1593// tfunc00 and tfunc01 are < 16Mb away, expect no range extension thunks94 bl tfunc0095 bl tfunc0196// tfunc32 and tfunc33 are > 16Mb away, expect range extension thunks in the97// precreated thunk section98 bl tfunc3299 bl tfunc33100// CHECK6: <tfunc15>:101// CHECK6-NEXT: 1100000: 4770 bx lr102// CHECK6-NEXT: 1100002: f4ff d7fd bl 0x200000 <tfunc00>103// CHECK6-NEXT: 1100006: f5ff d7fb bl 0x300000 <tfunc01>104// CHECK6-NEXT: 110000a: f6ff ffff bl 0x100000c <__Thumbv7ABSLongThunk_tfunc32>105// CHECK6-NEXT: 110000e: f700 f802 bl 0x1000016 <__Thumbv7ABSLongThunk_tfunc33>106 FUNCTION 16107 FUNCTION 17108 FUNCTION 18109// Expect another precreated thunk section here110// CHECK7: <__Thumbv7ABSLongThunk_tfunc15>:111// CHECK7-NEXT: 1400004: f4ff bffc b.w 0x1100000 <tfunc15>112// CHECK7: <__Thumbv7ABSLongThunk_tfunc16>:113// CHECK7-NEXT: 1400008: f5ff bffa b.w 0x1200000 <tfunc16>114 FUNCTION 19115 FUNCTION 20116 FUNCTION 21117 FUNCTION 22118 FUNCTION 23119 FUNCTION 24120 FUNCTION 25121 FUNCTION 26122 FUNCTION 27123 FUNCTION 28124// tfunc02 is > 16Mb away, expect range extension thunks in precreated thunk125// section126// CHECK8: <tfunc28>:127// CHECK8-NEXT: 1e00000: 4770 bx lr128// CHECK8-NEXT: 1e00002: f600 900d b.w 0x1000020 <__Thumbv7ABSLongThunk_tfunc02>129 130 b.w tfunc02131 FUNCTION 29132 FUNCTION 30133 FUNCTION 31134 FUNCTION 32135 // tfunc15 and tfunc16 are > 16 Mb away expect Thunks in the nearest136 // precreated thunk section.137 bl tfunc15138 bl tfunc16139// CHECK9: <tfunc32>:140// CHECK9: 2200000: 4770 bx lr141// CHECK9-NEXT: 2200002: f5ff d7ff bl 0x1400004 <__Thumbv7ABSLongThunk_tfunc15>142// CHECK9-NEXT: 2200006: f5ff d7ff bl 0x1400008 <__Thumbv7ABSLongThunk_tfunc16>143 144 FUNCTION 33145 bl tfunc15146 bl tfunc16147// CHECK10: <tfunc33>:148// CHECK10: 2300000: 4770 bx lr149// CHECK10-NEXT: 2300002: f4ff d7ff bl 0x1400004 <__Thumbv7ABSLongThunk_tfunc15>150// CHECK10-NEXT: 2300006: f4ff d7ff bl 0x1400008 <__Thumbv7ABSLongThunk_tfunc16>151