Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/auditwheel/elfutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,19 @@ def elf_read_rpaths(fn: Path) -> dict[str, list[str]]:

for t in section.iter_tags():
if t.entry.d_tag == "DT_RPATH":
result["rpaths"] = parse_ld_paths(t.rpath, root="/", path=str(fn))
result["rpaths"] = parse_ld_paths(
t.rpath,
root="/",
path=str(fn),
keep_non_exist=True,
)
elif t.entry.d_tag == "DT_RUNPATH":
result["runpaths"] = parse_ld_paths(t.runpath, root="/", path=str(fn))
result["runpaths"] = parse_ld_paths(
t.runpath,
root="/",
path=str(fn),
keep_non_exist=True,
)

return result

Expand Down
11 changes: 9 additions & 2 deletions src/auditwheel/lddtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ def dedupe(items: list[str]) -> list[str]:
return [seen.setdefault(x, x) for x in items if x not in seen]


def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> list[str]:
def parse_ld_paths(
str_ldpaths: str,
path: str,
root: str = "",
keep_non_exist: bool = False, # noqa: FBT001, FBT002
) -> list[str]:
"""Parse the colon-delimited list of paths and apply ldso rules to each

Note the special handling as dictated by the ldso:
Expand All @@ -229,6 +234,8 @@ def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> list[str]:
The path to prepend to all paths found
path
The object actively being parsed (used for $ORIGIN)
keep_non_exist
Do not eliminate non-exist rpath from result

Returns
-------
Expand All @@ -245,7 +252,7 @@ def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> list[str]:
else:
ldpath_ = root + ldpath
ldpaths.append(normpath(ldpath_))
return [p for p in dedupe(ldpaths) if os.path.isdir(p)]
return [p for p in dedupe(ldpaths) if keep_non_exist or os.path.isdir(p)]


@functools.lru_cache
Expand Down