gcc-4.1.0 vs. mmap()

linux.hh
	fold_elf86.asm  l_lx_elf.c
	fold_exec86.asm l_lx_exec.c
	fold_pti86.asm  l_lx_pti.c
	fold_sh86.asm   l_lx_sh.c    l_lx_sh86.asm
	l_lx_sep.c

committer: jreiser <jreiser> 1142305438 +0000
This commit is contained in:
John Reiser
2006-03-14 03:03:58 +00:00
parent a3097d5e25
commit 676cacff04
11 changed files with 72 additions and 57 deletions
+5 -11
View File
@@ -93,14 +93,8 @@ do_brk(void *addr)
return brk(addr);
}
static char *
__attribute_cdecl
do_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
{
(void)len; (void)prot; (void)flags; (void)fd; (void)offset;
return mmap((void *)&addr);
}
extern char *mmap(void *addr, size_t len,
int prot, int flags, int fd, off_t offset);
/*************************************************************************
// UPX & NRV stuff
@@ -215,7 +209,7 @@ 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 = do_mmap((void *)lo, hi, PROT_READ|PROT_WRITE|PROT_EXEC, mflags, 0, 0);
addr = mmap((void *)lo, hi, PROT_READ|PROT_WRITE|PROT_EXEC, mflags, 0, 0);
// Doing this may destroy the brk() that we set so carefully above.
// The munmap() is "needed" only for discontiguous PT_LOAD,
@@ -257,7 +251,7 @@ do_xmap(int const fdi, Elf32_Ehdr const *const ehdr, Elf32_auxv_t *const av)
haddr += reloc;
// Decompressor can overrun the destination by 3 bytes.
if (addr != do_mmap(addr, mlen, PROT_READ | PROT_WRITE,
if (addr != mmap(addr, mlen, PROT_READ | PROT_WRITE,
MAP_FIXED | MAP_PRIVATE,
fdi, phdr->p_offset - frag) ) {
err_exit(8);
@@ -271,7 +265,7 @@ ERR_LAB
}
addr += mlen + frag; /* page boundary on hi end */
if (addr < haddr) { // need pages for .bss
if (addr != do_mmap(addr, haddr - addr, prot,
if (addr != mmap(addr, haddr - addr, prot,
MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, 0, 0 ) ) {
err_exit(9);
}