[glib] gmodule: Use RTLD_DEFAULT if defined __BIONIC__
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gmodule: Use RTLD_DEFAULT if defined __BIONIC__
- Date: Fri, 6 Oct 2017 18:10:13 +0000 (UTC)
commit 7e70dd88c9dd7f7a6df57fd9b814632a6c7c3f00
Author: Justin Kim <justin kim collabora com>
Date: Thu Sep 28 16:10:05 2017 +0900
gmodule: Use RTLD_DEFAULT if defined __BIONIC__
This is a partial change of the previous work[0].
On 64 bit Android since android-23, 'handle = dlopen(NULL); dlsym(handle)'
doesn't work. Instead, only 'dlsym(RTLD_DEFAULT)' returns a valid pointer.
However, RTLD_DEFAULT is defined as '(void *) 0x0' on 64bit Android which
is usually used for invalid value so this patch allows the specific case.
[0] 0d81bb4e318b97780c70a55605cacf7e5b3fcaf7
https://bugzilla.gnome.org/show_bug.cgi?id=788270
gmodule/gmodule-dl.c | 9 +++++----
gmodule/gmodule.c | 4 ++++
2 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/gmodule/gmodule-dl.c b/gmodule/gmodule-dl.c
index 42363aa..5d0200c 100644
--- a/gmodule/gmodule-dl.c
+++ b/gmodule/gmodule-dl.c
@@ -115,10 +115,11 @@ _g_module_self (void)
/* On Android 32 bit (i.e. not __LP64__), dlopen(NULL)
* does not work reliable and generally no symbols are found
* at all. RTLD_DEFAULT works though.
- * On Android 64 bit, dlopen(NULL) seems to work but RTLD_DEFAULT
- * is NULL, which is considered an invalid module.
+ * On Android 64 bit, dlopen(NULL) seems to work but dlsym(handle)
+ * always returns 'undefined symbol'. Only if RTLD_DEFAULT or
+ * NULL is given, dlsym returns an appropriate pointer.
*/
-#if defined(__BIONIC__) && !defined(__LP64__)
+#if defined(__BIONIC__)
handle = RTLD_DEFAULT;
#else
handle = dlopen (NULL, RTLD_GLOBAL | RTLD_LAZY);
@@ -138,7 +139,7 @@ _g_module_close (gpointer handle,
*
* See above for the Android special case
*/
-#if defined(__BIONIC__) && !defined(__LP64__)
+#if defined(__BIONIC__)
is_unref = (handle != RTLD_DEFAULT);
#else
is_unref |= 1;
diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c
index c55fc76..886eb85 100644
--- a/gmodule/gmodule.c
+++ b/gmodule/gmodule.c
@@ -510,7 +510,11 @@ g_module_open (const gchar *file_name,
if (!main_module)
{
handle = _g_module_self ();
+/* On Android 64 bit, RTLD_DEFAULT is (void *)0x0
+ * so it always fails to create main_module if file_name is NULL */
+#if !defined(__BIONIC__) || !defined(__LP64__)
if (handle)
+#endif
{
main_module = g_new (GModule, 1);
main_module->file_name = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]