bf43f5
diff -ru GraphicsMagick-1.3.38.orig/magick/module.c GraphicsMagick-1.3.38/magick/module.c
bf43f5
--- GraphicsMagick-1.3.38.orig/magick/module.c	2022-03-26 18:45:36.000000000 +0100
bf43f5
+++ GraphicsMagick-1.3.38/magick/module.c	2022-11-05 20:08:54.097212410 +0100
bf43f5
@@ -47,12 +47,9 @@
bf43f5
 #include "magick/map.h"
bf43f5
 #include "magick/module.h"
bf43f5
 #include "magick/utility.h"
bf43f5
-#if defined(HasLTDL)
bf43f5
-#  include "ltdl.h"
bf43f5
-   typedef lt_dlhandle ModuleHandle;
bf43f5
-#else
bf43f5
-   typedef void *ModuleHandle;
bf43f5
-#endif
bf43f5
+
bf43f5
+#include <dlfcn.h>
bf43f5
+typedef void *ModuleHandle;
bf43f5
 
bf43f5
 /*
bf43f5
   Define declarations.
bf43f5
@@ -60,7 +57,7 @@
bf43f5
 #define MAX_MODULES 511 /* Maximum number of modules supported by build. */
bf43f5
 #define ModuleFilename  "modules.mgk"
bf43f5
 #if defined(HasLTDL)
bf43f5
-#  define ModuleGlobExpression "*.la"
bf43f5
+#  define ModuleGlobExpression "*.so"
bf43f5
 #else
bf43f5
 #  if defined(_DEBUG)
bf43f5
 #    define ModuleGlobExpression "IM_MOD_DB_*.dll"
bf43f5
@@ -297,9 +294,6 @@
bf43f5
   */
bf43f5
   if (ltdl_initialized)
bf43f5
     {
bf43f5
-#if !defined(HasJP2)
bf43f5
-      (void) lt_dlexit();
bf43f5
-#endif
bf43f5
       ltdl_initialized=False;
bf43f5
     }
bf43f5
 }
bf43f5
@@ -375,13 +369,13 @@
bf43f5
       return(MagickFail);
bf43f5
 
bf43f5
     /* Open the module */
bf43f5
-    handle=lt_dlopen(module_path);
bf43f5
+    handle=dlopen(module_path, RTLD_NOW);
bf43f5
     if (handle == (ModuleHandle) NULL)
bf43f5
       {
bf43f5
         char
bf43f5
           message[MaxTextExtent];
bf43f5
 
bf43f5
-        FormatString(message,"\"%.256s: %.256s\"",module_path,lt_dlerror());
bf43f5
+        FormatString(message,"\"%.256s: %.256s\"",module_path,dlerror());
bf43f5
         ThrowException(&(*image)->exception,ModuleError,UnableToLoadModule,
bf43f5
           message);
bf43f5
         return(status);
bf43f5
@@ -401,7 +395,7 @@
bf43f5
     FormatString(method_name,"%.64sImage",tag);
bf43f5
 #endif
bf43f5
     method=(unsigned int (*)(Image **,const int,char **))
bf43f5
-      lt_dlsym(handle,method_name);
bf43f5
+      dlsym(handle,method_name);
bf43f5
 
bf43f5
 
bf43f5
     /* Execute module method */
bf43f5
@@ -429,7 +423,7 @@
bf43f5
 
bf43f5
   }
bf43f5
   /* Close the module */
bf43f5
-  (void) lt_dlclose(handle);
bf43f5
+  (void) dlclose(handle);
bf43f5
   return(status);
bf43f5
 }
bf43f5
 
bf43f5
@@ -822,9 +816,11 @@
bf43f5
       */
bf43f5
       if (!ltdl_initialized)
bf43f5
         {
bf43f5
+#if 0
bf43f5
           if (lt_dlinit() != 0)
bf43f5
             MagickFatalError(ModuleFatalError,
bf43f5
-              UnableToInitializeModuleLoader,lt_dlerror());
bf43f5
+              UnableToInitializeModuleLoader,dlerror());
bf43f5
+#endif
bf43f5
           ltdl_initialized=True;
bf43f5
         }
bf43f5
       (void) ReadModuleConfigureFile(ModuleFilename,0,&exception);
bf43f5
@@ -1359,8 +1355,8 @@
bf43f5
     CoderInfo
bf43f5
       *coder_info;
bf43f5
 
bf43f5
-    ModuleHandle
bf43f5
-      handle;
bf43f5
+    void
bf43f5
+      *handle;
bf43f5
 
bf43f5
     register ModuleInfo
bf43f5
       *p;
bf43f5
@@ -1419,10 +1415,10 @@
bf43f5
     (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
bf43f5
       "Opening module at path \"%s\" ...", path);
