Fix partial REL relocs.
This commit is contained in:
parent
cd5d26f264
commit
98c1d4aab7
2 changed files with 48 additions and 12 deletions
|
@ -1,3 +1,10 @@
|
|||
1999-08-19 Nick Clifton <nickc@cygnus.com>
|
||||
|
||||
* elf32-arm.h (arm_add_to_rel): New function. Add a value to
|
||||
a REL style reloc.
|
||||
(elf32_arm_relocate_section): Use arm_add_to_rel to increment
|
||||
REL relocs when performing a partial relocation.
|
||||
|
||||
1999-08-18 Donn Terry <donn@interix.com>
|
||||
|
||||
* cofflink.c: Move definitions of N_TMASK, et. al., out of
|
||||
|
|
|
@ -1581,6 +1581,45 @@ elf32_arm_final_link_relocate (howto, input_bfd, output_bfd,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef USE_REL
|
||||
/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. */
|
||||
static void
|
||||
arm_add_to_rel (abfd, address, howto, increment)
|
||||
bfd * abfd;
|
||||
bfd_vma address;
|
||||
reloc_howto_type * howto;
|
||||
bfd_signed_vma increment;
|
||||
{
|
||||
bfd_vma contents;
|
||||
bfd_signed_vma addend;
|
||||
|
||||
contents = bfd_get_32 (abfd, address);
|
||||
|
||||
/* Get the (signed) value from the instruction. */
|
||||
addend = contents & howto->src_mask;
|
||||
if (addend & ((howto->src_mask + 1) >> 1))
|
||||
{
|
||||
bfd_signed_vma mask;
|
||||
|
||||
mask = -1;
|
||||
mask &= ~ howto->src_mask;
|
||||
addend |= mask;
|
||||
}
|
||||
|
||||
/* Add in the increment, (which is a byte value). */
|
||||
addend <<= howto->size;
|
||||
addend += increment;
|
||||
|
||||
/* Should we check for overflow here ? */
|
||||
|
||||
/* Drop any undesired bits. */
|
||||
addend >>= howto->rightshift;
|
||||
|
||||
contents = (contents & ~ howto->dst_mask) | (addend & howto->dst_mask);
|
||||
|
||||
bfd_put_32 (abfd, contents, address);
|
||||
}
|
||||
#endif /* USE_REL */
|
||||
|
||||
/* Relocate an ARM ELF section. */
|
||||
static boolean
|
||||
|
@ -1641,18 +1680,8 @@ elf32_arm_relocate_section (output_bfd, info, input_bfd, input_section,
|
|||
{
|
||||
sec = local_sections[r_symndx];
|
||||
#ifdef USE_REL
|
||||
{
|
||||
bfd_vma val;
|
||||
bfd_vma insn;
|
||||
|
||||
insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
||||
val = insn + ((sec->output_offset + sym->st_value)
|
||||
>> howto->rightshift);
|
||||
val &= howto->dst_mask;
|
||||
val |= insn & ~(howto->dst_mask);
|
||||
|
||||
bfd_put_32 (input_bfd, val, contents + rel->r_offset);
|
||||
}
|
||||
arm_add_to_rel (input_bfd, contents + rel->r_offset,
|
||||
howto, sec->output_offset + sym->st_value);
|
||||
#else
|
||||
rel->r_addend += (sec->output_offset + sym->st_value)
|
||||
>> howto->rightshift;
|
||||
|
|
Loading…
Reference in a new issue