Skip to content

Commit 12dbbed

Browse files
OSS-Fuzz Teamcopybara-github
authored andcommitted
Properly handle the interpreter copying
PiperOrigin-RevId: 816588120
1 parent 0b4351e commit 12dbbed

File tree

1 file changed

+10
-5
lines changed
  • infra/base-images/base-builder/indexer

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import subprocess
2323
from typing import Final, Sequence
2424

25-
_LD_PATH = "/usr/bin/ld.so.2"
26-
_LD_PATH: Final[pathlib.Path] = pathlib.Path("/lib64/ld-linux-x86-64.so.2")
25+
LD_BINARY_NAME: Final[str] = "ld-linux-x86-64.so.2"
26+
_LD_BINARY_PATH: Final[pathlib.Path] = pathlib.Path("/lib64") / LD_BINARY_NAME
2727

2828

2929
@dataclasses.dataclass(frozen=True)
@@ -45,14 +45,19 @@ def _parse_ld_trace_output(output: str) -> Sequence[SharedLibrary]:
4545
# lib foo.so => /tmp/sharedlib/lib foo.so (0x00007f76b9367000)
4646
# libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f76b9157000)
4747
# /lib64/ld-linux-x86-64.so.2 (0x00007f76b9379000)
48+
# The last line can also be:
49+
# /grte/lib64/lib64/ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
50+
# (0x00007f76b9379000)
4851
#
4952
# The lines that do not have a => should be skipped.
50-
# The dynamic linker should always be copied.
53+
# The dynamic linker should always be copied AND have its executable bit set.
5154
# The lines that have a => could contain a space, but we copy whatever is on
5255
# the right side of the =>, removing the load address.
53-
shared_libraries = [SharedLibrary(name="ld.so", path=_LD_PATH)]
56+
shared_libraries = [SharedLibrary(name=LD_BINARY_NAME, path=_LD_BINARY_PATH)]
5457
for lib_name, lib_path in re.findall(r"(\S+) => .*?(\S+) \(", output):
5558
lib_path = pathlib.Path(lib_path)
59+
if lib_path == _LD_BINARY_PATH:
60+
continue
5661
shared_libraries.append(SharedLibrary(name=lib_name, path=lib_path))
5762

5863
return shared_libraries
@@ -67,7 +72,7 @@ def get_shared_libraries(
6772
env["LD_BIND_NOW"] = "1"
6873

6974
result = subprocess.run(
70-
[_LD_PATH, binary_path],
75+
[_LD_BINARY_PATH, binary_path],
7176
capture_output=True,
7277
env=env,
7378
check=True,

0 commit comments

Comments
 (0)