]> code.delx.au - gnu-emacs/commitdiff
ELF unexec: Symbol table patching
authorAlan Modra <amodra@gmail.com>
Sun, 8 Nov 2015 17:29:00 +0000 (09:29 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 8 Nov 2015 18:00:59 +0000 (10:00 -0800)
No st_shndx value larger than SHN_LORESERVE should be changed.
* unexelf.c (unexec): Don't adjust any st_shndx larger than
SHN_LORESERVE.  Error on SHN_XINDEX.

src/unexelf.c

index 0065491b453fb86cf2ce2d985572718230760cfe..286ba2e99c1ccbd3a8ea83306044f31ad33b87c0 100644 (file)
@@ -1118,7 +1118,7 @@ temacs:
        }
 #endif /* __sgi */
 
-      /* If it is the symbol table, its st_shndx field needs to be patched.  */
+      /* Patch st_shndx field of symbol table.  */
       if (new_shdr->sh_type == SHT_SYMTAB
          || new_shdr->sh_type == SHT_DYNSYM)
        {
@@ -1126,9 +1126,10 @@ temacs:
          ElfW (Sym) *sym = (ElfW (Sym) *) (new_shdr->sh_offset + new_base);
          for (; num--; sym++)
            {
-             if ((sym->st_shndx == SHN_UNDEF)
-                 || (sym->st_shndx == SHN_ABS)
-                 || (sym->st_shndx == SHN_COMMON))
+             if (sym->st_shndx == SHN_XINDEX)
+               fatal ("SHT_SYMTAB_SHNDX unsupported");
+             if (sym->st_shndx == SHN_UNDEF
+                 || sym->st_shndx >= SHN_LORESERVE)
                continue;
 
              PATCH_INDEX (sym->st_shndx);