1
0
mirror of https://github.com/upx/upx synced 2025-09-28 19:06:07 +08:00

bug in make_hatch_*(); simplify xfind_pages() when MAP_FIXED; update AT_BASE

This commit is contained in:
John Reiser 2007-05-16 13:48:44 -07:00
parent df8acc4ed7
commit e81dd05666

View File

@ -291,6 +291,9 @@ make_hatch_x86(Elf32_Phdr const *const phdr, unsigned const reloc)
* hatch = escape;
}
}
else {
hatch = 0;
}
}
return hatch;
}
@ -320,6 +323,9 @@ make_hatch_arm(Elf32_Phdr const *const phdr, unsigned const reloc)
hatch[0]= 0xef90005b; // syscall __NR_unmap
hatch[1]= 0xe1a0f00e; // mov pc,lr
}
else {
hatch = 0;
}
}
return hatch;
}
@ -340,9 +346,12 @@ make_hatch_mips(
)
{
hatch[0]= 0x0000000c; // syscall
hatch[1]= 0x03e00008; // jr $ra
hatch[1]= 0x03200008; // jr $25 # $25 === $t9 === jp
hatch[2]= 0x00000000; // nop
}
else {
hatch = 0;
}
}
return hatch;
}
@ -440,9 +449,14 @@ xfind_pages(unsigned mflags, Elf32_Phdr const *phdr, int phnum,
lo -= ~page_mask & lo; // round down to page boundary
hi = page_mask & (hi - lo - page_mask -1); // page length
szlo = page_mask & (szlo - page_mask -1); // page length
addr = mmap((void *)lo, hi, PROT_NONE, mflags, -1, 0);
if (MAP_FIXED & mflags) {
addr = (char *)lo;
}
else {
addr = mmap((void *)lo, hi, PROT_NONE, mflags, -1, 0);
//munmap(szlo + addr, hi - szlo);
}
*p_brk = hi + addr; // the logical value of brk(0)
//mprotect(szlo + addr, hi - szlo, PROT_NONE); // no access, but keep the frames!
return (unsigned long)addr - lo;
}
@ -657,8 +671,9 @@ void *upx_main(
ERR_LAB
err_exit(19);
}
entry = do_xmap(fdi, ehdr, 0, av, 0, 0);
//close(fdi); // FIXME: bug in mipsel gcc 4.1.1
entry = do_xmap(fdi, ehdr, 0, av, &reloc, 0);
auxv_up(av, AT_BASE, reloc); // uClibc only?
close(fdi);
break;
}
}