c - How do I load and execute an ELF binary executable manually? -


suppose binary pic, how can load memory , execute entry point? i'm doing familiar elf execve not allowed.

these basic steps:

  1. read program headers find load directives , determine total length of mappings you'll need, in pages.
  2. map lowest-address load directive total length (which may greater file length), letting mmap assign address. reserve contiguous virtual address space.
  3. map remining load directives on top of parts of mapping using map_fixed.
  4. use program headers find dynamic vector, in turn give address of relocation vector(s).
  5. apply relocations. assuming binary static-linked pie binary, should consist entirely of relative relocations (just adding base load address), meaning don't have perform symbol lookups or fancy.
  6. construct elf program entry stack consisting of following sequence of system-word-sized values in array on stack:

    argc argv[0] argv[1] ... argv[argc-1] 0 environ[0] environ[1] ... environ[n] 0 0 
  7. (this step requires asm!) point stack pointer @ beginning of array , jump loaded program's entry point address (which can found in program headers).


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -