Skip to contentSkip to conversation

Execute a char buffer without loading ELF

Qemu-devel John Vele 2 participants 2 messages Mar 23, 2010 – Mar 24, 2010

lore
Share & tools
lore

John Vele

author
#0 lore raw

Hello,

I am involved in a project that we use Qemu user mode for i386 (./i386-linux-user/qemu-i386). I want to modify the source code in such a way to make qemu execute a buffer of bytes (given from the comman line for example) rather than loading
an ELF file and executing. I started looking at linux-user/linuxload.c loader_exec() function and linux-user/elfload.c load_elf_binary() function. Is there a way to bypass the loading of an ELF file and load a single buffer of bytes (that is i386 code) into memory
and make Qemu start execution on it?

Any help or comment is very very appreciated.

Thanx in advance

#1 lore raw
Quoted 9 lines

I am involved in a project that we use Qemu user mode for i386 (./i386-linux-user/qemu-i386). I want to modify the source code in such a way to make qemu execute a buffer of bytes (given from the comman line for example) rather than loading
an ELF file and executing. I started looking at linux-user/linuxload.c loader_exec() function and linux-user/elfload.c load_elf_binary() function. Is there a way to bypass the loading of an ELF file and load a single buffer of bytes (that is i386 code) into memory
and make Qemu start execution on it?

Short answer is no.

Long answer is:
- Creating an ELF image from a blob of data if fairly trivial, so you don't really need this functionality.
- You're using linux usermode emulation. Linux doesn't load and execute random data. Neither do we.
- Loading a blob of code at an arbitrary location probably won't do what you want anyway.

Paul