malloc, mmap, and unexec issue
From: Darren Kwan (dkwan_at_axiscorp.com)
Date: 08/08/03
- Next message: Kasper Dupont: "Re: [solved] how to find the current tty from a daemon?"
- Previous message: Andi Kleen: "Re: Design & implemention of a new network protocol on linux"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 8 Aug 2003 11:28:16 -0700
Hi Everybody,
I have a problem regarding malloc() using mmap() for large memory
allocations. I'll try to describe it the best I can. I have an
executable I'll call 'foo'. Arguments can be passed to 'foo' to change
its functionality. ie. 'foo -a -b'. Using code derived from emacs
unexec(), I create a new binary executable I'll call 'foo2'.
Therefore, running 'foo2' is equivalent to running 'foo -a -b'.
The way I understand it, unexec() lifts the data segment from the
source binary and patches it into the destination binary. The problem
is if the source binary 'foo' uses malloc() which uses mmap(), the
allocated memory doesn't appear in the 'foo' data segment which then
doesn't get patched to ‘foo2' and I get a segmentation fault if I run
‘foo2'. I can use mallopt() to deny malloc() from using mmap() and
then it works, but I'll be limited in the amount of memory I can
allocate.
There's no problem running in Solaris.
Can anyone suggest a workaround? I'm using Red Hat 7.2/7.3, gcc and
glibc, and the binaries are ELF.
Thanks!
Darren Kwan
Axis Systems
dkwan@axiscorp.com
- Next message: Kasper Dupont: "Re: [solved] how to find the current tty from a daemon?"
- Previous message: Andi Kleen: "Re: Design & implemention of a new network protocol on linux"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|