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

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