Skip to content

Commit

Permalink
depend: do not resolve soname in library path resolution
Browse files Browse the repository at this point in the history
In `_resolve_library_path_unix` helper, remove the part at the
end where we read the soname of the resolved library and replace
the name in returned path with the soname.

In most cases, this was effectively no-op, because we use this
function to resolve dependencies of binaries that we analyze,
and those refer to those dependencies via their sonames.

However, in the unlikely case that we are trying to resolve a
library with soname that differs from its true (file)name, we
would need to collect it under that true (file)name; first, because
whoever was referring to it expects to find it under the true
(file)name, and second, becase in such case, the file with
corresponding soname might not actually exist at all.
  • Loading branch information
rokm committed Apr 22, 2024
1 parent 1e75fd3 commit ba3ccc6
Showing 1 changed file with 1 addition and 28 deletions.
29 changes: 1 addition & 28 deletions PyInstaller/depend/bindepend.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,18 +693,7 @@ def _resolve_library_path_unix(name):
paths.append('/usr/local/lib')
lib = lib_search_func(name, paths)

# Give up :(
if lib is None:
return None

# Resolve the file name into the soname
if compat.is_freebsd or compat.is_aix or compat.is_openbsd:
# On FreeBSD objdump does not show SONAME, and on AIX objdump does not exist, so we just return the lib we
# have found.
return lib
else:
dir = os.path.dirname(lib)
return os.path.join(dir, _get_so_name(lib))
return lib


def _which_library(name, dirs):
Expand Down Expand Up @@ -734,22 +723,6 @@ def _library_matcher(name):
return re.compile(name + r"[0-9]*\.").match


def _get_so_name(filename):
"""
Return the soname of a library.
Soname is useful when there are multiple symplinks to one library.
"""
# TODO verify that objdump works on other unixes and not Linux only.
cmd = ["objdump", "-p", filename]
pattern = r'\s+SONAME\s+([^\s]+)'
if compat.is_solar:
cmd = ["elfdump", "-d", filename]
pattern = r'\s+SONAME\s+[^\s]+\s+([^\s]+)'
m = re.search(pattern, compat.exec_command(*cmd))
return m.group(1)


#- Python shared library search


Expand Down

0 comments on commit ba3ccc6

Please sign in to comment.