base: rm first-class support for static binaries

This patch removes the detection of statically linked executables from
the base framework. It thereby fixes the corner cases encountered with
Sculpt when obtaining the binaries of the runtime from the depot_rom
service that is hosted within the runtime.

Statically linked binaries and hybrid Linux/Genode (lx_hybrid) binaries
can still be started by relabeling the ROM-session route of "ld.lib.so"
to the binary name, pretending that the binary is the dynamic linker.
This can be achieved via init's label rewriting mechanism:

  <route>
    <service name="ROM" unscoped_label="ld.lib.so">
      <parent label="test-platform"/> </service>
  </route>

However, as this is quite cryptic and would need to be applied for all
lx_hybrid components, the patch adds a shortcut to init's configuration.
One can simply add the 'ld="no"' attribute to the <start> node of the
corresponding component:

  <start name="test-platform" ld="no"/>

Fixes #2866
This commit is contained in:
Norman Feske
2018-07-04 18:48:04 +02:00
committed by Christian Helmuth
parent c43ed44b17
commit 4b46abf813
35 changed files with 102 additions and 130 deletions

View File

@ -50,7 +50,7 @@ void Child::Initial_thread::start(addr_t) { }
/*
* On Linux, the ELF loading is performed by the kernel
*/
Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability,
Child::Process::Loaded_executable::Loaded_executable(Type,
Dataspace_capability,
Ram_session &,
Region_map &,
@ -58,51 +58,27 @@ Child::Process::Loaded_executable::Loaded_executable(Dataspace_capability,
Parent_capability) { }
Child::Process::Process(Dataspace_capability elf_ds,
Child::Process::Process(Type type,
Dataspace_capability ldso_ds,
Pd_session_capability,
Pd_session &pd,
Ram_session &ram,
Initial_thread_base &,
Region_map &local_rm,
Region_map &remote_rm,
Parent_capability parent_cap)
:
loaded_executable(elf_ds, ldso_ds, ram, local_rm, remote_rm, parent_cap)
loaded_executable(type, ldso_ds, pd, local_rm, remote_rm, parent_cap)
{
/* skip loading when called during fork */
if (!elf_ds.valid())
if (type == TYPE_FORKED)
return;
/* attach ELF locally */
addr_t elf_addr;
try { elf_addr = local_rm.attach(elf_ds); }
catch (Region_map::Invalid_dataspace) {
error("local attach of ELF executable failed (Invalid_dataspace)"); throw; }
catch (Region_map::Region_conflict) {
error("local attach of ELF executable failed (Region_conflict)"); throw; }
/* setup ELF object and read program entry pointer */
Elf_binary elf(elf_addr);
if (!elf.valid())
throw Invalid_executable();
bool const dynamically_linked = elf.dynamically_linked();
local_rm.detach(elf_addr);
/*
* If the specified executable is a dynamically linked program, we load
* the dynamic linker instead.
*/
if (dynamically_linked) {
if (!ldso_ds.valid()) {
error("attempt to start dynamic executable without dynamic linker");
throw Missing_dynamic_linker();
}
elf_ds = ldso_ds;
if (!ldso_ds.valid()) {
error("attempt to start dynamic executable without dynamic linker");
throw Missing_dynamic_linker();
}
pd.assign_parent(parent_cap);
@ -110,7 +86,7 @@ Child::Process::Process(Dataspace_capability elf_ds,
Linux_native_pd_client
lx_pd(static_cap_cast<Linux_native_pd>(pd.native_pd()));
lx_pd.start(elf_ds);
lx_pd.start(ldso_ds);
}