diff options
author | Mickael Guene <mickael.guene@st.com> | 2015-12-16 10:09:05 +0100 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2015-12-16 10:19:51 +0100 |
commit | 72d98d16ed09584660d0cbb759d90f8dfeef2343 (patch) | |
tree | 6a1f1e78ca24f2306e718025bf4d90d891956880 /ld | |
parent | 9c35a5290213e9a28e6cc691e1cc7ba5055653f7 (diff) | |
download | gdb-72d98d16ed09584660d0cbb759d90f8dfeef2343.zip gdb-72d98d16ed09584660d0cbb759d90f8dfeef2343.tar.gz gdb-72d98d16ed09584660d0cbb759d90f8dfeef2343.tar.bz2 |
[ARM] Add support for thumb1 pcrop relocations.
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
Diffstat (limited to 'ld')
-rw-r--r-- | ld/testsuite/ld-arm/arm-elf.exp | 6 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb1-adds.d | 38 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb1-adds.s | 43 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb1-movs.d | 38 | ||||
-rw-r--r-- | ld/testsuite/ld-arm/thumb1-movs.s | 43 |
5 files changed, 168 insertions, 0 deletions
diff --git a/ld/testsuite/ld-arm/arm-elf.exp b/ld/testsuite/ld-arm/arm-elf.exp index 1d9b1c8..23c9e57 100644 --- a/ld/testsuite/ld-arm/arm-elf.exp +++ b/ld/testsuite/ld-arm/arm-elf.exp @@ -223,6 +223,12 @@ set armelftests_common { "" {pcrel-shared.s} {{readelf -dr pcrel-shared.rd}} "pcrel-shared.so"} + {"MOVS thumb1 relocations" "-static -T arm.ld" "" "" {thumb1-movs.s} + {{objdump -dw thumb1-movs.d}} + "thumb1-movs"} + {"ADDS thumb1 relocations" "-static -T arm.ld" "" "" {thumb1-adds.s} + {{objdump -dw thumb1-adds.d}} + "thumb1-adds"} } set armelftests_nonacl { diff --git a/ld/testsuite/ld-arm/thumb1-adds.d b/ld/testsuite/ld-arm/thumb1-adds.d new file mode 100644 index 0000000..68ef68e --- /dev/null +++ b/ld/testsuite/ld-arm/thumb1-adds.d @@ -0,0 +1,38 @@ + +.*: file format.* + +Disassembly of section .text: + +00008000 <[^>]*>: + 8000: 3012 adds r0, #18 + 8002: 3134 adds r1, #52 ; 0x34 + 8004: 3280 adds r2, #128 ; 0x80 + 8006: 3301 adds r3, #1 + 8008: 3401 adds r4, #1 + 800a: 3500 adds r5, #0 + 800c: 3600 adds r6, #0 + 800e: 3700 adds r7, #0 + +00008010 <[^>]*>: + 8010: 3012 adds r0, #18 + 8012: 3100 adds r1, #0 + 8014: 3200 adds r2, #0 + 8016: 33ca adds r3, #202 ; 0xca + 8018: 3700 adds r7, #0 + 801a: 3634 adds r6, #52 ; 0x34 + 801c: 3581 adds r5, #129 ; 0x81 + 801e: 3423 adds r4, #35 ; 0x23 + +00008020 <[^>]*>: + 8020: 01 .byte 0x01 + +00008021 <[^>]*>: + 8021: 02 .byte 0x02 + +Disassembly of section .far: + +12340000 <[^>]*>: +12340000: 3000 adds r0, #0 +12340002: 3100 adds r1, #0 +12340004: 3200 adds r2, #0 +12340006: 3301 adds r3, #1 diff --git a/ld/testsuite/ld-arm/thumb1-adds.s b/ld/testsuite/ld-arm/thumb1-adds.s new file mode 100644 index 0000000..3dde045 --- /dev/null +++ b/ld/testsuite/ld-arm/thumb1-adds.s @@ -0,0 +1,43 @@ + .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 + diff --git a/ld/testsuite/ld-arm/thumb1-movs.d b/ld/testsuite/ld-arm/thumb1-movs.d new file mode 100644 index 0000000..6a72bc1 --- /dev/null +++ b/ld/testsuite/ld-arm/thumb1-movs.d @@ -0,0 +1,38 @@ + +.*: file format.* + +Disassembly of section .text: + +00008000 <[^>]*>: + 8000: 2012 movs r0, #18 + 8002: 2134 movs r1, #52 ; 0x34 + 8004: 2280 movs r2, #128 ; 0x80 + 8006: 2301 movs r3, #1 + 8008: 2401 movs r4, #1 + 800a: 2500 movs r5, #0 + 800c: 2600 movs r6, #0 + 800e: 2700 movs r7, #0 + +00008010 <[^>]*>: + 8010: 2012 movs r0, #18 + 8012: 2100 movs r1, #0 + 8014: 2281 movs r2, #129 ; 0x81 + 8016: 2320 movs r3, #32 + 8018: 2700 movs r7, #0 + 801a: 2600 movs r6, #0 + 801c: 2581 movs r5, #129 ; 0x81 + 801e: 2422 movs r4, #34 ; 0x22 + +00008020 <[^>]*>: + 8020: 01 .byte 0x01 + +00008021 <[^>]*>: + 8021: 02 .byte 0x02 + +Disassembly of section .far: + +12340000 <[^>]*>: +12340000: 2000 movs r0, #0 +12340002: 2100 movs r1, #0 +12340004: 2200 movs r2, #0 +12340006: 2301 movs r3, #1 diff --git a/ld/testsuite/ld-arm/thumb1-movs.s b/ld/testsuite/ld-arm/thumb1-movs.s new file mode 100644 index 0000000..80acfd5 --- /dev/null +++ b/ld/testsuite/ld-arm/thumb1-movs.s @@ -0,0 +1,43 @@ + .text + .arch armv6s-m + .syntax unified + .global _start + .thumb_func + .type _start, %function +_start: + .thumb_func + .type thumb1, %function +thumb1: + movs r0, #:upper8_15:#thumb3 + movs r1, #:upper0_7:#thumb3 + movs r2, #:lower8_15:#thumb1 + movs r3, #:lower0_7:#thumb1 + movs r4, #:lower0_7:#thumb3 + movs r5, #:lower8_15:#thumb3 + movs r6, #:upper0_7:#thumb1 + movs r7, #:upper8_15:#thumb1 + .thumb_func + .type thumb2, %function +thumb2: + movs r0, #:upper8_15:#(thumb3 + 0) + movs r1, #:upper0_7:#(thumb2 + 1) + movs r2, #:lower8_15:#(var1 + 255) + movs r3, #:lower0_7:#var1 + movs r7, #:upper8_15:#var1 + 4 + movs r6, #:upper0_7:#var2 + movs r5, #:lower8_15:#var2 + 0xff + movs r4, #:lower0_7:#var2 - (-1) +var1: + .byte 1 +var2: + .byte 2 + + .section .far, "ax", %progbits + .thumb_func + .type thumb3, %function +thumb3: + movs r0, #:upper8_15:#thumb1 + movs r1, #:upper0_7:#thumb2 + movs r2, #:lower8_15:#thumb3 + movs r3, #:lower0_7:#thumb1 + |