Skip to content

Commit 60831d5

Browse files
OSS-Fuzz Teamcopybara-github
authored andcommitted
Add extra_rpath_entries parameter to patch_binary_rpath_and_interpreter
for prepending additional RPATH directories. PiperOrigin-RevId: 895966227
1 parent d765b6f commit 60831d5

File tree

1 file changed

+13
-2
lines changed
  • infra/base-images/base-builder/indexer

1 file changed

+13
-2
lines changed

infra/base-images/base-builder/indexer/utils.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,24 @@ def patch_binary_rpath_and_interpreter(
131131
binary_path: os.PathLike[str],
132132
lib_mount_path: pathlib.Path,
133133
ld_binary_path: pathlib.Path = LD_BINARY_PATH_X86_64,
134+
extra_rpath_entries: Sequence[pathlib.Path] = (),
134135
):
135-
"""Patches the binary rpath and interpreter."""
136+
"""Patches the binary rpath and interpreter.
137+
138+
Args:
139+
binary_path: Path to the ELF binary to patch.
140+
lib_mount_path: Primary library directory. Used as the main RPATH entry and
141+
to resolve the ELF interpreter (ld-linux).
142+
ld_binary_path: Basename / path of the dynamic linker.
143+
extra_rpath_entries: Additional directories prepended to the RPATH (searched
144+
before ``lib_mount_path``).
145+
"""
146+
rpath = ":".join(p.as_posix() for p in [*extra_rpath_entries, lib_mount_path])
136147
subprocess.run(
137148
[
138149
"patchelf",
139150
"--set-rpath",
140-
lib_mount_path.as_posix(),
151+
rpath,
141152
"--force-rpath",
142153
binary_path,
143154
],

0 commit comments

Comments
 (0)