adfca8
From c00b42d59c296ef9b0660afd7b31e1d3c10972e7 Mon Sep 17 00:00:00 2001
adfca8
From: Alan Modra <amodra@gmail.com>
adfca8
Date: Sun, 8 Nov 2015 09:29:00 -0800
adfca8
Subject: [PATCH 07/11] ELF unexec: R_*_NONE relocs
adfca8
adfca8
These should be ignored on all targets.
adfca8
adfca8
* unexelf.c (unexec): Ignore R_*_NONE relocs for any target,
adfca8
not just Alpha.  Comment on reloc size assumption.
adfca8
---
adfca8
 src/unexelf.c | 14 +++++++-------
adfca8
 1 file changed, 7 insertions(+), 7 deletions(-)
adfca8
adfca8
diff --git a/src/unexelf.c b/src/unexelf.c
adfca8
index df99f92..15a4cde 100644
adfca8
--- a/src/unexelf.c
adfca8
+++ b/src/unexelf.c
adfca8
@@ -1202,7 +1202,7 @@ temacs:
adfca8
     }
adfca8
 
adfca8
   /* This loop seeks out relocation sections for the data section, so
adfca8
-     that it can undo relocations performed by the runtime linker.  */
adfca8
+     that it can undo relocations performed by the runtime loader.  */
adfca8
   for (n = new_file_h->e_shnum; 0 < --n; )
adfca8
     {
adfca8
       ElfW (Shdr) *rel_shdr = &NEW_SECTION_H (n);
adfca8
@@ -1235,14 +1235,14 @@ temacs:
adfca8
 		   reloc += rel_shdr->sh_entsize)
adfca8
 		{
adfca8
 		  ElfW (Addr) addr = ((ElfW (Rel) *) reloc)->r_offset - offset;
adfca8
-#ifdef __alpha__
adfca8
-		  /* The Alpha ELF binutils currently have a bug that
adfca8
-		     sometimes results in relocs that contain all
adfca8
-		     zeroes.  Work around this for now...  */
adfca8
+		  /* Ignore R_*_NONE relocs.  */
adfca8
 		  if (((ElfW (Rel) *) reloc)->r_offset == 0)
adfca8
 		    continue;
adfca8
-#endif
adfca8
-		  memcpy (new_base + addr, old_base + addr, sizeof (ElfW (Addr)));
adfca8
+		  /* Assume reloc applies to a word.
adfca8
+		     ??? This is not always true, eg. TLS module/index
adfca8
+		     pair in .got which occupies two words.  */
adfca8
+		  memcpy (new_base + addr, old_base + addr,
adfca8
+			  sizeof (ElfW (Addr)));
adfca8
 		}
adfca8
 	    }
adfca8
 	  break;
adfca8
-- 
adfca8
2.7.4
adfca8