MCPcopy Create free account
hub / github.com/lief-project/LIEF / main

Function main

api/python/examples/dyld_shared_cache_reader.py:14–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12from typing import Optional
13
14def main() -> int:
15 parser = argparse.ArgumentParser()
16 parser.add_argument("target", type=Path,
17 help='Target dyld shared file (file or dir)')
18 args = parser.parse_args()
19
20 target: Path = args.target
21 if not target.exists():
22 print(f"'{target}' does not exist")
23 return 1
24
25 dyld_cache = lief.dsc.load(target)
26 if dyld_cache is None:
27 print(f"Can't parse '{target}'")
28
29 for lib in dyld_cache.libraries:
30 print(f"0x{lib.address:016x} {lib.path}")
31
32 for idx, info in enumerate(dyld_cache.mapping_info):
33 print(f"mapping_info[{idx:02d}]: [{info.address:016x}, {info.end_address:016x}] -> 0x{info.file_offset:016x}")
34
35 for idx, subcache in enumerate(dyld_cache.subcaches):
36 uuid_str = ':'.join(map(lambda e: f"{e:02x}", subcache.uuid))
37 print(f"cache[{idx:02d}]: {uuid_str} {subcache.suffix}")
38
39if __name__ == "__main__":
40 raise SystemExit(main())

Callers 1

Calls 3

mapClass · 0.85
loadMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected