summaryrefslogtreecommitdiff
path: root/src/unexelf.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2015-11-08 09:29:00 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2015-11-08 10:00:59 -0800
commit190b968f189cb7d06223bb39045ec9055df67f68 (patch)
tree9335140975b6e9066773329d1fbd04d7ef6e9c88 /src/unexelf.c
parent47c6e3035b8182c6436de4673473de7824ad59f1 (diff)
downloademacs-190b968f189cb7d06223bb39045ec9055df67f68.tar.gz
ELF unexec: Symbol table patching
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.
Diffstat (limited to 'src/unexelf.c')
-rw-r--r--src/unexelf.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/unexelf.c b/src/unexelf.c
index 0065491b453..286ba2e99c1 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -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);