public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Commit: RX: Fix relaxation when -no-keep-memory is active
@ 2015-03-16 11:13 Nick Clifton
  0 siblings, 0 replies; only message in thread
From: Nick Clifton @ 2015-03-16 11:13 UTC (permalink / raw)
  To: binutils

Hi Guys,

  I am applying the patch below to fix a bug in the RX port when
  performing relaxation with -no-keep-memory enabled.  In such cases the
  relocs will not be stored in the elf_section_data structure and the
  relaxation code needs to load them itself.

Cheers
  Nick

bfd/ChangeLog
2015-03-16  Nick Clifton  <nickc@redhat.com>

	* elf32-rx.c (elf32_rx_relax_delete_bytes): If the relocs are not
	stored in the elf_section_data structure then load them as
	necessary.

diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index 5d35d2a..b8c632e 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -1561,6 +1561,18 @@ elf32_rx_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, int count,
   irel = elf_section_data (sec)->relocs;
   irelend = irel + sec->reloc_count;
 
+  if (irel == NULL && sec->reloc_count > 0)
+    {
+      /* If the relocs have not been kept in the section data
+	 structure (because -no-keep-memory was used) then
+	 reread them now.  */
+      irel = (_bfd_elf_link_read_relocs
+	      (abfd, sec, NULL, (Elf_Internal_Rela *) NULL, FALSE));
+      if (irel == NULL)
+	/* FIXME: Return FALSE instead ?  */
+	irelend = irel;
+    }
+
   /* Actually delete the bytes.  */
   memmove (contents + addr, contents + addr + count,
 	   (size_t) (toaddr - addr - count));
@@ -1574,7 +1586,7 @@ elf32_rx_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 < 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:[~2015-03-16 11:13 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 11:13 Commit: RX: Fix relaxation when -no-keep-memory is active Nick Clifton

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).