thumb_blx_out_of_range.s 1.5 KB

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