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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//! Pointer authentication and chained-fixup canonicalisation.
//!
//! On arm64e binaries, runtime pointers in `__objc_*list` and
//! `__swift5_*` indirection tables can carry a Pointer Authentication
//! Code (PAC) signature in bits `48..63` of each 64-bit slot. The
//! runtime canonicalises pointers by masking to the user
//! virtual-address window
//! (`0x0000_0000_0000_0000..=0x0000_FFFF_FFFF_FFFF`).
//!
//! When `LC_DYLD_CHAINED_FIXUPS` is present, raw pointers are encoded
//! as chain entries (rebase / bind / authenticated rebase /
//! authenticated bind). The per-format decoders in [`crate::fixup`]
//! extract the canonical target field directly from the slot bits
//! and surface PAC metadata as a [`PtrAuth`] value.
//!
//! `darwinscope` is read-only - it never verifies a signature; it
//! only strips the envelope and exposes `(diversity, addr_div, key)`
//! verbatim for downstream tools that *do* care to match against
//! expected discriminator constants.
//!
//! See `RESEARCH.md` §"Pointer authentication (arm64e)" (line 886)
//! and §"Chained-fixup auth pointer formats" (line 900) for the
//! underlying format references.
/// Mask covering the user virtual-address window (low 48 bits).
///
/// A raw 64-bit pointer carrying PAC envelope bits in `48..63` masks
/// down to the canonical user-VA via this mask. The chained-fixup
/// per-format decoders in [`crate::fixup`] extract structured fields
/// directly from the slot bits; this mask is for the rarer case
/// where a caller already holds a PAC-signed pointer and only needs
/// the canonical address back.
pub const VA_MASK: u64 = 0x0000_FFFF_FFFF_FFFF;
/// Strip PAC + chain-encoding bits, leaving the canonical 48-bit
/// user VA.
///
/// Always succeeds - for slots that aren't pointers, categorisation
/// is the caller's responsibility. This function does **not**
/// validate the signature; `darwinscope` is a parser, not a
/// validator. See module docs for the encoding it strips.
/// PAC metadata extracted from a chained-fixup auth slot
/// (`auth_rebase` / `auth_bind` / `auth_bind24` variants).
///
/// Cite: `dyld/include/mach-o/fixup-chains.h:137-194` and
/// `RESEARCH.md` §"Chained-fixup auth pointer formats" (line 900).
/// One of the four ARMv8.3 pointer-authentication keys.
///
/// `IA` is the default for signed code pointers; `DA` is typical
/// for signed data pointers. The encoding mapping is fixed by the
/// arm64e ABI - see `dyld/include/mach-o/fixup-chains.h:142`.