From: Cedric Le Goater <clg@fr.ibm.com>
To: vamsi krishna <vamsi.krishnak@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Idea to create a elf executable from running program [process2executable]
Date: Mon, 20 Mar 2006 09:33:10 +0100 [thread overview]
Message-ID: <441E68C6.7030107@fr.ibm.com> (raw)
In-Reply-To: <3faf05680603181422y7447fd7duc1032bd0e07b9c68@mail.gmail.com>
vamsi krishna wrote:
> Hello All,
>
> I have been working on an idea of creating an executable from a
> running process image.
>
> MOTIVATION:
> Process migration among the nodes in distributed computing,
> checkpointing process state.
>
> BASIS:
>
> The basis of my idea would be update the existing executable with
> extra PHDRS (Program Headers) with type PT_LOAD and each of these
> headers corresponding the vaddr mapping from /proc/<pid>/maps.
>
> I have done some basic study of kernels loders code in
> 'fs/binfmt_elf.c' especially code in 'load_elf_binary' function, the
> following is my understanding.
> <------------------------------------------>
> bss=0;
> brk=0;
> foreach (phdr in elf_header){
>
> if(phdr->type == PT_LOAD){
> if( phdr->filesize < phdr->memsize){
> /* Segment with .bss, so update brk and bss*/
> }
> else {
> /* Just map it*/
> }
> }
> /*Update brk bss*/
> }
> <------------------------------------>
>
> from the above the kernel is updating brk, thus creating the start of
> sbrk(0) only when it sees a PT_LOAD segment with filesize<memsize. So
> if I create a elf executable with all PT_LOAD segments with out any
> segments with filesize < memsize. The kernel will set brk base i.e
> sbrk(0) to the value phdr->vaddr+phdr->memsize of the last PT_LOAD
> segment its mapping? so do I need to reoder my PT_LOAD segments so
> that the heap goes as the last PT_LOAD segment?
Why don't you let execve() finish its job before modifying the mapping ?
Once execve returns, the segments are mapped and you are free to remap them
however you want and fill them in with a state previously saved on disk.
C.
next prev parent reply other threads:[~2006-03-20 8:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-18 22:22 Idea to create a elf executable from running program [process2executable] vamsi krishna
2006-03-19 9:30 ` Arjan van de Ven
2006-03-19 19:41 ` John Reiser
2006-03-20 8:33 ` Cedric Le Goater [this message]
2006-03-20 8:41 ` vamsi krishna
2006-03-21 8:43 ` Roberto Nibali
2006-03-22 5:18 ` Andrew Shewmaker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=441E68C6.7030107@fr.ibm.com \
--to=clg@fr.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=vamsi.krishnak@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.