MCPcopy Create free account
hub / github.com/OpenIPC/firmware / parse_binary

Function parse_binary

general/scripts/audit-vendor-abi.py:185–215  ·  view source on GitHub ↗

Parse a single .so file, extract imports, NEEDED, versions.

(path: str, pkg_dir: str)

Source from the content-addressed store, hash-verified

183 "__register_frame_info_bases", "__deregister_frame_info_bases",
184 "__register_frame_info_header_bases",
185 # libstdc++
186 "__dynamic_cast",
187}
188
189
190def is_toolchain_runtime_symbol(sym: str) -> bool:
191 """True if the compiler runtime (libgcc/libstdc++) provides this symbol.
192
193 Note __aeabi_d2iz is deliberately NOT special-cased away here: older
194 Buildroot ARM toolchains have been seen not to emit it, which is why
195 uclibc-compat carries an implementation. It is still a libgcc symbol,
196 so it is bucketed with the rest and simply not counted as a musl gap.
197 """
198 if sym in TOOLCHAIN_RUNTIME_SYMBOLS:
199 return True
200 return any(sym.startswith(p) for p in TOOLCHAIN_RUNTIME_PREFIXES)
201
202
203# ---------------------------------------------------------------------------
204# ELF helpers
205# ---------------------------------------------------------------------------
206
207def run_readelf(args: list[str], path: str) -> str:
208 try:
209 r = subprocess.run(
210 ["readelf", "-W"] + args + [path],
211 capture_output=True, text=True, timeout=10,
212 )
213 return r.stdout
214 except (subprocess.TimeoutExpired, FileNotFoundError):
215 return ""
216
217
218def is_elf(path: str) -> bool:

Callers 1

audit_packageFunction · 0.85

Calls 3

is_elfFunction · 0.85
run_readelfFunction · 0.85
BinaryInfoClass · 0.85

Tested by

no test coverage detected