diff Lib/ctypes/util.py @ 43371:fdff48f87f35 legacy-trunk

ctypes.util.find_library uses dump(1) instead of objdump(1) on Solaris. Fixes issue #1777530; will backport to release25-maint.
author Thomas Heller <theller@ctypes.org>
date Fri, 14 Sep 2007 19:40:35 +0000
parents cf8af6b7598b
children 6af64512294a
line wrap: on
line diff
--- a/Lib/ctypes/util.py	Fri Sep 14 18:58:34 2007 +0000
+++ b/Lib/ctypes/util.py	Fri Sep 14 19:40:35 2007 +0000
@@ -66,15 +66,27 @@
             return None
         return res.group(0)
 
-    def _get_soname(f):
-        # assuming GNU binutils / ELF
-        if not f:
-            return None
-        cmd = "objdump -p -j .dynamic 2>/dev/null " + f
-        res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read())
-        if not res:
-            return None
-        return res.group(1)
+
+    if sys.platform == "sunos5":
+        # use /usr/ccs/bin/dump on solaris
+        def _get_soname(f):
+            if not f:
+                return None
+            cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f
+            res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', os.popen(cmd).read())
+            if not res:
+                return None
+            return res.group(1)
+    else:
+        def _get_soname(f):
+            # assuming GNU binutils / ELF
+            if not f:
+                return None
+            cmd = "objdump -p -j .dynamic 2>/dev/null " + f
+            res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read())
+            if not res:
+                return None
+            return res.group(1)
 
     if (sys.platform.startswith("freebsd")
         or sys.platform.startswith("openbsd")