1# thumb_blx_out_of_range.s 2# Test THUMB/THUMB-2 blx instructions just out of the branch range limits. 3 .syntax unified 4 5 .section .text.pre,"x" 6 7# Add padding so that target is just output of branch range. 8 .space 4 9 10 .global _forward_target 11 .global _backward_target 12 .type _backword_target, %function 13_backward_target: 14 bx lr 15 .size _backward_target, .-_backward_target 16 17 .text 18# Use 256-byte alignment so that we know where the stubs start. 19 .align 8 20 21# Define _start so that linker does not complain. 22 .align 2 23 .global _start 24 .code 32 25 .type _start, %function 26_start: 27 bx lr 28 .size _start, .-_start 29 30 .global _backward_test 31 .code 16 32 .thumb_func 33 .type _backward_test, %function 34_backward_test: 35 bl _backward_target 36 .size _backward_test, .-_backward_test 37 38 .align 2 39 .global _forward_test 40 .code 16 41 .thumb_func 42 .type _forward_test, %function 43_forward_test: 44 # Bit 1 of the BLX target comes from bit 1 of branch base address, 45 # which is BLX instruction's address + 4. We intentionally put this 46 # forward BLX at an address n*4 + 2 so that the branch offset is 47 # bumped up by 2. 48 nop.n 49 bl _forward_target 50 .size _forward_test, .-_forward_test 51 52# switch back to ARM mode so that stubs are disassembled correctly. 53 .align 2 54 .code 32 55 56# Align stub table for address matching. 57 .align 8 58 59 .section .text.post,"x" 60 61# Add padding so that target is just out of branch range. 62 .space 12 63 .align 2 64 .code 32 65 .global _forward_target 66 .type _forward_target, %function 67_forward_target: 68 bx lr 69 .size _forward_target, .-_forward_target 70