Commit 7e70dd88 authored by Justin Kim's avatar Justin Kim Committed by Sebastian Dröge

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] 0d81bb4e

https://bugzilla.gnome.org/show_bug.cgi?id=788270
parent 860dc949
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment