Module Name: src
Committed By: matt
Date: Sat Apr 5 07:19:34 UTC 2014
Modified Files:
src/gnu/dist/binutils/bfd [matt-nb5-mips64]: elf32-arm.c
Log Message:
When writing BE8 executables, make the PLTs are written as little endian.
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.32.1 src/gnu/dist/binutils/bfd/elf32-arm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/gnu/dist/binutils/bfd/elf32-arm.c
diff -u src/gnu/dist/binutils/bfd/elf32-arm.c:1.1.1.1 src/gnu/dist/binutils/bfd/elf32-arm.c:1.1.1.1.32.1
--- src/gnu/dist/binutils/bfd/elf32-arm.c:1.1.1.1 Thu Feb 2 20:45:20 2006
+++ src/gnu/dist/binutils/bfd/elf32-arm.c Sat Apr 5 07:19:34 2014
@@ -2012,6 +2012,35 @@ insert_thumb_branch (insn32 br_insn, int
return br_insn;
}
+
+/* Store an Arm insn into an output section not processed by
+ elf32_arm_write_section. */
+
+static void
+put_arm_insn(struct elf32_arm_link_hash_table *htab,
+ bfd * output_bfd, bfd_vma val, void * ptr)
+{
+ if (htab->byteswap_code != bfd_little_endian (output_bfd))
+ bfd_putl32(val, ptr);
+ else
+ bfd_putb32(val, ptr);
+}
+
+
+/* Store a 16-bit Thumb insn into an output section not processed by
+ elf32_arm_write_section. */
+
+static void
+put_thumb_insn(struct elf32_arm_link_hash_table *htab,
+ bfd * output_bfd, bfd_vma val, void * ptr)
+{
+ if (htab->byteswap_code != bfd_little_endian (output_bfd))
+ bfd_putl16(val, ptr);
+ else
+ bfd_putb16(val, ptr);
+}
+
+
/* Thumb code calling an ARM function. */
static int
@@ -2068,11 +2097,11 @@ elf32_thumb_to_arm_stub (struct bfd_link
--my_offset;
myh->root.u.def.value = my_offset;
- bfd_put_16 (output_bfd, (bfd_vma) t2a1_bx_pc_insn,
- s->contents + my_offset);
+ put_thumb_insn (globals, output_bfd, (bfd_vma) t2a1_bx_pc_insn,
+ s->contents + my_offset);
- bfd_put_16 (output_bfd, (bfd_vma) t2a2_noop_insn,
- s->contents + my_offset + 2);
+ put_thumb_insn (globals, output_bfd, (bfd_vma) t2a2_noop_insn,
+ s->contents + my_offset + 2);
ret_offset =
/* Address of destination of the stub. */
@@ -2090,9 +2119,9 @@ elf32_thumb_to_arm_stub (struct bfd_link
/* ARM branches work from the pc of the instruction + 8. */
+ 8);
- bfd_put_32 (output_bfd,
- (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
- s->contents + my_offset + 4);
+ put_arm_insn (globals, output_bfd,
+ (bfd_vma) t2a3_b_insn | ((ret_offset >> 2) & 0x00FFFFFF),
+ s->contents + my_offset + 4);
}
BFD_ASSERT (my_offset <= globals->thumb_glue_size);
@@ -2171,11 +2200,11 @@ elf32_arm_to_thumb_stub (struct bfd_link
--my_offset;
myh->root.u.def.value = my_offset;
- bfd_put_32 (output_bfd, (bfd_vma) a2t1_ldr_insn,
- s->contents + my_offset);
+ put_arm_insn (globals, output_bfd, (bfd_vma) a2t1_ldr_insn,
+ s->contents + my_offset);
- bfd_put_32 (output_bfd, (bfd_vma) a2t2_bx_r12_insn,
- s->contents + my_offset + 4);
+ put_arm_insn (globals, output_bfd, (bfd_vma) a2t2_bx_r12_insn,
+ s->contents + my_offset + 4);
/* It's a thumb address. Add the low order bit. */
bfd_put_32 (output_bfd, val | a2t3_func_addr_insn,
@@ -4959,16 +4988,17 @@ elf32_arm_finish_dynamic_symbol (bfd * o
/* Fill in the entry in the procedure linkage table. */
if (htab->symbian_p)
{
- unsigned i;
- for (i = 0; i < htab->plt_entry_size / 4; ++i)
- bfd_put_32 (output_bfd,
- elf32_arm_symbian_plt_entry[i],
- splt->contents + h->plt.offset + 4 * i);
+ put_arm_insn (htab, output_bfd,
+ elf32_arm_symbian_plt_entry[0],
+ splt->contents + h->plt.offset);
+ put_arm_insn (htab, output_bfd,
+ elf32_arm_symbian_plt_entry[1],
+ splt->contents + h->plt.offset + 4);
/* Fill in the entry in the .rel.plt section. */
rel.r_offset = (splt->output_section->vma
+ splt->output_offset
- + h->plt.offset + 4 * (i - 1));
+ + h->plt.offset + 4);
rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT);
/* Get the index in the procedure linkage table which
@@ -5014,20 +5044,23 @@ elf32_arm_finish_dynamic_symbol (bfd * o
if (eh->plt_thumb_refcount > 0)
{
- bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[0],
- splt->contents + h->plt.offset - 4);
- bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[1],
- splt->contents + h->plt.offset - 2);
+ put_thumb_insn (htab, output_bfd, elf32_arm_plt_thumb_stub[0],
+ splt->contents + h->plt.offset - 4);
+ put_thumb_insn (htab, output_bfd, elf32_arm_plt_thumb_stub[1],
+ splt->contents + h->plt.offset - 2);
}
- bfd_put_32 (output_bfd, elf32_arm_plt_entry[0] | ((got_displacement & 0x0ff00000) >> 20),
- splt->contents + h->plt.offset + 0);
- bfd_put_32 (output_bfd, elf32_arm_plt_entry[1] | ((got_displacement & 0x000ff000) >> 12),
- splt->contents + h->plt.offset + 4);
- bfd_put_32 (output_bfd, elf32_arm_plt_entry[2] | (got_displacement & 0x00000fff),
- splt->contents + h->plt.offset + 8);
+ put_arm_insn (htab, output_bfd,
+ elf32_arm_plt_entry[0] | ((got_displacement & 0x0ff00000) >> 20),
+ splt->contents + h->plt.offset + 0);
+ put_arm_insn (htab, output_bfd,
+ elf32_arm_plt_entry[1] | ((got_displacement & 0x000ff000) >> 12),
+ splt->contents + h->plt.offset + 4);
+ put_arm_insn (htab, output_bfd,
+ elf32_arm_plt_entry[2] | (got_displacement & 0x00000fff),
+ splt->contents + h->plt.offset + 8);
#ifdef FOUR_WORD_PLT
- bfd_put_32 (output_bfd, elf32_arm_plt_entry[3],
+ put_arm_insn (htab, output_bfd, elf32_arm_plt_entry[3],
splt->contents + h->plt.offset + 12);
#endif
@@ -5317,10 +5350,14 @@ elf32_arm_finish_dynamic_sections (bfd *
- splt->output_offset
- 16);
- bfd_put_32 (output_bfd, elf32_arm_plt0_entry[0], splt->contents + 0);
- bfd_put_32 (output_bfd, elf32_arm_plt0_entry[1], splt->contents + 4);
- bfd_put_32 (output_bfd, elf32_arm_plt0_entry[2], splt->contents + 8);
- bfd_put_32 (output_bfd, elf32_arm_plt0_entry[3], splt->contents + 12);
+ put_arm_insn (htab, output_bfd, elf32_arm_plt0_entry[0],
+ splt->contents + 0);
+ put_arm_insn (htab, output_bfd, elf32_arm_plt0_entry[1],
+ splt->contents + 4);
+ put_arm_insn (htab, output_bfd, elf32_arm_plt0_entry[2],
+ splt->contents + 8);
+ put_arm_insn (htab, output_bfd, elf32_arm_plt0_entry[3],
+ splt->contents + 12);
#ifdef FOUR_WORD_PLT
/* The displacement value goes in the otherwise-unused last word of
the second entry. */