thank you both for your answers! I actually got Norman's approach working using a slightly modified version of the demo's launchpad. With this launchpad, all I have to do is load incoming binaries into an Attached_ram_dataspace as Norman said.
diff --git a/repos/demo/include/launchpad/launchpad.h b/repos/demo/include/launchpad/launchpad.h
index 9aa0ed5..2e319f8 100644
--- a/repos/demo/include/launchpad/launchpad.h
+++ b/repos/demo/include/launchpad/launchpad.h
@@ -268,7 +268,9 @@ class Launchpad
Genode::Allocator *alloc) { }
Launchpad_child *start_child(const char *prg_name, unsigned long quota,
- Genode::Dataspace_capability config_ds);
+ Genode::Dataspace_capability config_ds,
+ Genode::Dataspace_capability binary_ds =
+ Genode::Dataspace_capability());
/**
* Exit child and close all its sessions
diff --git a/repos/demo/src/lib/launchpad/launchpad.cc b/repos/demo/src/lib/launchpad/launchpad.cc
index d60ad51..2fde521 100644
--- a/repos/demo/src/lib/launchpad/launchpad.cc
+++ b/repos/demo/src/lib/launchpad/launchpad.cc
@@ -186,7 +186,8 @@ void Launchpad::process_config()
Launchpad_child *Launchpad::start_child(const char *filename,
unsigned long ram_quota,
- Genode::Dataspace_capability config_ds)
+ Genode::Dataspace_capability config_ds,
+ Genode::Dataspace_capability binary_ds)
{
printf("starting %s with quota %lu\n", filename, ram_quota);
@@ -212,19 +213,27 @@ Launchpad_child *Launchpad::start_child(const char *filename,
/* lookup executable elf binary */
Dataspace_capability file_cap;
Rom_session_capability rom_cap;
- try {
- /*
- * When creating a ROM connection for a non-existing file, the
- * constructor of 'Rom_connection' throws a 'Parent::Service_denied'
- * exception.
- */
- Rom_connection rom(filename, unique_name);
- rom.on_destruction(Rom_connection::KEEP_OPEN);
- rom_cap = rom.cap();
- file_cap = rom.dataspace();
- } catch (...) {
- printf("Error: Could not access file \"%s\" from ROM service.\n", filename);
- return 0;
+ if (binary_ds == Genode::Dataspace_capability())
+ {
+ /* invalid dataspace, look up in file */
+ try {
+ /*
+ * When creating a ROM connection for a non-existing file, the
+ * constructor of 'Rom_connection' throws a 'Parent::Service_denied'
+ * exception.
+ */
+ Rom_connection rom(filename, unique_name);
+ rom.on_destruction(Rom_connection::KEEP_OPEN);
+ rom_cap = rom.cap();
+ file_cap = rom.dataspace();
+ } catch (...) {
+ printf("Error: Could not access file \"%s\" from ROM service.\n", filename);
+ return 0;
+ }
+ }
+ else
+ {
+ file_cap = binary_ds;
}
/* create ram session for child with some of our own quota */