Jan Synacek e76854
From 2776e4ffe1f4cf965a6b99201097ca7d4ee2f95c Mon Sep 17 00:00:00 2001
Jan Synacek e76854
From: Alan Modra <amodra@gmail.com>
Jan Synacek e76854
Date: Sun, 8 Nov 2015 09:29:00 -0800
Jan Synacek e76854
Subject: ELF unexec: Symbol table patching
Jan Synacek e76854
Jan Synacek e76854
Emacs should build on ppc64el.  A problem with the bss has been fixed.
Jan Synacek e76854
Jan Synacek e76854
This upstream patch has been added [4/10]:
Jan Synacek e76854
Jan Synacek e76854
  ELF unexec: Symbol table patching
Jan Synacek e76854
Jan Synacek e76854
  No st_shndx value larger than SHN_LORESERVE should be changed.
Jan Synacek e76854
  * unexelf.c (unexec): Don't adjust any st_shndx larger than
Jan Synacek e76854
  SHN_LORESERVE.  Error on SHN_XINDEX.
Jan Synacek e76854
Jan Synacek e76854
Origin: upstream, commit: 190b968f189cb7d06223bb39045ec9055df67f68
Jan Synacek e76854
Bug: http://debbugs.gnu.org/20614
Jan Synacek e76854
Bug-Debian: http://bugs.debian.org/808347
Jan Synacek e76854
Added-by: Rob Browning <rlb@defaultvalue.org>
Jan Synacek e76854
---
Jan Synacek e76854
 src/unexelf.c |    9 +++++----
Jan Synacek e76854
 1 file changed, 5 insertions(+), 4 deletions(-)
Jan Synacek e76854
Jan Synacek e76854
Index: emacs-24.5/src/unexelf.c
Jan Synacek e76854
===================================================================
Jan Synacek e76854
--- emacs-24.5.orig/src/unexelf.c
Jan Synacek e76854
+++ emacs-24.5/src/unexelf.c
Jan Synacek e76854
@@ -1119,7 +1119,7 @@ temacs:
Jan Synacek e76854
 	}
Jan Synacek e76854
 #endif /* __sgi */
Jan Synacek e76854
 
Jan Synacek e76854
-      /* If it is the symbol table, its st_shndx field needs to be patched.  */
Jan Synacek e76854
+      /* Patch st_shndx field of symbol table.  */
Jan Synacek e76854
       if (new_shdr->sh_type == SHT_SYMTAB
Jan Synacek e76854
 	  || new_shdr->sh_type == SHT_DYNSYM)
Jan Synacek e76854
 	{
Jan Synacek e76854
@@ -1127,9 +1127,10 @@ temacs:
Jan Synacek e76854
 	  ElfW (Sym) *sym = (ElfW (Sym) *) (new_shdr->sh_offset + new_base);
Jan Synacek e76854
 	  for (; num--; sym++)
Jan Synacek e76854
 	    {
Jan Synacek e76854
-	      if ((sym->st_shndx == SHN_UNDEF)
Jan Synacek e76854
-		  || (sym->st_shndx == SHN_ABS)
Jan Synacek e76854
-		  || (sym->st_shndx == SHN_COMMON))
Jan Synacek e76854
+	      if (sym->st_shndx == SHN_XINDEX)
Jan Synacek e76854
+		fatal ("SHT_SYMTAB_SHNDX unsupported");
Jan Synacek e76854
+	      if (sym->st_shndx == SHN_UNDEF
Jan Synacek e76854
+		  || sym->st_shndx >= SHN_LORESERVE)
Jan Synacek e76854
 		continue;
Jan Synacek e76854
 
Jan Synacek e76854
 	      PATCH_INDEX (sym->st_shndx);