public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [rl78] make sure relocs are loaded before using them
@ 2013-11-06  3:13 DJ Delorie
  0 siblings, 0 replies; only message in thread
From: DJ Delorie @ 2013-11-06  3:13 UTC (permalink / raw)
  To: binutils


Committed.  Apparently, we can have internal relocs loaded without
having the ELF relocs loaded...

	* elf32-rl78.c (elf32_rl78_relax_delete_bytes): Make sure relocs
	are loaded before trying to use them.

diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index 9060663..5bdef67 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -1481,6 +1481,12 @@ elf32_rl78_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, int count
     toaddr = alignment_rel->r_offset;
 
   irel = elf_section_data (sec)->relocs;
+  if (irel == NULL)
+    {
+      _bfd_elf_link_read_relocs (sec->owner, sec, NULL, NULL, TRUE);
+      irel = elf_section_data (sec)->relocs;
+    }
+
   irelend = irel + sec->reloc_count;
 
   /* Actually delete the bytes.  */
@@ -1496,7 +1502,7 @@ elf32_rl78_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, int count
     memset (contents + toaddr - count, 0x03, count);
 
   /* Adjust all the relocs.  */
-  for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
+  for (; irel && irel < irelend; irel++)
     {
       /* Get the new reloc address.  */
       if (irel->r_offset > addr

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-11-06  3:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-06  3:13 [rl78] make sure relocs are loaded before using them DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).