Blame SOURCES/emacs-0005-ELF-unexec-Symbol-table-patching.patch

bb3be4
From b99e034e9696f745d8da4742251bb538e0841f63 Mon Sep 17 00:00:00 2001
bb3be4
From: Alan Modra <amodra@gmail.com>
bb3be4
Date: Sun, 8 Nov 2015 09:29:00 -0800
bb3be4
Subject: [PATCH 05/11] ELF unexec: Symbol table patching
bb3be4
bb3be4
No st_shndx value larger than SHN_LORESERVE should be changed.
bb3be4
* unexelf.c (unexec): Don't adjust any st_shndx larger than
bb3be4
SHN_LORESERVE.  Error on SHN_XINDEX.
bb3be4
---
bb3be4
 src/unexelf.c | 9 +++++----
bb3be4
 1 file changed, 5 insertions(+), 4 deletions(-)
bb3be4
bb3be4
diff --git a/src/unexelf.c b/src/unexelf.c
bb3be4
index 0065491..286ba2e 100644
bb3be4
--- a/src/unexelf.c
bb3be4
+++ b/src/unexelf.c
bb3be4
@@ -1118,7 +1118,7 @@ temacs:
bb3be4
 	}
bb3be4
 #endif /* __sgi */
bb3be4
 
bb3be4
-      /* If it is the symbol table, its st_shndx field needs to be patched.  */
bb3be4
+      /* Patch st_shndx field of symbol table.  */
bb3be4
       if (new_shdr->sh_type == SHT_SYMTAB
bb3be4
 	  || new_shdr->sh_type == SHT_DYNSYM)
bb3be4
 	{
bb3be4
@@ -1126,9 +1126,10 @@ temacs:
bb3be4
 	  ElfW (Sym) *sym = (ElfW (Sym) *) (new_shdr->sh_offset + new_base);
bb3be4
 	  for (; num--; sym++)
bb3be4
 	    {
bb3be4
-	      if ((sym->st_shndx == SHN_UNDEF)
bb3be4
-		  || (sym->st_shndx == SHN_ABS)
bb3be4
-		  || (sym->st_shndx == SHN_COMMON))
bb3be4
+	      if (sym->st_shndx == SHN_XINDEX)
bb3be4
+		fatal ("SHT_SYMTAB_SHNDX unsupported");
bb3be4
+	      if (sym->st_shndx == SHN_UNDEF
bb3be4
+		  || sym->st_shndx >= SHN_LORESERVE)
bb3be4
 		continue;
bb3be4
 
bb3be4
 	      PATCH_INDEX (sym->st_shndx);
bb3be4
-- 
bb3be4
2.7.4
bb3be4