parent
c9b5dcafbd
commit
8af81668ea
|
@ -16,11 +16,4 @@ CC_C_OPT += -Wno-pointer-sign -Wno-unused-but-set-variable \
|
||||||
-Wno-nonnull-compare -Wno-misleading-indentation \
|
-Wno-nonnull-compare -Wno-misleading-indentation \
|
||||||
-Wno-format -Wno-incompatible-pointer-types
|
-Wno-format -Wno-incompatible-pointer-types
|
||||||
|
|
||||||
#
|
|
||||||
# rump.ld is an additional linker script which is required during
|
|
||||||
# initialization
|
|
||||||
#
|
|
||||||
LD_SCRIPT_SO = $(BASE_DIR)/src/ld/genode_rel.ld \
|
|
||||||
-T$(REP_DIR)/src/ld/rump.ld
|
|
||||||
|
|
||||||
# vi:set ft=make :
|
# vi:set ft=make :
|
||||||
|
|
|
@ -14,7 +14,7 @@ PORT_DIR := $(call port_dir,$(REP_DIR)/ports/dde_rump)
|
||||||
|
|
||||||
MIRROR_FROM_REP_DIR := $(LIB_MK) \
|
MIRROR_FROM_REP_DIR := $(LIB_MK) \
|
||||||
lib/import/import-rump.mk \
|
lib/import/import-rump.mk \
|
||||||
src/ld src/lib src/server/rump_fs \
|
src/lib src/server/rump_fs \
|
||||||
include/rump include/rump_fs \
|
include/rump include/rump_fs \
|
||||||
include/util
|
include/util
|
||||||
|
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* \brief Additonial sections required by all rump libraries
|
|
||||||
*
|
|
||||||
* Modified version of original linker script
|
|
||||||
*
|
|
||||||
* \author Sebastiasn Sumpf
|
|
||||||
* \date 2013-12-12
|
|
||||||
*/
|
|
||||||
|
|
||||||
SECTIONS
|
|
||||||
{
|
|
||||||
.rump_modules :
|
|
||||||
{
|
|
||||||
__start_link_set_modules = .;
|
|
||||||
KEEP(*(link_set_modules));
|
|
||||||
__stop_link_set_modules = .;
|
|
||||||
} : rw
|
|
||||||
|
|
||||||
.rump_domains :
|
|
||||||
{
|
|
||||||
__start_link_set_domains = .;
|
|
||||||
KEEP(*(link_set_domains));
|
|
||||||
__stop_link_set_domains = .;
|
|
||||||
} : rw
|
|
||||||
|
|
||||||
.rump_components :
|
|
||||||
{
|
|
||||||
__start_link_set_rump_components = .;
|
|
||||||
KEEP(*(link_set_rump_components));
|
|
||||||
__stop_link_set_rump_components = .;
|
|
||||||
} : rw
|
|
||||||
}
|
|
|
@ -50,185 +50,6 @@ static Genode::Allocator &heap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct Sym_tab
|
|
||||||
{
|
|
||||||
Genode::Shared_object::Link_map const *map;
|
|
||||||
|
|
||||||
void const *dynamic_base = nullptr;
|
|
||||||
void const *sym_base = nullptr;
|
|
||||||
|
|
||||||
Elf_Addr str_tab = 0;
|
|
||||||
size_t sym_cnt = 0;
|
|
||||||
size_t out_cnt = 0;
|
|
||||||
size_t str_size = 0;
|
|
||||||
|
|
||||||
Elf_Sym *sym_tab;
|
|
||||||
|
|
||||||
Sym_tab(Genode::Shared_object::Link_map const *map)
|
|
||||||
: map(map), dynamic_base(map->dynamic)
|
|
||||||
{
|
|
||||||
if (!dynamic_base) {
|
|
||||||
Genode::error(map->path, ": base is bogus ", Genode::Hex(map->addr));
|
|
||||||
throw -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (verbose)
|
|
||||||
Genode::log("for ", map->path, " at ", Genode::Hex(map->addr));
|
|
||||||
|
|
||||||
find_tables();
|
|
||||||
|
|
||||||
if (!sym_base) {
|
|
||||||
Genode::error(map->path, ": could not find symbol table "
|
|
||||||
"(sym_base ", sym_base, ")");
|
|
||||||
throw -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* alloc memory for the tables */
|
|
||||||
alloc_memory();
|
|
||||||
|
|
||||||
/* file sym_tab and str_tab */
|
|
||||||
read_symbols();
|
|
||||||
}
|
|
||||||
|
|
||||||
~Sym_tab()
|
|
||||||
{
|
|
||||||
if (sym_tab)
|
|
||||||
destroy(heap(), sym_tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Elf_Sym const *elf_symbol(int index = 0)
|
|
||||||
{
|
|
||||||
Elf_Sym const *s = static_cast<Elf_Sym const *>(sym_base);
|
|
||||||
return &s[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
Elf_Dyn const *elf_dyn(int index = 0)
|
|
||||||
{
|
|
||||||
Elf_Dyn const *d = static_cast<Elf_Dyn const *>(dynamic_base);
|
|
||||||
return &d[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_wanted(char const *name)
|
|
||||||
{
|
|
||||||
using namespace Genode;
|
|
||||||
return (!strcmp(name, "rump", 4) ||
|
|
||||||
!strcmp(name, "RUMP", 4) ||
|
|
||||||
!strcmp(name, "__", 2)) ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Find symtab and strtab
|
|
||||||
*/
|
|
||||||
void find_tables()
|
|
||||||
{
|
|
||||||
uint64_t dyn_tag = elf_dyn()->d_tag;
|
|
||||||
for (int i = 0;
|
|
||||||
dyn_tag != DT_NULL;
|
|
||||||
i++,
|
|
||||||
dyn_tag = elf_dyn(i)->d_tag) {
|
|
||||||
|
|
||||||
switch (dyn_tag) {
|
|
||||||
case DT_SYMTAB:
|
|
||||||
sym_base = (void *)(elf_dyn(i)->d_un.d_ptr + map->addr);
|
|
||||||
break;
|
|
||||||
case DT_STRTAB:
|
|
||||||
str_tab = elf_dyn(i)->d_un.d_ptr + map->addr;
|
|
||||||
break;
|
|
||||||
case DT_STRSZ:
|
|
||||||
str_size = elf_dyn(i)->d_un.d_ptr;
|
|
||||||
break;
|
|
||||||
case DT_HASH:
|
|
||||||
{
|
|
||||||
Elf_Symindx *hashtab = (Elf_Symindx *)(elf_dyn(i)->d_un.d_ptr +
|
|
||||||
map->addr);
|
|
||||||
sym_cnt = hashtab[1];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DT_SYMENT:
|
|
||||||
{
|
|
||||||
size_t sym_size = elf_dyn(i)->d_un.d_ptr;
|
|
||||||
if (sym_size != sizeof(Elf_Sym))
|
|
||||||
Genode::warning("Elf symbol size does not match binary ",
|
|
||||||
sym_size, " != ", sizeof(Elf_Sym));
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void alloc_memory()
|
|
||||||
{
|
|
||||||
sym_tab = (Elf_Sym *)heap().alloc(sizeof(Elf_Sym) * sym_cnt);
|
|
||||||
}
|
|
||||||
|
|
||||||
void read_symbols()
|
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < sym_cnt; i++) {
|
|
||||||
|
|
||||||
Elf_Sym const *sym = elf_symbol(i);
|
|
||||||
if (sym->st_shndx == SHN_UNDEF || !sym->st_value)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
char const *name = (char const *)(sym->st_name + str_tab);
|
|
||||||
if (!is_wanted(name))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sym_tab[out_cnt] = *sym;
|
|
||||||
/* set absolute value */
|
|
||||||
sym_tab[out_cnt].st_value += map->addr;
|
|
||||||
if (verbose)
|
|
||||||
Genode::log("Read symbol ", name, " "
|
|
||||||
"val: ", Genode::Hex(sym_tab[out_cnt].st_value));
|
|
||||||
out_cnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void rump_load(rump_symload_fn symload)
|
|
||||||
{
|
|
||||||
symload(sym_tab, sizeof(Elf_Sym) * out_cnt, (char *)str_tab, str_size);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call init functions of libraries
|
|
||||||
*/
|
|
||||||
static void _dl_init(Genode::Shared_object::Link_map const *map,
|
|
||||||
rump_modinit_fn mod_init,
|
|
||||||
rump_compload_fn comp_init)
|
|
||||||
{
|
|
||||||
using namespace Genode;
|
|
||||||
Shared_object *obj = nullptr;
|
|
||||||
try {
|
|
||||||
obj = new (heap()) Shared_object(::env(), heap(), map->path,
|
|
||||||
Shared_object::BIND_LAZY,
|
|
||||||
Shared_object::DONT_KEEP);
|
|
||||||
}
|
|
||||||
catch (...) { error("could not dlopen ", map->path); return; }
|
|
||||||
|
|
||||||
struct modinfo **mi_start, **mi_end;
|
|
||||||
struct rump_component **rc_start, **rc_end;
|
|
||||||
|
|
||||||
mi_start = obj->lookup<modinfo **>("__start_link_set_modules");
|
|
||||||
mi_end = obj->lookup<modinfo **>("__stop_link_set_modules");
|
|
||||||
if (verbose)
|
|
||||||
log("MI: start: ", mi_start, " end: ", mi_end);
|
|
||||||
if (mi_start && mi_end)
|
|
||||||
mod_init(mi_start, (Genode::size_t)(mi_end-mi_start));
|
|
||||||
|
|
||||||
rc_start = obj->lookup<rump_component **>("__start_link_set_rump_components");
|
|
||||||
rc_end = obj->lookup<rump_component **>("__stop_link_set_rump_components");
|
|
||||||
if (verbose)
|
|
||||||
log("RC: start: ", rc_start, " end: ", rc_end);
|
|
||||||
if (rc_start && rc_end) {
|
|
||||||
for (; rc_start < rc_end; rc_start++)
|
|
||||||
comp_init(*rc_start);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void rumpuser_dl_bootstrap(rump_modinit_fn domodinit, rump_symload_fn symload,
|
void rumpuser_dl_bootstrap(rump_modinit_fn domodinit, rump_symload_fn symload,
|
||||||
rump_compload_fn compload)
|
rump_compload_fn compload)
|
||||||
{
|
{
|
||||||
|
@ -241,21 +62,6 @@ void rumpuser_dl_bootstrap(rump_modinit_fn domodinit, rump_symload_fn symload,
|
||||||
Shared_object::KEEP);
|
Shared_object::KEEP);
|
||||||
}
|
}
|
||||||
catch (...) { error("could not dlopen the main executable"); return; }
|
catch (...) { error("could not dlopen the main executable"); return; }
|
||||||
|
|
||||||
Shared_object::Link_map const *map = &obj_main->link_map();
|
|
||||||
for (; map->next; map = map->next) ;
|
|
||||||
|
|
||||||
Shared_object::Link_map const *curr_map;
|
|
||||||
|
|
||||||
for (curr_map = map; curr_map; curr_map = curr_map->prev) {
|
|
||||||
if (!Genode::strcmp(curr_map->path, "rump", 4)) {
|
|
||||||
Sym_tab tab(curr_map);
|
|
||||||
/* load into rum kernel */
|
|
||||||
tab.rump_load(symload);
|
|
||||||
/* init modules and components */
|
|
||||||
_dl_init(curr_map, domodinit, compload);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user