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
//! Address-space helpers.
//!
//! All address fields exposed by nimrod (`vm_addr`, `address`, `call_addr`,
//! `payload_addr`, …) are **virtual addresses** in the input image's load
//! space, not file offsets. Consumers that need an RVA (for cross-tool
//! compatibility with disassemblers that work in image-relative space) can
//! use [`crate::NimBinary::shim_rva`] et al.
//!
//! Consumers that persist VAs into a signed-integer column should use
//! [`va_to_i64`] to guard against the rare adversarial case of a VA above
//! `i64::MAX`.
//!
//! Nimrod itself does not bound VAs below `i64::MAX`; pathological PE
//! image bases or Mach-O segment vmaddrs can in principle place values in
//! the upper half of the `u64` range.
/// Returns the VA as an `i64`, or `None` if it would overflow.
///
/// Use this when persisting nimrod address fields into a signed
/// 64-bit column. Wrapping casts (`va as i64`) silently produce
/// negative values for VAs above `i64::MAX`, which is rare but
/// possible on adversarial input.