INNER CODE UNIT · Python

elf_metadata

mumu-lhl/Ciyue · tools/bundle_linux_dependencies.py:58

def elf_metadata(path: Path) -> ElfMetadata | None:
    try:
        with path.open("rb") as stream:
            if stream.read(4) != b"\x7fELF":
                return None
    except OSError as error:
        raise RuntimeError(f"Cannot read {path}: {error}") from error

    result = subprocess.run(
        ["readelf", "--dynamic", str(path)],
        check=False,
        capture_output=True,
        text=True,
        env={**os.environ, "LC_ALL": "C"},
    )
    if result.returncode != 0:
        raise RuntimeError(f"readelf failed for {path}:\n{result.stderr.strip()}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…