2013-12-05 15:45:14 +01:00
|
|
|
/*
|
|
|
|
* \brief Call initialization functions for all modules and components
|
|
|
|
* \author Sebastian Sumpf
|
|
|
|
* \date 2013-12-12
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2013-2017 Genode Labs GmbH
|
2013-12-05 15:45:14 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2013-12-05 15:45:14 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <rump/rumpuser.h>
|
2017-11-14 16:03:16 +01:00
|
|
|
#include <exec_elf.h>
|
2013-12-05 15:45:14 +01:00
|
|
|
}
|
|
|
|
|
2017-01-06 14:23:53 +01:00
|
|
|
#include <rump/env.h>
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
#include <base/log.h>
|
2014-10-27 15:53:52 +01:00
|
|
|
#include <base/shared_object.h>
|
2013-12-05 15:45:14 +01:00
|
|
|
#include <util/string.h>
|
|
|
|
|
2017-01-06 14:23:53 +01:00
|
|
|
|
2013-12-05 15:45:14 +01:00
|
|
|
#ifdef _LP64
|
|
|
|
typedef Elf64_Dyn Elf_Dyn;
|
|
|
|
typedef Elf64_Sym Elf_Sym;
|
|
|
|
#else
|
|
|
|
typedef Elf32_Dyn Elf_Dyn;
|
|
|
|
typedef Elf32_Sym Elf_Sym;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static bool const verbose = false;
|
|
|
|
|
|
|
|
|
2016-10-30 15:17:24 +01:00
|
|
|
static Genode::Shared_object *obj_main;
|
|
|
|
|
|
|
|
|
|
|
|
static Genode::Env &env()
|
|
|
|
{
|
2017-01-06 14:23:53 +01:00
|
|
|
return Rump::env().env();
|
2016-10-30 15:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static Genode::Allocator &heap()
|
|
|
|
{
|
2017-01-06 14:23:53 +01:00
|
|
|
return Rump::env().heap();
|
2016-10-30 15:17:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-05 15:45:14 +01:00
|
|
|
void rumpuser_dl_bootstrap(rump_modinit_fn domodinit, rump_symload_fn symload,
|
|
|
|
rump_compload_fn compload)
|
|
|
|
{
|
|
|
|
/* open main program and request link map */
|
2014-10-27 15:53:52 +01:00
|
|
|
using namespace Genode;
|
2013-12-05 15:45:14 +01:00
|
|
|
|
2016-10-30 15:17:24 +01:00
|
|
|
try {
|
|
|
|
obj_main = new (heap()) Shared_object(::env(), heap(), nullptr,
|
|
|
|
Shared_object::BIND_NOW,
|
|
|
|
Shared_object::KEEP);
|
|
|
|
}
|
|
|
|
catch (...) { error("could not dlopen the main executable"); return; }
|
2013-12-05 15:45:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void * rumpuser_dl_globalsym(const char *symname)
|
|
|
|
{
|
|
|
|
|
2014-10-27 15:53:52 +01:00
|
|
|
void *addr = 0;
|
|
|
|
try { addr = obj_main->lookup(symname); }
|
|
|
|
catch (...) { }
|
2013-12-05 15:45:14 +01:00
|
|
|
|
|
|
|
if (verbose)
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("Lookup: ", symname, " addr ", addr);
|
2013-12-05 15:45:14 +01:00
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|