aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2012-01-05 09:57:18 +0000
committerNick Clifton <nickc@redhat.com>2012-01-05 09:57:18 +0000
commita1c7aafba7187298755c891834a048d60154c6a2 (patch)
tree0e5b940687e88185124060889a16906d6840beff /bfd
parentce1b17c4a3732bab97720e024796b79db4d2f450 (diff)
downloadgdb-a1c7aafba7187298755c891834a048d60154c6a2.zip
gdb-a1c7aafba7187298755c891834a048d60154c6a2.tar.gz
gdb-a1c7aafba7187298755c891834a048d60154c6a2.tar.bz2
PR ld/12161
* elf32-avr.c (elf32_avr_relax_delete_bytes): Read in relocs if necessary.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elf32-avr.c14
2 files changed, 18 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index eeef5a6..e544499 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-05 Nick Clifton <nickc@redhat.com>
+
+ PR ld/12161
+ * elf32-avr.c (elf32_avr_relax_delete_bytes): Read in relocs if
+ necessary.
+
2012-01-05 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix zero registers core files when built by gcc-4.7.
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 6d20aef..a7f9217 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -1503,11 +1503,18 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
bfd_vma symval;
bfd_vma shrinked_insn_address;
+ if (isec->reloc_count == 0)
+ continue;
+
shrinked_insn_address = (sec->output_section->vma
+ sec->output_offset + addr - count);
- irelend = elf_section_data (isec)->relocs + isec->reloc_count;
- for (irel = elf_section_data (isec)->relocs;
+ irel = elf_section_data (isec)->relocs;
+ /* PR 12161: Read in the relocs for this section if necessary. */
+ if (irel == NULL)
+ irel = _bfd_elf_link_read_relocs (abfd, isec, NULL, NULL, FALSE);
+
+ for (irelend = irel + isec->reloc_count;
irel < irelend;
irel++)
{
@@ -1564,6 +1571,9 @@ elf32_avr_relax_delete_bytes (bfd *abfd,
/* else...Reference symbol is extern. No need for adjusting
the addend. */
}
+
+ if (elf_section_data (isec)->relocs == NULL)
+ free (irelend - isec->reloc_count);
}
}