Objective-C

This module allows to inspect Objective-C metadata from a Mach-O binary.

If a Mach-O binary embeds Objective-C metadata, they can be accessed through lief.MachO.Binary.objc_metadata / LIEF::MachO::Binary::objc_metadata():

macho: lief.MachO.Binary = ...
metadata: lief.objc.Metadata = macho.objc_metadata
if metadata is not None:
    print("Objective-C metadata found")

Then at this point, one can use the API exposed by the class lief.objc.Metadata / LIEF::objc::Metadata to inspect the Objective-C Metadata.

In particular, the function: lief.objc.Metadata.to_decl()/ LIEF::objc::Metadata::to_decl() can be used to generate a header-like output of all the Objective-C metadata found in the binary.

macho: lief.MachO.Binary = lief.parse("some_macho")
metadata: lief.objc.Metadata = macho.objc_metadata
for clazz in metadata.classes:
    print(f"name={clazz.name}")
    for meth in clazz.methods:
        print(f"  method.name={meth.name}")
print(metadata.to_decl())

This Objective-C support is based on iCDump which is detailed here:


You can find the documentation of the API for the different languages here:

Python API

C++ API

Rust API: https://lief-rs.s3.fr-par.scw.cloud/doc/latest/lief/index.html