115 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-linux-gnueabihf %s -o %t3// RUN: echo "SECTIONS { \4// RUN: . = SIZEOF_HEADERS; \5// RUN: .text 0x00011000 : { *(.text.*) } \6// RUN: } \7// RUN: sym = .;" > %t.script8// RUN: ld.lld --script %t.script %t -o %t29// RUN: llvm-readobj --sections --symbols %t2 | FileCheck --check-prefix=CHECK-ELF %s10// RUN: llvm-objdump --no-show-raw-insn --start-address=0x11000 --stop-address=0x11048 -d %t2 | FileCheck %s11 12// An example of thunk generation that takes the maximum number of permitted13// passes to converge. We start with a set of branches of which all but one are14// in range. Any thunk added to extend the range of a branch is inserted in15// between the branches and the targets which knocks some more branches out16// of range. At the end of 9 passes of createThunks() every branch has a17// range extension thunk, allowing the final pass to check that no more thunks18// are required.19//20// As the size of the .text section changes 9 times, the symbol sym which21// depends on the size of .text will be updated 9 times. This test checks that22// any iteration limit to updating symbols does not limit thunk convergence.23// up to its pass limit without24//25// CHECK-ELF: Name: .text26// CHECK-ELF-NEXT: Type: SHT_PROGBITS27// CHECK-ELF-NEXT: Flags [28// CHECK-ELF-NEXT: SHF_ALLOC29// CHECK-ELF-NEXT: SHF_EXECINSTR30// CHECK-ELF-NEXT: ]31// CHECK-ELF-NEXT: Address: 0x1100032// CHECK-ELF-NEXT: Offset: 0x100033// CHECK-ELF-NEXT: Size: 1677729234// CHECK-ELF: Name: sym35// CHECK-ELF-NEXT: Value: 0x101104C36 37// CHECK: 00011000 <_start>:38// CHECK-NEXT: 11000: b.w 0xe11048 <__Thumbv7ABSLongThunk_f2>39// CHECK-NEXT: 11004: b.w 0xe11048 <__Thumbv7ABSLongThunk_f2>40// CHECK-NEXT: 11008: b.w 0xe1104c <__Thumbv7ABSLongThunk_f3>41// CHECK-NEXT: 1100c: b.w 0xe1104c <__Thumbv7ABSLongThunk_f3>42// CHECK-NEXT: 11010: b.w 0xe11050 <__Thumbv7ABSLongThunk_f4>43// CHECK-NEXT: 11014: b.w 0xe11050 <__Thumbv7ABSLongThunk_f4>44// CHECK-NEXT: 11018: b.w 0xe11054 <__Thumbv7ABSLongThunk_f5>45// CHECK-NEXT: 1101c: b.w 0xe11054 <__Thumbv7ABSLongThunk_f5>46// CHECK-NEXT: 11020: b.w 0xe11058 <__Thumbv7ABSLongThunk_f6>47// CHECK-NEXT: 11024: b.w 0xe11058 <__Thumbv7ABSLongThunk_f6>48// CHECK-NEXT: 11028: b.w 0xe1105c <__Thumbv7ABSLongThunk_f7>49// CHECK-NEXT: 1102c: b.w 0xe1105c <__Thumbv7ABSLongThunk_f7>50// CHECK-NEXT: 11030: b.w 0xe11060 <__Thumbv7ABSLongThunk_f8>51// CHECK-NEXT: 11034: b.w 0xe11060 <__Thumbv7ABSLongThunk_f8>52// CHECK-NEXT: 11038: b.w 0xe11064 <__Thumbv7ABSLongThunk_f9>53// CHECK-NEXT: 1103c: b.w 0xe11064 <__Thumbv7ABSLongThunk_f9>54// CHECK-NEXT: 11040: b.w 0xe11068 <__Thumbv7ABSLongThunk_f10>55// CHECK-NEXT: 11044: b.w 0xe11068 <__Thumbv7ABSLongThunk_f10>56 57 58 .thumb59 .section .text.00, "ax", %progbits60 .globl _start61 .thumb_func62_start: b.w f263 b.w f264 b.w f365 b.w f366 b.w f467 b.w f468 b.w f569 b.w f570 b.w f671 b.w f672 b.w f773 b.w f774 b.w f875 b.w f876 b.w f977 b.w f978 b.w f1079 b.w f1080 81 .section .text.01, "ax", %progbits82 .space 14 * 1024 * 102483// Thunks are inserted here, initially only 1 branch is out of range and needs84// a thunk. However the added thunk is 4-bytes in size which makes another85// branch out of range, which adds another thunk ...86 .section .text.02, "ax", %progbits87 .space (2 * 1024 * 1024) - 6888 .thumb_func89f2: bx lr90 nop91 .thumb_func92f3: bx lr93 nop94 .thumb_func95f4: bx lr96 nop97 .thumb_func98f5: bx lr99 nop100 .thumb_func101f6: bx lr102 nop103 .thumb_func104f7: bx lr105 nop106 .thumb_func107f8: bx lr108 nop109 .thumb_func110f9: bx lr111 nop112 .thumb_func113f10: bx lr114 nop115