mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-18 23:03:29 +08:00
72d98d16ed
To support thumb1 execute-only code we need to support four new relocations (R_ARM_THM_ALU_ABS_G0_NC, R_ARM_THM_ALU_ABS_G1_NC, R_ARM_THM_ALU_ABS_G2_NC and R_ARM_THM_ALU_ABS_G3_NC). These relocations allow the static linker to finalize construction of symbol address. Typical sequence of code to get address of the symbol foo is then the following : movs r3, #:upper8_15:#foo lsls r3, #8 adds r3, #:upper0_7:#foo lsls r3, #8 adds r3, #:lower8_15:#foo lsls r3, #8 adds r3, #:lower0_7:#foo This will give following sequence of text and relocations after assembly : 4: 2300 movs r3, #0 4: R_ARM_THM_ALU_ABS_G3_NC foo 6: 021b lsls r3, r3, #8 8: 3300 adds r3, #0 8: R_ARM_THM_ALU_ABS_G2_NC foo a: 021b lsls r3, r3, #8 c: 3300 adds r3, #0 c: R_ARM_THM_ALU_ABS_G1_NC foo e: 021b lsls r3, r3, #8 10: 3300 adds r3, #0 10: R_ARM_THM_ALU_ABS_G0_NC foo
44 lines
925 B
ArmAsm
44 lines
925 B
ArmAsm
.text
|
|
.arch armv6s-m
|
|
.syntax unified
|
|
.global _start
|
|
.thumb_func
|
|
.type _start, %function
|
|
_start:
|
|
.thumb_func
|
|
.type thumb1, %function
|
|
thumb1:
|
|
adds r0, #:upper8_15:#thumb3
|
|
adds r1, #:upper0_7:#thumb3
|
|
adds r2, #:lower8_15:#thumb1
|
|
adds r3, #:lower0_7:#thumb1
|
|
adds r4, #:lower0_7:#thumb3
|
|
adds r5, #:lower8_15:#thumb3
|
|
adds r6, #:upper0_7:#thumb1
|
|
adds r7, #:upper8_15:#thumb1
|
|
.thumb_func
|
|
.type thumb2, %function
|
|
thumb2:
|
|
adds r0, #:upper8_15:#thumb3
|
|
adds r1, #:upper0_7:#(var2 + 1)
|
|
adds r2, #:lower8_15:#(thumb3 + 255)
|
|
adds r3, #:lower0_7:#(var1 + 0xaa)
|
|
adds r7, #:upper8_15:#var1 + 4
|
|
adds r6, #:upper0_7:#thumb3
|
|
adds r5, #:lower8_15:#var2 + 0xff
|
|
adds r4, #:lower0_7:#var2 - (-2)
|
|
var1:
|
|
.byte 1
|
|
var2:
|
|
.byte 2
|
|
|
|
.section .far, "ax", %progbits
|
|
.thumb_func
|
|
.type thumb3, %function
|
|
thumb3:
|
|
adds r0, #:upper8_15:#thumb1
|
|
adds r1, #:upper0_7:#thumb2
|
|
adds r2, #:lower8_15:#thumb3
|
|
adds r3, #:lower0_7:#thumb1
|
|
|