From 64e8c24b0d67e6f6c0177a35c671f7b500f5410c Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 25 May 2026 21:16:30 -0300 Subject: [PATCH] mlibc: backport shared object promotion fix --- patches/mlibc/jinx-working-patch.patch | 18 ++++++++++++++++++ recipes/mlibc | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index b2ae714e..0b0aac67 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -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(-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 diff --git a/recipes/mlibc b/recipes/mlibc index b01f87ee..6bd6e8ef 100644 --- a/recipes/mlibc +++ b/recipes/mlibc @@ -1,6 +1,6 @@ name=mlibc from_source=mlibc -revision=3 +revision=4 hostdeps="xgcc xbinutils pkgconfig" builddeps="freestnd-c-hdrs freestnd-cxx-hdrs frigg libsmarter" imagedeps="meson ninja-build git build-essential binutils"