diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2016-06-06 16:47:18 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-06-07 10:03:45 +0300 |
commit | 577f883fab66a0af27ffe2dc24d2bc6a1b2f9806 (patch) | |
tree | 14ea19e287e48cbda4bcf7bf652df1c9cf2686b0 /data | |
parent | 2a7a4498f6240392a096f9e13cc0805fbf35e062 (diff) |
android: Work around NDK ABI incompatibility around bsd_signal/signal in a different way
Get the correct symbol via dlsym() instead of letting the linker figure it
out. Letting the linker do it can bring us into infinite recursion calling
into our very own weak symbol.
https://bugzilla.gnome.org/show_bug.cgi?id=766235
Diffstat (limited to 'data')
-rw-r--r-- | data/ndk-build/gstreamer_android-1.0.c.in | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/data/ndk-build/gstreamer_android-1.0.c.in b/data/ndk-build/gstreamer_android-1.0.c.in index 54ede21d..da3851ee 100644 --- a/data/ndk-build/gstreamer_android-1.0.c.in +++ b/data/ndk-build/gstreamer_android-1.0.c.in @@ -8,10 +8,38 @@ * symbol but only signal(). * See https://bugzilla.gnome.org/show_bug.cgi?id=766235 */ +static gpointer +load_real_signal (gpointer data) +{ + GModule *module; + gpointer ret = NULL; + + module = g_module_open ("libc.so", G_MODULE_BIND_LOCAL); + g_module_symbol (module, "signal", &ret); + + /* As fallback, let's try bsd_signal */ + if (ret == NULL) { + g_warning ("Can't find signal(3) in libc.so!"); + g_module_symbol (module, "bsd_signal", &ret); + } + + g_module_close (module); + + return ret; +} + __sighandler_t bsd_signal(int signum, __sighandler_t handler) __attribute__((weak)); __sighandler_t bsd_signal(int signum, __sighandler_t handler) { - return signal(signum, handler); + static GOnce gonce = G_ONCE_INIT; + __sighandler_t (*real_signal) (int signum, __sighandler_t handler); + + g_once (&gonce, load_real_signal, NULL); + + real_signal = gonce.retval; + g_assert (real_signal != NULL); + + return real_signal(signum, handler); } static jobject _context = NULL; |