Revisión | 72d98d16ed09584660d0cbb759d90f8dfeef2343 (tree) |
---|---|
Tiempo | 2015-12-16 18:19:51 |
Autor | Mickael Guene <mickael.guene@st.c...> |
Commiter | Christophe Lyon |
[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: R_ARM_THM_ALU_ABS_G3_NC foo
8: R_ARM_THM_ALU_ABS_G2_NC foo
c: R_ARM_THM_ALU_ABS_G1_NC foo
10: R_ARM_THM_ALU_ABS_G0_NC foo
@@ -3516,6 +3516,12 @@ pc-relative or some form of GOT-indirect relocation. */ | ||
3516 | 3516 | /* ARM support for STT_GNU_IFUNC. */ |
3517 | 3517 | BFD_RELOC_ARM_IRELATIVE, |
3518 | 3518 | |
3519 | +/* Thumb1 relocations to support execute-only code. */ | |
3520 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC, | |
3521 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC, | |
3522 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC, | |
3523 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC, | |
3524 | + | |
3519 | 3525 | /* These relocs are only used within the ARM assembler. They are not |
3520 | 3526 | (at present) written to any object files. */ |
3521 | 3527 | BFD_RELOC_ARM_IMMEDIATE, |
@@ -1689,6 +1689,60 @@ static reloc_howto_type elf32_arm_howto_table_1[] = | ||
1689 | 1689 | 0x00000000, /* src_mask */ |
1690 | 1690 | 0x00000000, /* dst_mask */ |
1691 | 1691 | FALSE), /* pcrel_offset */ |
1692 | + EMPTY_HOWTO (130), | |
1693 | + EMPTY_HOWTO (131), | |
1694 | + HOWTO (R_ARM_THM_ALU_ABS_G0_NC,/* type. */ | |
1695 | + 0, /* rightshift. */ | |
1696 | + 1, /* size (0 = byte, 1 = short, 2 = long). */ | |
1697 | + 16, /* bitsize. */ | |
1698 | + FALSE, /* pc_relative. */ | |
1699 | + 0, /* bitpos. */ | |
1700 | + complain_overflow_bitfield,/* complain_on_overflow. */ | |
1701 | + bfd_elf_generic_reloc, /* special_function. */ | |
1702 | + "R_ARM_THM_ALU_ABS_G0_NC",/* name. */ | |
1703 | + FALSE, /* partial_inplace. */ | |
1704 | + 0x00000000, /* src_mask. */ | |
1705 | + 0x00000000, /* dst_mask. */ | |
1706 | + FALSE), /* pcrel_offset. */ | |
1707 | + HOWTO (R_ARM_THM_ALU_ABS_G1_NC,/* type. */ | |
1708 | + 0, /* rightshift. */ | |
1709 | + 1, /* size (0 = byte, 1 = short, 2 = long). */ | |
1710 | + 16, /* bitsize. */ | |
1711 | + FALSE, /* pc_relative. */ | |
1712 | + 0, /* bitpos. */ | |
1713 | + complain_overflow_bitfield,/* complain_on_overflow. */ | |
1714 | + bfd_elf_generic_reloc, /* special_function. */ | |
1715 | + "R_ARM_THM_ALU_ABS_G1_NC",/* name. */ | |
1716 | + FALSE, /* partial_inplace. */ | |
1717 | + 0x00000000, /* src_mask. */ | |
1718 | + 0x00000000, /* dst_mask. */ | |
1719 | + FALSE), /* pcrel_offset. */ | |
1720 | + HOWTO (R_ARM_THM_ALU_ABS_G2_NC,/* type. */ | |
1721 | + 0, /* rightshift. */ | |
1722 | + 1, /* size (0 = byte, 1 = short, 2 = long). */ | |
1723 | + 16, /* bitsize. */ | |
1724 | + FALSE, /* pc_relative. */ | |
1725 | + 0, /* bitpos. */ | |
1726 | + complain_overflow_bitfield,/* complain_on_overflow. */ | |
1727 | + bfd_elf_generic_reloc, /* special_function. */ | |
1728 | + "R_ARM_THM_ALU_ABS_G2_NC",/* name. */ | |
1729 | + FALSE, /* partial_inplace. */ | |
1730 | + 0x00000000, /* src_mask. */ | |
1731 | + 0x00000000, /* dst_mask. */ | |
1732 | + FALSE), /* pcrel_offset. */ | |
1733 | + HOWTO (R_ARM_THM_ALU_ABS_G3_NC,/* type. */ | |
1734 | + 0, /* rightshift. */ | |
1735 | + 1, /* size (0 = byte, 1 = short, 2 = long). */ | |
1736 | + 16, /* bitsize. */ | |
1737 | + FALSE, /* pc_relative. */ | |
1738 | + 0, /* bitpos. */ | |
1739 | + complain_overflow_bitfield,/* complain_on_overflow. */ | |
1740 | + bfd_elf_generic_reloc, /* special_function. */ | |
1741 | + "R_ARM_THM_ALU_ABS_G3_NC",/* name. */ | |
1742 | + FALSE, /* partial_inplace. */ | |
1743 | + 0x00000000, /* src_mask. */ | |
1744 | + 0x00000000, /* dst_mask. */ | |
1745 | + FALSE), /* pcrel_offset. */ | |
1692 | 1746 | }; |
1693 | 1747 | |
1694 | 1748 | /* 160 onwards: */ |
@@ -1889,7 +1943,11 @@ static const struct elf32_arm_reloc_map elf32_arm_reloc_map[] = | ||
1889 | 1943 | {BFD_RELOC_ARM_LDC_SB_G0, R_ARM_LDC_SB_G0}, |
1890 | 1944 | {BFD_RELOC_ARM_LDC_SB_G1, R_ARM_LDC_SB_G1}, |
1891 | 1945 | {BFD_RELOC_ARM_LDC_SB_G2, R_ARM_LDC_SB_G2}, |
1892 | - {BFD_RELOC_ARM_V4BX, R_ARM_V4BX} | |
1946 | + {BFD_RELOC_ARM_V4BX, R_ARM_V4BX}, | |
1947 | + {BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC, R_ARM_THM_ALU_ABS_G3_NC}, | |
1948 | + {BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC, R_ARM_THM_ALU_ABS_G2_NC}, | |
1949 | + {BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC, R_ARM_THM_ALU_ABS_G1_NC}, | |
1950 | + {BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC, R_ARM_THM_ALU_ABS_G0_NC} | |
1893 | 1951 | }; |
1894 | 1952 | |
1895 | 1953 | static reloc_howto_type * |
@@ -11023,6 +11081,33 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, | ||
11023 | 11081 | } |
11024 | 11082 | return bfd_reloc_ok; |
11025 | 11083 | |
11084 | + case R_ARM_THM_ALU_ABS_G0_NC: | |
11085 | + case R_ARM_THM_ALU_ABS_G1_NC: | |
11086 | + case R_ARM_THM_ALU_ABS_G2_NC: | |
11087 | + case R_ARM_THM_ALU_ABS_G3_NC: | |
11088 | + { | |
11089 | + const int shift_array[4] = {0, 8, 16, 24}; | |
11090 | + bfd_vma insn = bfd_get_16 (input_bfd, hit_data); | |
11091 | + bfd_vma addr = value; | |
11092 | + int shift = shift_array[r_type - R_ARM_THM_ALU_ABS_G0_NC]; | |
11093 | + | |
11094 | + /* Compute address. */ | |
11095 | + if (globals->use_rel) | |
11096 | + signed_addend = insn & 0xff; | |
11097 | + addr += signed_addend; | |
11098 | + if (branch_type == ST_BRANCH_TO_THUMB) | |
11099 | + addr |= 1; | |
11100 | + /* Clean imm8 insn. */ | |
11101 | + insn &= 0xff00; | |
11102 | + /* And update with correct part of address. */ | |
11103 | + insn |= (addr >> shift) & 0xff; | |
11104 | + /* Update insn. */ | |
11105 | + bfd_put_16 (input_bfd, insn, hit_data); | |
11106 | + } | |
11107 | + | |
11108 | + *unresolved_reloc_p = FALSE; | |
11109 | + return bfd_reloc_ok; | |
11110 | + | |
11026 | 11111 | default: |
11027 | 11112 | return bfd_reloc_notsupported; |
11028 | 11113 | } |
@@ -1545,6 +1545,10 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", | ||
1545 | 1545 | "BFD_RELOC_ARM_LDC_SB_G2", |
1546 | 1546 | "BFD_RELOC_ARM_V4BX", |
1547 | 1547 | "BFD_RELOC_ARM_IRELATIVE", |
1548 | + "BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC", | |
1549 | + "BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC", | |
1550 | + "BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC", | |
1551 | + "BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC", | |
1548 | 1552 | "BFD_RELOC_ARM_IMMEDIATE", |
1549 | 1553 | "BFD_RELOC_ARM_ADRL_IMMEDIATE", |
1550 | 1554 | "BFD_RELOC_ARM_T32_IMMEDIATE", |
@@ -3272,6 +3272,17 @@ ENUMDOC | ||
3272 | 3272 | ARM support for STT_GNU_IFUNC. |
3273 | 3273 | |
3274 | 3274 | ENUM |
3275 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC | |
3276 | +ENUMX | |
3277 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC | |
3278 | +ENUMX | |
3279 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC | |
3280 | +ENUMX | |
3281 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC | |
3282 | +ENUMDOC | |
3283 | + Thumb1 relocations to support execute-only code. | |
3284 | + | |
3285 | +ENUM | |
3275 | 3286 | BFD_RELOC_ARM_IMMEDIATE |
3276 | 3287 | ENUMX |
3277 | 3288 | BFD_RELOC_ARM_ADRL_IMMEDIATE |
@@ -5273,7 +5273,28 @@ static struct group_reloc_table_entry group_reloc_table[] = | ||
5273 | 5273 | BFD_RELOC_ARM_ALU_SB_G2, /* ALU */ |
5274 | 5274 | BFD_RELOC_ARM_LDR_SB_G2, /* LDR */ |
5275 | 5275 | BFD_RELOC_ARM_LDRS_SB_G2, /* LDRS */ |
5276 | - BFD_RELOC_ARM_LDC_SB_G2 } }; /* LDC */ | |
5276 | + BFD_RELOC_ARM_LDC_SB_G2 }, /* LDC */ | |
5277 | + /* Absolute thumb alu relocations. */ | |
5278 | + { "lower0_7", | |
5279 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC,/* ALU. */ | |
5280 | + 0, /* LDR. */ | |
5281 | + 0, /* LDRS. */ | |
5282 | + 0 }, /* LDC. */ | |
5283 | + { "lower8_15", | |
5284 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC,/* ALU. */ | |
5285 | + 0, /* LDR. */ | |
5286 | + 0, /* LDRS. */ | |
5287 | + 0 }, /* LDC. */ | |
5288 | + { "upper0_7", | |
5289 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC,/* ALU. */ | |
5290 | + 0, /* LDR. */ | |
5291 | + 0, /* LDRS. */ | |
5292 | + 0 }, /* LDC. */ | |
5293 | + { "upper8_15", | |
5294 | + BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC,/* ALU. */ | |
5295 | + 0, /* LDR. */ | |
5296 | + 0, /* LDRS. */ | |
5297 | + 0 } }; /* LDC. */ | |
5277 | 5298 | |
5278 | 5299 | /* Given the address of a pointer pointing to the textual name of a group |
5279 | 5300 | relocation as may appear in assembler source, attempt to find its details |
@@ -10394,7 +10415,9 @@ do_t_add_sub (void) | ||
10394 | 10415 | { |
10395 | 10416 | inst.instruction = THUMB_OP16(opcode); |
10396 | 10417 | inst.instruction |= (Rd << 4) | Rs; |
10397 | - inst.reloc.type = BFD_RELOC_ARM_THUMB_ADD; | |
10418 | + if (inst.reloc.type < BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC | |
10419 | + || inst.reloc.type > BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC) | |
10420 | + inst.reloc.type = BFD_RELOC_ARM_THUMB_ADD; | |
10398 | 10421 | if (inst.size_req != 2) |
10399 | 10422 | inst.relax = opcode; |
10400 | 10423 | } |
@@ -11745,9 +11768,13 @@ do_t_mov_cmp (void) | ||
11745 | 11768 | inst.instruction = THUMB_OP16 (opcode); |
11746 | 11769 | inst.instruction |= Rn << 8; |
11747 | 11770 | if (inst.size_req == 2) |
11748 | - inst.reloc.type = BFD_RELOC_ARM_THUMB_IMM; | |
11771 | + { | |
11772 | + if (inst.reloc.type < BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC | |
11773 | + || inst.reloc.type > BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC) | |
11774 | + inst.reloc.type = BFD_RELOC_ARM_THUMB_IMM; | |
11775 | + } | |
11749 | 11776 | else |
11750 | - inst.relax = opcode; | |
11777 | + inst.relax = opcode; | |
11751 | 11778 | } |
11752 | 11779 | else |
11753 | 11780 | { |
@@ -18608,7 +18635,7 @@ static const struct asm_opcode insns[] = | ||
18608 | 18635 | CL("cmnp", 170f000, 2, (RR, SH), cmp), |
18609 | 18636 | |
18610 | 18637 | tCE("mov", 1a00000, _mov, 2, (RR, SH), mov, t_mov_cmp), |
18611 | - tC3("movs", 1b00000, _movs, 2, (RR, SH), mov, t_mov_cmp), | |
18638 | + tC3("movs", 1b00000, _movs, 2, (RR, SHG), mov, t_mov_cmp), | |
18612 | 18639 | tCE("mvn", 1e00000, _mvn, 2, (RR, SH), mov, t_mvn_tst), |
18613 | 18640 | tC3("mvns", 1f00000, _mvns, 2, (RR, SH), mov, t_mvn_tst), |
18614 | 18641 |
@@ -23242,6 +23269,68 @@ md_apply_fix (fixS * fixP, | ||
23242 | 23269 | } |
23243 | 23270 | return; |
23244 | 23271 | |
23272 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC: | |
23273 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC: | |
23274 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC: | |
23275 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC: | |
23276 | + gas_assert (!fixP->fx_done); | |
23277 | + { | |
23278 | + bfd_vma insn; | |
23279 | + bfd_boolean is_mov; | |
23280 | + bfd_vma encoded_addend = value; | |
23281 | + | |
23282 | + /* Check that addend can be encoded in instruction. */ | |
23283 | + if (!seg->use_rela_p && (value < 0 || value > 255)) | |
23284 | + as_bad_where (fixP->fx_file, fixP->fx_line, | |
23285 | + _("the offset 0x%08lX is not representable"), | |
23286 | + (unsigned long) encoded_addend); | |
23287 | + | |
23288 | + /* Extract the instruction. */ | |
23289 | + insn = md_chars_to_number (buf, THUMB_SIZE); | |
23290 | + is_mov = (insn & 0xf800) == 0x2000; | |
23291 | + | |
23292 | + /* Encode insn. */ | |
23293 | + if (is_mov) | |
23294 | + { | |
23295 | + if (!seg->use_rela_p) | |
23296 | + insn |= encoded_addend; | |
23297 | + } | |
23298 | + else | |
23299 | + { | |
23300 | + int rd, rs; | |
23301 | + | |
23302 | + /* Extract the instruction. */ | |
23303 | + /* Encoding is the following | |
23304 | + 0x8000 SUB | |
23305 | + 0x00F0 Rd | |
23306 | + 0x000F Rs | |
23307 | + */ | |
23308 | + /* The following conditions must be true : | |
23309 | + - ADD | |
23310 | + - Rd == Rs | |
23311 | + - Rd <= 7 | |
23312 | + */ | |
23313 | + rd = (insn >> 4) & 0xf; | |
23314 | + rs = insn & 0xf; | |
23315 | + if ((insn & 0x8000) || (rd != rs) || rd > 7) | |
23316 | + as_bad_where (fixP->fx_file, fixP->fx_line, | |
23317 | + _("Unable to process relocation for thumb opcode: %lx"), | |
23318 | + (unsigned long) insn); | |
23319 | + | |
23320 | + /* Encode as ADD immediate8 thumb 1 code. */ | |
23321 | + insn = 0x3000 | (rd << 8); | |
23322 | + | |
23323 | + /* Place the encoded addend into the first 8 bits of the | |
23324 | + instruction. */ | |
23325 | + if (!seg->use_rela_p) | |
23326 | + insn |= encoded_addend; | |
23327 | + } | |
23328 | + | |
23329 | + /* Update the instruction. */ | |
23330 | + md_number_to_chars (buf, insn, THUMB_SIZE); | |
23331 | + } | |
23332 | + break; | |
23333 | + | |
23245 | 23334 | case BFD_RELOC_ARM_ALU_PC_G0_NC: |
23246 | 23335 | case BFD_RELOC_ARM_ALU_PC_G0: |
23247 | 23336 | case BFD_RELOC_ARM_ALU_PC_G1_NC: |
@@ -23579,6 +23668,10 @@ tc_gen_reloc (asection *section, fixS *fixp) | ||
23579 | 23668 | case BFD_RELOC_ARM_LDC_SB_G1: |
23580 | 23669 | case BFD_RELOC_ARM_LDC_SB_G2: |
23581 | 23670 | case BFD_RELOC_ARM_V4BX: |
23671 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC: | |
23672 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G1_NC: | |
23673 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G2_NC: | |
23674 | + case BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC: | |
23582 | 23675 | code = fixp->fx_r_type; |
23583 | 23676 | break; |
23584 | 23677 |
@@ -23881,6 +23974,12 @@ arm_fix_adjustable (fixS * fixP) | ||
23881 | 23974 | || fixP->fx_r_type == BFD_RELOC_ARM_THUMB_MOVT_PCREL) |
23882 | 23975 | return FALSE; |
23883 | 23976 | |
23977 | + /* BFD_RELOC_ARM_THUMB_ALU_ABS_Gx_NC relocations have VERY limited | |
23978 | + offsets, so keep these symbols. */ | |
23979 | + if (fixP->fx_r_type >= BFD_RELOC_ARM_THUMB_ALU_ABS_G0_NC | |
23980 | + && fixP->fx_r_type <= BFD_RELOC_ARM_THUMB_ALU_ABS_G3_NC) | |
23981 | + return FALSE; | |
23982 | + | |
23884 | 23983 | return TRUE; |
23885 | 23984 | } |
23886 | 23985 | #endif /* defined (OBJ_ELF) || defined (OBJ_COFF) */ |
@@ -537,6 +537,22 @@ respectively. For example to load the 32-bit address of foo into r0: | ||
537 | 537 | MOVT r0, #:upper16:foo |
538 | 538 | @end smallexample |
539 | 539 | |
540 | +Relocations @samp{R_ARM_THM_ALU_ABS_G0_NC}, @samp{R_ARM_THM_ALU_ABS_G1_NC}, | |
541 | +@samp{R_ARM_THM_ALU_ABS_G2_NC} and @samp{R_ARM_THM_ALU_ABS_G3_NC} can be | |
542 | +generated by prefixing the value with @samp{#:lower0_7:#}, | |
543 | +@samp{#:lower8_15:#}, @samp{#:upper0_7:#} and @samp{#:upper8_15:#} | |
544 | +respectively. For example to load the 32-bit address of foo into r0: | |
545 | + | |
546 | +@smallexample | |
547 | + MOVS r0, #:upper8_15:#foo | |
548 | + LSLS r0, r0, #8 | |
549 | + ADDS r0, #:upper0_7:#foo | |
550 | + LSLS r0, r0, #8 | |
551 | + ADDS r0, #:lower8_15:#foo | |
552 | + LSLS r0, r0, #8 | |
553 | + ADDS r0, #:lower0_7:#foo | |
554 | +@end smallexample | |
555 | + | |
540 | 556 | @node ARM-Neon-Alignment |
541 | 557 | @subsection NEON Alignment Specifiers |
542 | 558 |
@@ -0,0 +1,16 @@ | ||
1 | +#objdump: -dr --prefix-addresses --show-raw-insn | |
2 | +#skip: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix* | |
3 | +#name: ADDS relocations against local symbols for armv6s-m | |
4 | + | |
5 | +.*: +file format .*arm.* | |
6 | + | |
7 | +Disassembly of section .text: | |
8 | +0[0-9a-f]+ <[^>]+> 3000 adds r0, #0 | |
9 | + 0: R_ARM_THM_ALU_ABS_G3_NC bar | |
10 | +0[0-9a-f]+ <[^>]+> 3000 adds r0, #0 | |
11 | + 2: R_ARM_THM_ALU_ABS_G2_NC bar | |
12 | +0[0-9a-f]+ <[^>]+> 3000 adds r0, #0 | |
13 | + 4: R_ARM_THM_ALU_ABS_G1_NC bar | |
14 | +0[0-9a-f]+ <[^>]+> 3000 adds r0, #0 | |
15 | + 6: R_ARM_THM_ALU_ABS_G0_NC bar | |
16 | +#... |
@@ -0,0 +1,13 @@ | ||
1 | +.arch armv6s-m | |
2 | +.text | |
3 | +.syntax unified | |
4 | +.thumb | |
5 | +foo: | |
6 | +adds r0, #:upper8_15:#bar | |
7 | +adds r0, #:upper0_7:#bar | |
8 | +adds r0, #:lower8_15:#bar | |
9 | +adds r0, #:lower0_7:#bar | |
10 | + | |
11 | +.space 0x10000 | |
12 | + | |
13 | +bar: |
@@ -0,0 +1,16 @@ | ||
1 | +#objdump: -dr --prefix-addresses --show-raw-insn | |
2 | +#skip: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd *-*-riscix* | |
3 | +#name: MOVS relocations against local symbols for armv6s-m | |
4 | + | |
5 | +.*: +file format .*arm.* | |
6 | + | |
7 | +Disassembly of section .text: | |
8 | +0[0-9a-f]+ <[^>]+> 2000 movs r0, #0 | |
9 | + 0: R_ARM_THM_ALU_ABS_G3_NC bar | |
10 | +0[0-9a-f]+ <[^>]+> 2000 movs r0, #0 | |
11 | + 2: R_ARM_THM_ALU_ABS_G2_NC bar | |
12 | +0[0-9a-f]+ <[^>]+> 2000 movs r0, #0 | |
13 | + 4: R_ARM_THM_ALU_ABS_G1_NC bar | |
14 | +0[0-9a-f]+ <[^>]+> 2000 movs r0, #0 | |
15 | + 6: R_ARM_THM_ALU_ABS_G0_NC bar | |
16 | +#... |
@@ -0,0 +1,13 @@ | ||
1 | +.arch armv6s-m | |
2 | +.text | |
3 | +.syntax unified | |
4 | +.thumb | |
5 | +foo: | |
6 | +movs r0, #:upper8_15:#bar | |
7 | +movs r0, #:upper0_7:#bar | |
8 | +movs r0, #:lower8_15:#bar | |
9 | +movs r0, #:lower0_7:#bar | |
10 | + | |
11 | +.space 0x10000 | |
12 | + | |
13 | +bar: |
@@ -230,6 +230,11 @@ START_RELOC_NUMBERS (elf_arm_reloc_type) | ||
230 | 230 | RELOC_NUMBER (R_ARM_ME_TOO, 128) /* obsolete */ |
231 | 231 | RELOC_NUMBER (R_ARM_THM_TLS_DESCSEQ ,129) |
232 | 232 | |
233 | + RELOC_NUMBER (R_ARM_THM_ALU_ABS_G0_NC,132) | |
234 | + RELOC_NUMBER (R_ARM_THM_ALU_ABS_G1_NC,133) | |
235 | + RELOC_NUMBER (R_ARM_THM_ALU_ABS_G2_NC,134) | |
236 | + RELOC_NUMBER (R_ARM_THM_ALU_ABS_G3_NC,135) | |
237 | + | |
233 | 238 | RELOC_NUMBER (R_ARM_IRELATIVE, 160) |
234 | 239 | |
235 | 240 | /* Extensions? R=read-only? */ |
@@ -223,6 +223,12 @@ set armelftests_common { | ||
223 | 223 | "" {pcrel-shared.s} |
224 | 224 | {{readelf -dr pcrel-shared.rd}} |
225 | 225 | "pcrel-shared.so"} |
226 | + {"MOVS thumb1 relocations" "-static -T arm.ld" "" "" {thumb1-movs.s} | |
227 | + {{objdump -dw thumb1-movs.d}} | |
228 | + "thumb1-movs"} | |
229 | + {"ADDS thumb1 relocations" "-static -T arm.ld" "" "" {thumb1-adds.s} | |
230 | + {{objdump -dw thumb1-adds.d}} | |
231 | + "thumb1-adds"} | |
226 | 232 | } |
227 | 233 | |
228 | 234 | set armelftests_nonacl { |
@@ -0,0 +1,38 @@ | ||
1 | + | |
2 | +.*: file format.* | |
3 | + | |
4 | +Disassembly of section .text: | |
5 | + | |
6 | +00008000 <[^>]*>: | |
7 | + 8000: 3012 adds r0, #18 | |
8 | + 8002: 3134 adds r1, #52 ; 0x34 | |
9 | + 8004: 3280 adds r2, #128 ; 0x80 | |
10 | + 8006: 3301 adds r3, #1 | |
11 | + 8008: 3401 adds r4, #1 | |
12 | + 800a: 3500 adds r5, #0 | |
13 | + 800c: 3600 adds r6, #0 | |
14 | + 800e: 3700 adds r7, #0 | |
15 | + | |
16 | +00008010 <[^>]*>: | |
17 | + 8010: 3012 adds r0, #18 | |
18 | + 8012: 3100 adds r1, #0 | |
19 | + 8014: 3200 adds r2, #0 | |
20 | + 8016: 33ca adds r3, #202 ; 0xca | |
21 | + 8018: 3700 adds r7, #0 | |
22 | + 801a: 3634 adds r6, #52 ; 0x34 | |
23 | + 801c: 3581 adds r5, #129 ; 0x81 | |
24 | + 801e: 3423 adds r4, #35 ; 0x23 | |
25 | + | |
26 | +00008020 <[^>]*>: | |
27 | + 8020: 01 .byte 0x01 | |
28 | + | |
29 | +00008021 <[^>]*>: | |
30 | + 8021: 02 .byte 0x02 | |
31 | + | |
32 | +Disassembly of section .far: | |
33 | + | |
34 | +12340000 <[^>]*>: | |
35 | +12340000: 3000 adds r0, #0 | |
36 | +12340002: 3100 adds r1, #0 | |
37 | +12340004: 3200 adds r2, #0 | |
38 | +12340006: 3301 adds r3, #1 |
@@ -0,0 +1,43 @@ | ||
1 | + .text | |
2 | + .arch armv6s-m | |
3 | + .syntax unified | |
4 | + .global _start | |
5 | + .thumb_func | |
6 | + .type _start, %function | |
7 | +_start: | |
8 | + .thumb_func | |
9 | + .type thumb1, %function | |
10 | +thumb1: | |
11 | + adds r0, #:upper8_15:#thumb3 | |
12 | + adds r1, #:upper0_7:#thumb3 | |
13 | + adds r2, #:lower8_15:#thumb1 | |
14 | + adds r3, #:lower0_7:#thumb1 | |
15 | + adds r4, #:lower0_7:#thumb3 | |
16 | + adds r5, #:lower8_15:#thumb3 | |
17 | + adds r6, #:upper0_7:#thumb1 | |
18 | + adds r7, #:upper8_15:#thumb1 | |
19 | + .thumb_func | |
20 | + .type thumb2, %function | |
21 | +thumb2: | |
22 | + adds r0, #:upper8_15:#thumb3 | |
23 | + adds r1, #:upper0_7:#(var2 + 1) | |
24 | + adds r2, #:lower8_15:#(thumb3 + 255) | |
25 | + adds r3, #:lower0_7:#(var1 + 0xaa) | |
26 | + adds r7, #:upper8_15:#var1 + 4 | |
27 | + adds r6, #:upper0_7:#thumb3 | |
28 | + adds r5, #:lower8_15:#var2 + 0xff | |
29 | + adds r4, #:lower0_7:#var2 - (-2) | |
30 | +var1: | |
31 | + .byte 1 | |
32 | +var2: | |
33 | + .byte 2 | |
34 | + | |
35 | + .section .far, "ax", %progbits | |
36 | + .thumb_func | |
37 | + .type thumb3, %function | |
38 | +thumb3: | |
39 | + adds r0, #:upper8_15:#thumb1 | |
40 | + adds r1, #:upper0_7:#thumb2 | |
41 | + adds r2, #:lower8_15:#thumb3 | |
42 | + adds r3, #:lower0_7:#thumb1 | |
43 | + |
@@ -0,0 +1,38 @@ | ||
1 | + | |
2 | +.*: file format.* | |
3 | + | |
4 | +Disassembly of section .text: | |
5 | + | |
6 | +00008000 <[^>]*>: | |
7 | + 8000: 2012 movs r0, #18 | |
8 | + 8002: 2134 movs r1, #52 ; 0x34 | |
9 | + 8004: 2280 movs r2, #128 ; 0x80 | |
10 | + 8006: 2301 movs r3, #1 | |
11 | + 8008: 2401 movs r4, #1 | |
12 | + 800a: 2500 movs r5, #0 | |
13 | + 800c: 2600 movs r6, #0 | |
14 | + 800e: 2700 movs r7, #0 | |
15 | + | |
16 | +00008010 <[^>]*>: | |
17 | + 8010: 2012 movs r0, #18 | |
18 | + 8012: 2100 movs r1, #0 | |
19 | + 8014: 2281 movs r2, #129 ; 0x81 | |
20 | + 8016: 2320 movs r3, #32 | |
21 | + 8018: 2700 movs r7, #0 | |
22 | + 801a: 2600 movs r6, #0 | |
23 | + 801c: 2581 movs r5, #129 ; 0x81 | |
24 | + 801e: 2422 movs r4, #34 ; 0x22 | |
25 | + | |
26 | +00008020 <[^>]*>: | |
27 | + 8020: 01 .byte 0x01 | |
28 | + | |
29 | +00008021 <[^>]*>: | |
30 | + 8021: 02 .byte 0x02 | |
31 | + | |
32 | +Disassembly of section .far: | |
33 | + | |
34 | +12340000 <[^>]*>: | |
35 | +12340000: 2000 movs r0, #0 | |
36 | +12340002: 2100 movs r1, #0 | |
37 | +12340004: 2200 movs r2, #0 | |
38 | +12340006: 2301 movs r3, #1 |
@@ -0,0 +1,43 @@ | ||
1 | + .text | |
2 | + .arch armv6s-m | |
3 | + .syntax unified | |
4 | + .global _start | |
5 | + .thumb_func | |
6 | + .type _start, %function | |
7 | +_start: | |
8 | + .thumb_func | |
9 | + .type thumb1, %function | |
10 | +thumb1: | |
11 | + movs r0, #:upper8_15:#thumb3 | |
12 | + movs r1, #:upper0_7:#thumb3 | |
13 | + movs r2, #:lower8_15:#thumb1 | |
14 | + movs r3, #:lower0_7:#thumb1 | |
15 | + movs r4, #:lower0_7:#thumb3 | |
16 | + movs r5, #:lower8_15:#thumb3 | |
17 | + movs r6, #:upper0_7:#thumb1 | |
18 | + movs r7, #:upper8_15:#thumb1 | |
19 | + .thumb_func | |
20 | + .type thumb2, %function | |
21 | +thumb2: | |
22 | + movs r0, #:upper8_15:#(thumb3 + 0) | |
23 | + movs r1, #:upper0_7:#(thumb2 + 1) | |
24 | + movs r2, #:lower8_15:#(var1 + 255) | |
25 | + movs r3, #:lower0_7:#var1 | |
26 | + movs r7, #:upper8_15:#var1 + 4 | |
27 | + movs r6, #:upper0_7:#var2 | |
28 | + movs r5, #:lower8_15:#var2 + 0xff | |
29 | + movs r4, #:lower0_7:#var2 - (-1) | |
30 | +var1: | |
31 | + .byte 1 | |
32 | +var2: | |
33 | + .byte 2 | |
34 | + | |
35 | + .section .far, "ax", %progbits | |
36 | + .thumb_func | |
37 | + .type thumb3, %function | |
38 | +thumb3: | |
39 | + movs r0, #:upper8_15:#thumb1 | |
40 | + movs r1, #:upper0_7:#thumb2 | |
41 | + movs r2, #:lower8_15:#thumb3 | |
42 | + movs r3, #:lower0_7:#thumb1 | |
43 | + |