Skip to content

Commit

Permalink
fix needed field
Browse files Browse the repository at this point in the history
  • Loading branch information
oraluben committed Jan 6, 2025
1 parent 9aca4a3 commit 896c26c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/auditwheel/lddtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,18 +386,22 @@ def lddtree(
libs: list[str] = []
rpaths: list[str] = []
runpaths: list[str] = []
_excluded: set[str] = set()
for segment in elf.iter_segments():
if segment.header.p_type != "PT_DYNAMIC":
continue

for t in segment.iter_tags():
if t.needed in _excluded:
continue
if t.entry.d_tag == "DT_RPATH":
rpaths = parse_ld_paths(t.rpath, path=path, root=root)
elif t.entry.d_tag == "DT_RUNPATH":
runpaths = parse_ld_paths(t.runpath, path=path, root=root)
elif t.entry.d_tag == "DT_NEEDED":
if any(fnmatch(t.needed, e) for e in exclude):
log.info("Excluding %s", t.needed)
_excluded.add(t.needed)
else:
libs.append(t.needed)
if runpaths:
Expand All @@ -416,12 +420,11 @@ def lddtree(
log.debug(" ldpaths[runpath] = %s", runpaths)
ret["rpath"] = rpaths
ret["runpath"] = runpaths
ret["needed"] = libs

# Search for the libs this ELF uses.
all_ldpaths: list[str] | None = None
for lib in libs:
if lib in _all_libs:
if lib in _all_libs or lib in _excluded:
continue
if all_ldpaths is None:
all_ldpaths = (
Expand All @@ -436,6 +439,7 @@ def lddtree(
realpath, fullpath = find_lib(elf, lib, all_ldpaths, root)
if any(fnmatch(realpath, e) for e in exclude):
log.info("Excluding %s", realpath)
_excluded.add(lib)
continue
_all_libs[lib] = {
"realpath": realpath,
Expand All @@ -456,4 +460,6 @@ def lddtree(

del elf

ret["needed"] = [lib for lib in libs if lib not in _excluded]

return ret

0 comments on commit 896c26c

Please sign in to comment.