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
//! Zero-copy PE/COFF reading.
//!
//! **Workstream W14.** The input side of the PE/COFF backend (M7), the
//! counterpart of [`elf::read`](crate::elf::read):
//!
//! - [`CoffFile`]: parses any binary input, dispatching on its leading
//! bytes to one of the readers below.
//! - [`CoffObject`]: relocatable objects, regular and `/bigobj`
//! ([`FileHeader`]): sections ([`SectionHeader`], long names through
//! `/<n>` and `//<base64>`, alignment, COMDAT flags), symbols
//! ([`SymbolTable`], [`Symbol`], with [`AuxSectionDefinition`],
//! [`AuxWeakExternal`], [`AuxFunctionDefinition`] and file name aux
//! records), relocations ([`Relocations`]), `@feat.00` ([`Feat00`]),
//! `.llvm_addrsig` ([`AddrsigIter`]) and resource sections.
//! - [`directives`](mod@directives): `.drectve` tokenization with the
//! Windows quoting rules and parsing into [`Directive`]s.
//! - [`import`](mod@import): short import objects ([`ShortImport`]) and GNU
//! `dlltool` long import members ([`classify_long_import`],
//! [`LongImportDlls`]).
//! - [`PeImage`]: DLLs and executables — headers, data directories, RVA
//! translation and the export directory ([`ExportDirectory`]).
//! - [`def`](mod@def): module-definition files ([`ModuleDefinition`]).
//! - [`consts`]: PE/COFF constants, and machine, storage class and
//! relocation type names.
//!
//! # Safety and robustness
//!
//! Input is untrusted. Records are decoded with `from_le_bytes` from byte
//! slices; there is no `unsafe`. Every offset and size is bounds-checked
//! with checked arithmetic (this module denies
//! `clippy::arithmetic_side_effects`), and problems are reported as
//! [`Error::Malformed`](crate::Error::Malformed) naming the file and
//! offset.
//!
//! # Performance model
//!
//! Parsing an object reads its fixed headers and checks the table bounds;
//! it allocates nothing. Sections, symbols and relocations are decoded one
//! record at a time from the mapped bytes, and names are returned as
//! `&[u8]` slices into the file. Regular and `/bigobj` objects share one
//! code path with a run-time record size: the difference is two fields, not
//! worth monomorphizing. All types are `Send + Sync`, so files are parsed in
//! parallel.
//!
//! # Limitations
//!
//! - Legacy COFF line numbers are not decoded.
//! - ARM64EC and ARM64X short imports expose the header fields, but not the
//! extra `__imp_aux_` and mangled thunk symbols they define.
//! - Anonymous objects other than `/bigobj` (MSVC `/GL` LTCG IR) are
//! rejected.
//! - [`PeImage`] ignores the loader's rounding of `PointerToRawData` to
//! 512 bytes, which only matters for hand-crafted images.
pub use ;
pub use ;
pub use ;
pub use ExportSpec;
pub use CoffFile;
pub use FileHeader;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Source;
pub use StringTable;
pub use ;