Explicitly load libgomp.so.1 in gst-plugin-scanner

libgomp has a long lasting TLS bug
(https://bugzilla.redhat.com/show_bug.cgi?id=1722181). Preload the
library in gst-plugin-scanner to resolve the TLS memory issue while
launching gstreamer.

Change-Id: I8ebedaf320a6b4253e8804946e4ff79bbde48ad7
diff --git a/libs/gst/helpers/Makefile.am b/libs/gst/helpers/Makefile.am
index d72a652..a7c6d6c 100644
--- a/libs/gst/helpers/Makefile.am
+++ b/libs/gst/helpers/Makefile.am
@@ -3,7 +3,9 @@
 
 gst_plugin_scanner_SOURCES = gst-plugin-scanner.c
 gst_plugin_scanner_CFLAGS = $(GST_OBJ_CFLAGS)
-gst_plugin_scanner_LDADD = $(GST_OBJ_LIBS)
+gst_plugin_scanner_LDADD = \
+	$(GST_OBJ_LIBS) \
+	-lgomp
 
 if ENABLE_BASH_COMPLETION
 helpers_PROGRAMS += gst-completion-helper
diff --git a/libs/gst/helpers/gst-plugin-scanner.c b/libs/gst/helpers/gst-plugin-scanner.c
index cbefb29..ef735eb 100644
--- a/libs/gst/helpers/gst-plugin-scanner.c
+++ b/libs/gst/helpers/gst-plugin-scanner.c
@@ -30,6 +30,7 @@
 #include <gst/gst.h>
 
 #include <string.h>
+#include <dlfcn.h>
 
 int
 main (int argc, char *argv[])
@@ -37,6 +38,7 @@
   gboolean res;
   char **my_argv;
   int my_argc;
+  void *handle;
 
   /* We may or may not have an executable path */
   if (argc != 2 && argc != 3)
@@ -50,6 +52,8 @@
   my_argv[0] = argv[0];
   my_argv[1] = (char *) "--gst-disable-registry-update";
 
+  handle = dlopen("libgomp.so.1", RTLD_LAZY);
+
 #ifndef GST_DISABLE_REGISTRY
   _gst_disable_registry_cache = TRUE;
 #endif