ldso: update link map during respawn

move binary to front of link map after respawn. This is required by GDB
in order to load symbol files correctly.

issue #3481
This commit is contained in:
Sebastian Sumpf 2019-12-13 14:01:38 +01:00 committed by Christian Helmuth
parent 9c372c36c1
commit 22d4d5c1c1
2 changed files with 22 additions and 0 deletions

View File

@ -134,6 +134,20 @@ struct Linker::Link_map
first = map->next;
}
static void make_first(Link_map *map)
{
remove(map);
if (first) {
first->prev = map;
}
map->prev = nullptr;
map->next = first;
first = map;
Debug::d()->map = map;
}
static void dump()
{
if (!verbose_link_map)

View File

@ -193,6 +193,11 @@ class Linker::Elf_object : public Object, private Fifo<Elf_object>::Element
Link_map::add(&_map);
};
void link_map_make_first()
{
Link_map::make_first(&_map);
}
void force_keep() { _keep = KEEP; }
Link_map const &link_map() const override { return _map; }
@ -731,6 +736,9 @@ void *Dynamic_linker::_respawn(Env &env, char const *binary, char const *entry_n
/* load new binary */
construct_at<Binary>(binary_ptr, env, *heap(), config, name.string());
/* move to front of link map */
binary_ptr->link_map_make_first();
try {
return (void *)binary_ptr->lookup_symbol(entry_name);
}