ldso: dump link map of loaded shared objects

Also log the link-map information of shared objects loaded after startup
if 'ld_verbose' is configured.
This commit is contained in:
Christian Helmuth 2016-04-03 11:35:30 +02:00
parent 4ef2b0ed2e
commit 7a64e0bb80
4 changed files with 31 additions and 16 deletions

View File

@ -12,8 +12,23 @@
*/
#include <debug.h>
#include <linker.h>
/**
* C-break function for GDB
*/
extern "C" void brk(Linker::Debug *, Linker::Link_map *) { }
void Linker::dump_link_map(Object *o)
{
for (; o; o = o->next_obj()) {
if (o->is_binary())
continue;
Genode::printf(" " EFMT " .. " EFMT ": %s\n",
o->link_map()->addr, o->link_map()->addr + o->size() - 1,
o->name());
}
}

View File

@ -22,8 +22,12 @@ constexpr bool verbose_link_map = false;
namespace Linker {
struct Debug;
struct Link_map;
struct Object;
void dump_link_map(Object *o);
}
/**
* LIBC debug support
*/

View File

@ -538,21 +538,6 @@ extern "C" void init_rtld()
}
static void dump_loaded()
{
Object *o = Elf_object::obj_list()->head();
for(; o; o = o->next_obj()) {
if (o->is_binary())
continue;
Genode::printf(" " EFMT " .. " EFMT ": %s\n",
o->link_map()->addr, o->link_map()->addr + o->size() - 1,
o->name());
}
}
Genode::size_t Component::stack_size() { return 16*1024*sizeof(long); }
char const * Component::name() { return "ep"; }
@ -585,7 +570,7 @@ void Component::construct(Genode::Environment &env)
Genode::Thread_base::stack_area_virtual_base(),
Genode::Thread_base::stack_area_virtual_base() +
Genode::Thread_base::stack_area_virtual_size() - 1);
dump_loaded();
dump_link_map(Elf_object::obj_list()->head());
}
} catch (...) { }

View File

@ -11,6 +11,10 @@
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <os/config.h>
/* local includes */
#include <linker.h>
@ -63,6 +67,13 @@ Genode::Shared_object::Shared_object(char const *file, unsigned flags)
bind_now = (flags & Shared_object::NOW) ? true : false;
_handle = (Root_object *)new (Genode::env()->heap()) Root_object(file ? file : binary_name(), flags);
/* print loaded object information */
try {
if (Genode::config()->xml_node().attribute("ld_verbose").has_value("yes"))
Linker::dump_link_map(to_root(_handle)->dep.head()->obj);
} catch (...) { }
} catch (...) { throw Invalid_file(); }
}