aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf32-avr.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/elf32-avr.c')
-rw-r--r--bfd/elf32-avr.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index b95e251..a0a5c69 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1822,7 +1822,7 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
Elf_Internal_Rela *irel, *irelend;
Elf_Internal_Sym *isym;
Elf_Internal_Sym *isymbuf = NULL;
- bfd_vma toaddr;
+ bfd_vma toaddr, reloc_toaddr;
struct elf_link_hash_entry **sym_hashes;
struct elf_link_hash_entry **end_hashes;
unsigned int symcount;
@@ -1859,6 +1859,17 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
}
}
+ /* We need to look at all relocs with offsets less than toaddr. prop
+ records handling adjusts toaddr downwards to avoid moving syms at the
+ address of the property record, but all relocs with offsets between addr
+ and the current value of toaddr need to have their offsets adjusted.
+ Assume addr = 0, toaddr = 4 and count = 2. After prop records handling,
+ toaddr becomes 2, but relocs with offsets 2 and 3 still need to be
+ adjusted (to 0 and 1 respectively), as the first 2 bytes are now gone.
+ So record the current value of toaddr here, and use it when adjusting
+ reloc offsets. */
+ reloc_toaddr = toaddr;
+
irel = elf_section_data (sec)->relocs;
irelend = irel + sec->reloc_count;
@@ -1917,7 +1928,7 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
/* Get the new reloc address. */
if ((irel->r_offset > addr
- && irel->r_offset < toaddr))
+ && irel->r_offset < reloc_toaddr))
{
if (debug_relax)
printf ("Relocation at address 0x%x needs to be moved.\n"