-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
replacements.go
66 lines (53 loc) · 1.84 KB
/
replacements.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package swift
// __TEXT.__swift5_replace
// This section contains dynamic replacement information.
// This is essentially the Swift equivalent of Objective-C method swizzling.
type AutomaticDynamicReplacements struct {
Flags uint32
NumScopes uint32
AutomaticDynamicReplacementEntry
}
type AutomaticDynamicReplacementEntry struct {
ReplacementScope int32 // DynamicReplacementScope
Flags uint32
}
type DynamicReplacementKey struct {
Root int32
Flags uint32
}
func (d DynamicReplacementKey) ExtraDiscriminator() uint16 {
return uint16(d.Flags & 0x0000FFFF)
}
func (d DynamicReplacementKey) IsAsync() bool {
return ((d.Flags >> 16) & 0x1) != 0
}
type DynamicReplacementScope struct {
Flags uint32
NumReplacements uint32 // hard coded to 1
DynamicReplacementDescriptor
}
const EnableChainingMask = 0x1
type DynamicReplacementDescriptor struct {
ReplacedFunctionKey int32 // DynamicReplacementKey
ReplacementFunction int32 // UNION w/ ReplacementAsyncFunction - TargetCompactFunctionPointer|TargetRelativeDirectPointer
ChainEntry int32 // DynamicReplacementChainEntry
Flags uint32
}
func (d DynamicReplacementDescriptor) ShouldChain() bool {
return (d.Flags & EnableChainingMask) != 0
}
type DynamicReplacementChainEntry struct {
ImplementationFunction uint64 // void *
Next uint64 // DynamicReplacementChainEntry *
}
// __TEXT.__swift5_replac2
// This section contains dynamic replacement information for opaque types.
type DynamicReplacementSomeDescriptor struct {
OriginalOpaqueTypeDesc int32 // OpaqueTypeDescriptor -> TargetContextDescriptor
ReplacementOpaqueTypeDesc int32 // OpaqueTypeDescriptor -> TargetContextDescriptor
}
type AutomaticDynamicReplacementsSome struct {
Flags uint32
NumReplacements uint32
Replacements []DynamicReplacementSomeDescriptor
}