179 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t3// RUN: echo "SECTIONS { \4// RUN: .text 0x100000 : { *(.text) } \5// RUN: .textl : { *(.text_l0*) *(.text_l1*) *(.text_l2*) *(.text_l3*) } \6// RUN: .texth : { *(.text_h0*) *(.text_h1*) *(.text_h2*) *(.text_h3*) } \7// RUN: }" > %t.script8// RUN: ld.lld --script %t.script %t -o %t29// The output file is large, most of it zeroes. We dissassemble only the10// parts we need to speed up the test and avoid a large output file11// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x100000 --stop-address=0x100012 | FileCheck --check-prefix=CHECK1 %s12// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x200000 --stop-address=0x200008 | FileCheck --check-prefix=CHECK2 %s13// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0xb00004 --stop-address=0xb0000e | FileCheck --check-prefix=CHECK3 %s14// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x2100000 --stop-address=0x210001a | FileCheck --check-prefix=CHECK4 %s15// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x2200000 --stop-address=0x220000e | FileCheck --check-prefix=CHECK5 %s16// RUN: llvm-objdump --no-print-imm-hex -d %t2 --start-address=0x4100000 --stop-address=0x4100020 | FileCheck --check-prefix=CHECK6 %s17 18// Test the range extensions in a linker script where there are several19// OutputSections requiring range extension Thunks. We should be able to reuse20// Thunks between OutputSections but our placement of new Thunks is done on a21// per OutputSection basis22 .syntax unified23 24// Define a function that we can match with .text_l* aligned on a megabyte25// boundary26 .macro FUNCTIONL suff27 .section .text_l\suff\(), "ax", %progbits28 .thumb29 .balign 0x10000030 .globl tfuncl\suff\()31 .type tfuncl\suff\(), %function32tfuncl\suff\():33 bx lr34 .endm35 36// Define a function that we can match with .text_h* aligned on a megabyte37// boundary38 .macro FUNCTIONH suff39 .section .text_h\suff\(), "ax", %progbits40 .thumb41 .balign 0x10000042 .globl tfunch\suff\()43 .type tfunch\suff\(), %function44tfunch\suff\():45 bx lr46 .endm47 48 .section .text, "ax", %progbits49 .thumb50 .globl _start51_start:52 bl tfuncl0053 // Expect a range extension thunk in .text OutputSection54 bl tfunch3155// CHECK1: Disassembly of section .text:56// CHECK1-EMPTY:57// CHECK1-NEXT: <_start>:58// CHECK1-NEXT: 100000: f0ff fffe bl 0x200000 <tfuncl00>59// CHECK1-NEXT: 100004: f000 f800 bl 0x100008 <__Thumbv7ABSLongThunk_tfunch31>60// CHECK1: <__Thumbv7ABSLongThunk_tfunch31>:61// CHECK1-NEXT: 100008: f240 0c01 movw r12, #162// CHECK1-NEXT: 10000c: f2c0 4c10 movt r12, #104063// CHECK1-NEXT: 100010: 4760 bx r1264 FUNCTIONL 0065 // Create a range extension thunk in .textl66 bl tfuncl2467 // We can reuse existing thunk in .text68 bl tfunch3169// CHECK2: Disassembly of section .textl:70// CHECK2-EMPTY:71// CHECK2-NEXT: <tfuncl00>:72// CHECK2-NEXT: 200000: 4770 bx lr73// CHECK2-NEXT: 200002: f0ff dfff bl 0xb00004 <__Thumbv7ABSLongThunk_tfuncl24>74// CHECK2-NEXT: 200006: f6ff ffff bl 0x100008 <__Thumbv7ABSLongThunk_tfunch31>75 FUNCTIONL 0176 FUNCTIONL 0277 FUNCTIONL 0378 FUNCTIONL 0479 FUNCTIONL 0580 FUNCTIONL 0681 FUNCTIONL 0782 FUNCTIONL 0883 FUNCTIONL 0984// CHECK3: <__Thumbv7ABSLongThunk_tfuncl24>:85// CHECK3-NEXT: b00004: f2ff 97fc b.w 0x1a00000 <tfuncl24>86 FUNCTIONL 1087 FUNCTIONL 1188 FUNCTIONL 1289 FUNCTIONL 1390 FUNCTIONL 1491 FUNCTIONL 1592 FUNCTIONL 1693 FUNCTIONL 1794 FUNCTIONL 1895 FUNCTIONL 1996 FUNCTIONL 2097 FUNCTIONL 2198 FUNCTIONL 2299 FUNCTIONL 23100 FUNCTIONL 24101 FUNCTIONL 25102 FUNCTIONL 26103 FUNCTIONL 27104 FUNCTIONL 28105 FUNCTIONL 29106 FUNCTIONL 30107 FUNCTIONL 31108 // Create range extension thunks in .textl109 bl tfuncl00110 bl tfuncl24111 // Shouldn't need a thunk112 bl tfunch00113// CHECK4: 2100002: f000 f805 bl 0x2100010 <__Thumbv7ABSLongThunk_tfuncl00>114// CHECK4-NEXT: 2100006: f4ff f7fb bl 0x1a00000 <tfuncl24>115// CHECK4-NEXT: 210000a: f0ff fff9 bl 0x2200000 <tfunch00>116// CHECK4: <__Thumbv7ABSLongThunk_tfuncl00>:117// CHECK4-NEXT: 2100010: f240 0c01 movw r12, #1118// CHECK4-NEXT: 2100014: f2c0 0c20 movt r12, #32119// CHECK4-NEXT: 2100018: 4760 bx r12120 FUNCTIONH 00121 // Can reuse existing thunks in .textl122 bl tfuncl00123 bl tfuncl24124 // Shouldn't need a thunk125 bl tfuncl31126// CHECK5: Disassembly of section .texth:127// CHECK5-EMPTY:128// CHECK5-NEXT: <tfunch00>:129// CHECK5-NEXT: 2200000: 4770 bx lr130// CHECK5-NEXT: 2200002: f700 f805 bl 0x2100010 <__Thumbv7ABSLongThunk_tfuncl00>131// CHECK5-NEXT: 2200006: f7ff dffb bl 0x1a00000 <tfuncl24>132// CHECK5-NEXT: 220000a: f6ff fff9 bl 0x2100000 <tfuncl31>133 FUNCTIONH 01134 FUNCTIONH 02135 FUNCTIONH 03136 FUNCTIONH 04137 FUNCTIONH 05138 FUNCTIONH 06139 FUNCTIONH 07140 FUNCTIONH 08141 FUNCTIONH 09142 FUNCTIONH 10143 FUNCTIONH 11144 FUNCTIONH 12145 FUNCTIONH 13146 FUNCTIONH 14147 FUNCTIONH 15148 FUNCTIONH 16149 FUNCTIONH 17150 FUNCTIONH 18151 FUNCTIONH 19152 FUNCTIONH 20153 FUNCTIONH 21154 FUNCTIONH 22155 FUNCTIONH 23156 FUNCTIONH 24157 FUNCTIONH 25158 FUNCTIONH 26159 FUNCTIONH 27160 FUNCTIONH 28161 FUNCTIONH 29162 FUNCTIONH 30163 FUNCTIONH 31164// expect Thunks in .texth165 bl tfuncl00166 bl tfunch00167// CHECK6: <tfunch31>:168// CHECK6-NEXT: 4100000: 4770 bx lr169// CHECK6-NEXT: 4100002: f000 f803 bl 0x410000c <__Thumbv7ABSLongThunk_tfuncl00>170// CHECK6-NEXT: 4100006: f000 f806 bl 0x4100016 <__Thumbv7ABSLongThunk_tfunch00>171// CHECK6: <__Thumbv7ABSLongThunk_tfuncl00>:172// CHECK6-NEXT: 410000c: f240 0c01 movw r12, #1173// CHECK6-NEXT: 4100010: f2c0 0c20 movt r12, #32174// CHECK6-NEXT: 4100014: 4760 bx r12175// CHECK6: <__Thumbv7ABSLongThunk_tfunch00>:176// CHECK6-NEXT: 4100016: f240 0c01 movw r12, #1177// CHECK6-NEXT: 410001a: f2c0 2c20 movt r12, #544178// CHECK6-NEXT: 410001e: 4760 bx r12179