INNER CODE UNIT · Python
inspect_binary
alper-han/CrossMacro · scripts/ci/verify-glibc-baseline.py:65
def inspect_binary(path: Path, readelf: str = "readelf") -> list[tuple[int, ...]]:
if not path.is_file():
raise RuntimeError(f"binary does not exist: {path}")
result = subprocess.run(
[readelf, "--version-info", str(path)],
check=False,
capture_output=True,
text=True,
)
if result.returncode != 0:
detail = (result.stderr or result.stdout).strip()
raise RuntimeError(f"readelf failed for {path}: {detail}")
return extract_glibc_versions(result.stdout + result.stderr)
def format_version(version: tuple[int, ...]) -> str:
return ".".join(str(part) for part in version)