mlibc: backport shared object promotion fix

This commit is contained in:
Matheus
2026-05-25 21:16:30 -03:00
parent 01be955e58
commit 64e8c24b0d
2 changed files with 19 additions and 1 deletions
+18
View File
@@ -306,6 +306,24 @@ index 8592ea5..94ceba1 100644
+ }
+ return 0;
}
diff --git mlibc-clean/options/rtld/generic/main.cpp mlibc-workdir/options/rtld/generic/main.cpp
index bf54bcb..106916a 100644
--- mlibc-clean/options/rtld/generic/main.cpp
+++ mlibc-workdir/options/rtld/generic/main.cpp
@@ -729,7 +729,12 @@ void *__dlapi_open(const char *file, int flags, void *returnAddress) {
// TODO: Thread-safety!
auto rts = rtsCounter++;
- SharedObject *object = initialRepository->findLoadedObject(file);
+ auto objectName = frg::string_view{file};
+ auto lastSlash = objectName.find_last('/');
+ if (lastSlash != static_cast<size_t>(-1))
+ objectName = objectName.sub_string(lastSlash + 1, objectName.size() - (lastSlash + 1));
+
+ SharedObject *object = initialRepository->findLoadedObject(objectName);
if (object && object->globalRts == 0 && (flags & RTLD_GLOBAL)) {
// The object was opened with RTLD_LOCAL, but we are called with RTLD_GLOBAL.
// According to the man page, we should promote to the global scope here.
diff --git mlibc-clean/options/rtld/x86_64/runtime.S mlibc-workdir/options/rtld/x86_64/runtime.S
index ba9a520..b958ef3 100644
--- mlibc-clean/options/rtld/x86_64/runtime.S