This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Decompress section before applying simple relocations


Hi,

Since bfd_get_full_section_contents caches the decompressed section
content, we have to decompress compressed section before applying
simple relocations if it doesn't use RELA relocations.  OK to install?

Thanks.


H.J.
---
2010-12-14  H.J. Lu  <hongjiu.lu@intel.com>

	* simple.c (bfd_simple_get_relocated_section_contents): If a
	compressed section doesn't use RELA relocations, decompress it
	first before applying simple relocations.

diff --git a/bfd/simple.c b/bfd/simple.c
index 03d1a15..ac92f80 100644
--- a/bfd/simple.c
+++ b/bfd/simple.c
@@ -207,6 +207,20 @@ bfd_simple_get_relocated_section_contents (bfd *abfd,
       if (data == NULL)
 	return NULL;
       outbuf = data;
+
+      /* If a compressed section doesn't use RELA relocations, we
+	 decompress it now so that applying simple relocations won't
+	 change its content.  */
+      if (!sec->use_rela_p
+	  && sec->compress_status == DECOMPRESS_SECTION_SIZED)
+	{
+	  bfd_byte *saved_outbuf =  (bfd_byte *) bfd_malloc (amt);
+	  if (saved_outbuf == NULL)
+	    return NULL;
+	  /* Decompress the section.  */
+	  if (!bfd_get_full_section_contents (abfd, sec, &saved_outbuf))
+	    return NULL;
+	}
     }
 
   /* The sections in ABFD may already have output sections and offsets set.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]