MCPcopy Create free account
hub / github.com/F-Stack/f-stack / get_needed_libs

Function get_needed_libs

dpdk/usertools/dpdk-pmdinfo.py:289–305  ·  view source on GitHub ↗

Extract the dynamic library dependencies from an ELF executable.

(path: Path)

Source from the content-addressed store, hash-verified

287
288
289def get_needed_libs(path: Path) -> Iterator[Path]:
290 """
291 Extract the dynamic library dependencies from an ELF executable.
292 """
293 with subprocess.Popen(
294 ["ldd", str(path)], stdout=subprocess.PIPE, stderr=subprocess.PIPE
295 ) as proc:
296 out, err = proc.communicate()
297 if proc.returncode != 0:
298 err = err.decode("utf-8").splitlines()[-1].strip()
299 raise Exception(f"cannot read ELF file: {err}")
300 for match in LDD_LIB_RE.finditer(out.decode("utf-8")):
301 libname, libpath = match.groups()
302 if libname.startswith("librte_"):
303 libpath = Path(libpath)
304 if libpath.is_file():
305 yield libpath.resolve()
306
307
308# ----------------------------------------------------------------------------

Callers 1

parse_pmdinfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected