or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

android-formats.mdassembly-engine.mdcore-operations.mddebug-info.mdelf-format.mdextended-features.mdindex.mdmacho-format.mdpe-format.md

extended-features.mddocs/

0

# Extended Features

1

2

Advanced platform-specific features providing deep integration with Apple ecosystem technologies including Objective-C runtime metadata and macOS/iOS shared cache analysis.

3

4

## Capabilities

5

6

### Objective-C Metadata

7

8

Comprehensive Objective-C runtime metadata extraction for analyzing classes, methods, properties, and protocols in macOS and iOS binaries.

9

10

```python { .api }

11

# Access through lief.objc module

12

import lief.objc as ObjC

13

14

class Metadata:

15

classes: Iterator[Class]

16

protocols: Iterator[Protocol]

17

18

def get_class(self, name: str) -> Optional[Class]

19

def get_protocol(self, name: str) -> Optional[Protocol]

20

21

class Class:

22

name: str

23

super_class: Optional[Class]

24

methods: Iterator[Method]

25

ivars: Iterator[IVar]

26

properties: Iterator[Property]

27

protocols: Iterator[Protocol]

28

29

class Method:

30

name: str

31

mangled_type: str

32

address: int

33

is_instance: bool

34

35

class Property:

36

name: str

37

attribute: str

38

39

class Protocol:

40

name: str

41

methods: Iterator[Method]

42

properties: Iterator[Property]

43

44

class IVar:

45

name: str

46

type: str

47

offset: int

48

```

49

50

Usage example:

51

```python

52

import lief

53

import lief.objc as ObjC

54

55

# Parse Mach-O binary with Objective-C metadata

56

binary = lief.parse("/System/Library/Frameworks/Foundation.framework/Foundation")

57

58

if hasattr(binary, 'objc_metadata') and binary.objc_metadata:

59

objc = binary.objc_metadata

60

61

# List all Objective-C classes

62

for cls in objc.classes:

63

print(f"Class: {cls.name}")

64

if cls.super_class:

65

print(f" Inherits from: {cls.super_class.name}")

66

67

# List methods

68

for method in cls.methods:

69

print(f" Method: {method.name} ({'instance' if method.is_instance else 'class'})")

70

```

71

72

### Dyld Shared Cache

73

74

Support for analyzing macOS and iOS shared caches that contain multiple dynamic libraries optimized for system performance.

75

76

```python { .api }

77

# Access through lief.dsc module

78

import lief.dsc as DSC

79

80

class DyldSharedCache:

81

architecture: str

82

platform: PLATFORMS

83

version: str

84

85

def dylibs(self) -> Iterator[Dylib]

86

def mapping_info(self) -> Iterator[MappingInfo]

87

def find_lib_from_name(self, name: str) -> Optional[Dylib]

88

def find_lib_from_path(self, path: str) -> Optional[Dylib]

89

def has_subcaches(self) -> bool

90

def subcaches(self) -> Iterator[SubCache]

91

92

class Dylib:

93

path: str

94

address: int

95

modtime: int

96

inode: int

97

98

def get_binary(self) -> Optional[MachO.Binary]

99

100

class MappingInfo:

101

address: int

102

size: int

103

file_offset: int

104

max_protection: int

105

init_protection: int

106

107

class SubCache:

108

suffix: str

109

uuid: bytes

110

cache_type: CACHE_TYPE

111

```

112

113

Usage example:

114

```python

115

import lief.dsc as DSC

116

117

# Parse shared cache

118

cache = DSC.load("/System/Library/dyld/dyld_shared_cache_arm64e")

119

120

if cache:

121

print(f"Architecture: {cache.architecture}")

122

print(f"Platform: {cache.platform}")

123

124

# List all dylibs in cache

125

for dylib in cache.dylibs():

126

print(f"Dylib: {dylib.path}")

127

128

# Extract individual binary

129

binary = dylib.get_binary()

130

if binary:

131

print(f" Entry point: 0x{binary.entrypoint:x}")

132

133

# Find specific library

134

foundation = cache.find_lib_from_name("Foundation")

135

if foundation:

136

print(f"Found Foundation at: 0x{foundation.address:x}")

137

```

138

139

## Types

140

141

```python { .api }

142

class PLATFORMS(enum.Enum):

143

UNKNOWN = 0

144

MACOS = 1

145

IOS = 2

146

TVOS = 3

147

WATCHOS = 4

148

BRIDGEOS = 5

149

MACCATALYST = 6

150

IOSSIMULATOR = 7

151

TVOSSIMULATOR = 8

152

WATCHOSSIMULATOR = 9

153

154

class CACHE_TYPE(enum.Enum):

155

REGULAR = 0

156

STUB_ISLAND = 1

157

```