mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "vamsi krishna" <vamsi.krishnak@gmail.com>
To: linux-kernel@vger.kernel.org
Subject: Idea to create a elf executable from running program [process2executable]
Date: Sun, 19 Mar 2006 03:52:17 +0530	[thread overview]
Message-ID: <3faf05680603181422y7447fd7duc1032bd0e07b9c68@mail.gmail.com> (raw)

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?

Is there any way we can tell the elf loader to force the vaddr for
sbrk(0) i.e brk base ?

Let me know your suggestion on this idea?

Really appreciate your valuable comments.

Sincerely,
Vamsi

[PS: I dont know if some one has already implemented this idea??]

             reply	other threads:[~2006-03-18 22:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-18 22:22 vamsi krishna [this message]
2006-03-19  9:30 ` Arjan van de Ven
2006-03-19 19:41   ` John Reiser
2006-03-20  8:33 ` Cedric Le Goater
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=3faf05680603181422y7447fd7duc1032bd0e07b9c68@mail.gmail.com \
    --to=vamsi.krishnak@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®