bug in make_hatch_*(); simplify xfind_pages() when MAP_FIXED; update AT_BASE
This commit is contained in:
@@ -291,6 +291,9 @@ make_hatch_x86(Elf32_Phdr const *const phdr, unsigned const reloc)
|
|||||||
* hatch = escape;
|
* hatch = escape;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
hatch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return hatch;
|
return hatch;
|
||||||
}
|
}
|
||||||
@@ -320,6 +323,9 @@ make_hatch_arm(Elf32_Phdr const *const phdr, unsigned const reloc)
|
|||||||
hatch[0]= 0xef90005b; // syscall __NR_unmap
|
hatch[0]= 0xef90005b; // syscall __NR_unmap
|
||||||
hatch[1]= 0xe1a0f00e; // mov pc,lr
|
hatch[1]= 0xe1a0f00e; // mov pc,lr
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
hatch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return hatch;
|
return hatch;
|
||||||
}
|
}
|
||||||
@@ -340,9 +346,12 @@ make_hatch_mips(
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
hatch[0]= 0x0000000c; // syscall
|
hatch[0]= 0x0000000c; // syscall
|
||||||
hatch[1]= 0x03e00008; // jr $ra
|
hatch[1]= 0x03200008; // jr $25 # $25 === $t9 === jp
|
||||||
hatch[2]= 0x00000000; // nop
|
hatch[2]= 0x00000000; // nop
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
hatch = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return hatch;
|
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
|
lo -= ~page_mask & lo; // round down to page boundary
|
||||||
hi = page_mask & (hi - lo - page_mask -1); // page length
|
hi = page_mask & (hi - lo - page_mask -1); // page length
|
||||||
szlo = page_mask & (szlo - page_mask -1); // page length
|
szlo = page_mask & (szlo - page_mask -1); // page length
|
||||||
|
if (MAP_FIXED & mflags) {
|
||||||
|
addr = (char *)lo;
|
||||||
|
}
|
||||||
|
else {
|
||||||
addr = mmap((void *)lo, hi, PROT_NONE, mflags, -1, 0);
|
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)
|
*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;
|
return (unsigned long)addr - lo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,8 +671,9 @@ void *upx_main(
|
|||||||
ERR_LAB
|
ERR_LAB
|
||||||
err_exit(19);
|
err_exit(19);
|
||||||
}
|
}
|
||||||
entry = do_xmap(fdi, ehdr, 0, av, 0, 0);
|
entry = do_xmap(fdi, ehdr, 0, av, &reloc, 0);
|
||||||
//close(fdi); // FIXME: bug in mipsel gcc 4.1.1
|
auxv_up(av, AT_BASE, reloc); // uClibc only?
|
||||||
|
close(fdi);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user