From bfd9c48039c0f7966ac7f7c6c544f04f291270e5 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Wed, 27 Sep 2017 09:47:27 +0200 Subject: [PATCH] libc: support RTLD_DEFAULT in dlsym issue #2791 --- repos/libports/src/lib/libc/dynamic_linker.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/repos/libports/src/lib/libc/dynamic_linker.cc b/repos/libports/src/lib/libc/dynamic_linker.cc index 8e58a02301..791c4d7466 100644 --- a/repos/libports/src/lib/libc/dynamic_linker.cc +++ b/repos/libports/src/lib/libc/dynamic_linker.cc @@ -87,13 +87,20 @@ void *dlopen(const char *name, int mode) void *dlsym(void *handle, const char *name) { - if (handle == nullptr || handle == RTLD_NEXT || handle == RTLD_DEFAULT || - handle == RTLD_SELF) { + if (handle == nullptr || handle == RTLD_NEXT || handle == RTLD_SELF) { snprintf(err_str, MAX_ERR, "Unsupported handle %p\n", handle); return nullptr; } try { + if (handle == RTLD_DEFAULT) { + static Libc::Allocator global_alloc; + + return Shared_object(*genode_env, global_alloc, nullptr, + Shared_object::BIND_LAZY, + Shared_object::KEEP).lookup(name); + } + return to_object(handle)->lookup(name); } catch (...) { snprintf(err_str, MAX_ERR, "Symbol '%s' not found\n", name);