bf43f5
 
bf43f5
-    handle=lt_dlopen(path);
bf43f5
+    handle=dlopen(path, RTLD_NOW);
bf43f5
     if (handle == (ModuleHandle) NULL)
bf43f5
       {
bf43f5
-        FormatString(message,"\"%.1024s: %.1024s\"",path,lt_dlerror());
bf43f5
+        FormatString(message,"\"%.1024s: %.1024s\"",path,dlerror());
bf43f5
         ThrowException(exception,ModuleError,UnableToLoadModule,message);
bf43f5
         return(MagickFail);
bf43f5
       }
bf43f5
@@ -1432,7 +1428,7 @@
bf43f5
     coder_info=SetCoderInfo(module_name);
bf43f5
     if (coder_info == (CoderInfo*) NULL)
bf43f5
       {
bf43f5
-        (void) lt_dlclose(handle);
bf43f5
+        (void) dlclose(handle);
bf43f5
         return(MagickFail);
bf43f5
       }
bf43f5
     coder_info->handle=handle;
bf43f5
@@ -1443,10 +1439,10 @@
bf43f5
       Locate and record RegisterFORMATImage function
bf43f5
     */
bf43f5
     TagToFunctionName(module_name,"Register%sImage",name);
bf43f5
-    coder_info->register_function=(void (*)(void)) lt_dlsym(handle,name);
bf43f5
+    coder_info->register_function=(void (*)(void)) dlsym(handle,name);
bf43f5
     if (coder_info->register_function == (void (*)(void)) NULL)
bf43f5
       {
bf43f5
-        FormatString(message,"\"%.1024s: %.1024s\"",module_name,lt_dlerror());
bf43f5
+        FormatString(message,"\"%.1024s: %.1024s\"",module_name,dlerror());
bf43f5
         ThrowException(exception,ModuleError,UnableToRegisterImageFormat,
bf43f5
           message);
bf43f5
         return(MagickFail);
bf43f5
@@ -1460,10 +1456,10 @@
bf43f5
       Locate and record UnregisterFORMATImage function
bf43f5
     */
bf43f5
     TagToFunctionName(module_name,"Unregister%sImage",name);
bf43f5
-    coder_info->unregister_function=(void (*)(void)) lt_dlsym(handle,name);
bf43f5
+    coder_info->unregister_function=(void (*)(void)) dlsym(handle,name);
bf43f5
     if (coder_info->unregister_function == (void (*)(void)) NULL)
bf43f5
       {
bf43f5
-        FormatString(message,"\"%.1024s: %.1024s\"",module_name,lt_dlerror());
bf43f5
+        FormatString(message,"\"%.1024s: %.1024s\"",module_name,dlerror());
bf43f5
         ThrowException(exception,ModuleError,UnableToRegisterImageFormat,
bf43f5
           message);
bf43f5
         return(MagickFail);
bf43f5
@@ -1983,7 +1979,7 @@
bf43f5
   assert(tag != (char *) NULL);
bf43f5
   assert(module_name != (char *) NULL);
bf43f5
 #if defined(HasLTDL)
bf43f5
-  (void) FormatString(module_name,"%.1024s.la",tag);
bf43f5
+  (void) FormatString(module_name,"%.1024s.so",tag);
bf43f5
   (void) LocaleLower(module_name);
bf43f5
 #else
bf43f5
 #if defined(MSWINDOWS)
bf43f5
@@ -2030,7 +2026,7 @@
bf43f5
   assert(tag != (char *) NULL);
bf43f5
   assert(module_name != (char *) NULL);
bf43f5
 #if defined(HasLTDL)
bf43f5
-  (void) FormatString(module_name,"%.1024s.la",tag);
bf43f5
+  (void) FormatString(module_name,"%.1024s.so",tag);
bf43f5
   (void) LocaleLower(module_name);
bf43f5
 #else
bf43f5
   (void) FormatString(module_name,"%.1024s.dll",tag);
bf43f5
@@ -2142,10 +2138,10 @@
bf43f5
   */
bf43f5
   if ( strcmp("JP2",coder_info->tag) != 0 )
bf43f5
     {
bf43f5
-      if (lt_dlclose((ModuleHandle) coder_info->handle))
bf43f5
+      if (dlclose((ModuleHandle) coder_info->handle))
bf43f5
         {
bf43f5
           FormatString(message,"\"%.1024s: %.1024s\"",coder_info->tag,
bf43f5
-                       lt_dlerror());
bf43f5
+                       dlerror());
bf43f5
           ThrowException(exception,ModuleError,FailedToCloseModule,message);
bf43f5
           status=False;
bf43f5
         }