1#![allow(clippy::too_many_arguments)]
2// We are writing a very specific, well defined format, so it makes it easier to
3// see exactly what is being written if we explicitly write out `\n` instead of
4// hoping somebody notices the `writeln!` instead of `write!`.
5#![allow(clippy::write_with_newline)]
6
7mod alignment;
8mod archive;
9mod archive_writer;
10mod coff;
11mod coff_import_file;
12mod mangler;
13mod math_extras;
14mod object_reader;
15
16pub use archive::ArchiveKind;
17pub use archive_writer::{write_archive_to_stream, NewArchiveMember};
18pub use coff::MachineTypes;
19pub use coff_import_file::{write_import_library, COFFShortExport};
20
21pub type GetSymbolsFn =
22 fn(buf: &[u8], f: &mut dyn FnMut(&[u8]) -> std::io::Result<()>) -> std::io::Result<bool>;
23pub type Is64BitObjectFileFn = fn(buf: &[u8]) -> bool;
24pub type IsECObjectFileFn = fn(buf: &[u8]) -> bool;
25pub type GetXCoffMemberAlignmentFn = fn(buf: &[u8]) -> u32;
26
27/// Helper struct to query object file information from members.
28pub struct ObjectReader {
29 /// Iterates over the symbols in the object file.
30 pub get_symbols: GetSymbolsFn,
31 /// Returns true if the object file is 64-bit.
32 /// Note that this should match LLVM's `SymbolicFile::is64Bit`, which
33 /// considers all COFF files to be 32-bit.
34 pub is_64_bit_object_file: Is64BitObjectFileFn,
35 /// Returns true if the object file is an EC (that is, an Arm64EC or x64)
36 /// object file
37 pub is_ec_object_file: IsECObjectFileFn,
38 /// Returns the member alignment of an XCoff object file.
39 pub get_xcoff_member_alignment: GetXCoffMemberAlignmentFn,
40}
41
42/// Default implementation of [ObjectReader] that uses the `object` crate.
43pub const DEFAULT_OBJECT_READER: ObjectReader = ObjectReader {
44 get_symbols: object_reader::get_native_object_symbols,
45 is_64_bit_object_file: object_reader::is_64_bit_symbolic_file,
46 is_ec_object_file: object_reader::is_ec_object,
47 get_xcoff_member_alignment: object_reader::get_member_alignment,
48};
49

Provided by KDAB

Privacy Policy
Learn Rust with the experts
Find out more