Fix Elf_auxv table. upx was duplicating AT_PHDR (and others)

because Linux 2.4.5 supplies many more AT_ entries than before.
First noticed by Sebastian <scut@nb.in-berlin.de>.
	fold_elf86.asm fold_sh86.asm l_lx_sep86.asm
	l_lx_elf.c     l_lx_sh.c     l_lx_sep.c

committer: jreiser <jreiser> 994871296 +0000
This commit is contained in:
John Reiser
2001-07-11 17:08:16 +00:00
parent caca5ffa12
commit ef17dc10ca
6 changed files with 186 additions and 129 deletions
+8 -8
View File
@@ -172,7 +172,7 @@ bzero(char *p, size_t len)
// Notice there is no make_hatch(), either.
static Elf32_Addr // entry address
do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, Elf32_auxv_t *const a)
do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, Elf32_auxv_t *const av)
{
Elf32_Phdr const *phdr = (Elf32_Phdr const *) (ehdr->e_phoff +
(char const *)ehdr);
@@ -180,7 +180,7 @@ do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, Elf32_auxv_t *const a)
int j;
for (j=0; j < ehdr->e_phnum; ++phdr, ++j)
if (PT_PHDR==phdr->p_type) {
a->a_un.a_val = phdr->p_vaddr;
av[AT_PHDR -1].a_un.a_val = phdr->p_vaddr;
}
else if (PT_LOAD==phdr->p_type) {
struct Extent xo;
@@ -301,12 +301,12 @@ void *upx_main(
entry = getexec(fn, ehdr, av);
*efn = c; // replace terminator character
av[0].a_type = AT_PHDR; // av[0].a_un.a_val is set by do_xmap
av[1].a_type = AT_PHENT; av[1].a_un.a_val = ehdr->e_phentsize;
av[2].a_type = AT_PHNUM; av[2].a_un.a_val = ehdr->e_phnum;
av[3].a_type = AT_PAGESZ; av[3].a_un.a_val = PAGE_SIZE;
av[4].a_type = AT_ENTRY; av[4].a_un.a_val = entry;
av[5].a_type = AT_NULL;
// av[AT_PHDR -1].a_un.a_val is set again by do_xmap if PT_PHDR is present.
av[AT_PHDR -1].a_type = AT_PHDR ; // av[AT_PHDR-1].a_un.a_val is set by do_xmap
av[AT_PHENT -1].a_type = AT_PHENT ; av[AT_PHENT -1].a_un.a_val = ehdr->e_phentsize;
av[AT_PHNUM -1].a_type = AT_PHNUM ; av[AT_PHNUM -1].a_un.a_val = ehdr->e_phnum;
av[AT_PAGESZ -1].a_type = AT_PAGESZ; av[AT_PAGESZ -1].a_un.a_val = PAGE_SIZE;
av[AT_ENTRY -1].a_type = AT_ENTRY ; av[AT_ENTRY -1].a_un.a_val = entry;
}
{ // Map PT_INTERP program interpreter