[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libio/libioP.h:ALLOC_BUF() unconditionally uses mmap()
From: |
Wayne Whitney |
Subject: |
Re: libio/libioP.h:ALLOC_BUF() unconditionally uses mmap() |
Date: |
Mon, 17 Dec 2001 13:57:47 -0800 (PST) |
P.S. On the separate topic of modifying MAGMA instead of glibc or the
kernel, it occured to me that since MAGMA is linked statically, it could
just redefine __mmap() to request a higher address. So I tried adding
this to a test program:
#define __NR_real_mmap __NR_mmap
#define NEW_MAP_FIXED_BASE 0xA0000000
static inline _syscall6(void *, real_mmap, void *, start, size_t, len, int,
prot, int, flags, int, fd, off_t, offset);
void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t
offset)
{
if (start == 0 && fd == -1) {
start = (void *) NEW_MAP_FIXED_BASE;
/* flags &= MAP_FIXED; Is this needed */
}
return (real_mmap(start, len, prot, flags, fd, offset));
}
That changed the output of strace on the program from:
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x40000000
to:
old_mmap(ptrace: umoven: Input/output error
ptrace: umoven: Input/output error
) = -1 EFAULT (Bad address)
which suggests that I did something wrong. :-) I guess the mmap syscall
does not follow the syscall calling style that the _syscall6 macro
assumes. Is there an eaiser way to do this than to duplicate the contents
of glibc-2.2.4/sysdeps/unix/sysv/linux/i386/mmap.S? I assume that once I
have defined __mmap in my program, there is no way to reference the __mmap
object from mmap.o in libc.a.
Thanks, Wayne