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