monistode_binutils/
lib.rs

1pub mod address;
2pub mod definition;
3pub mod executable;
4pub mod object_file;
5pub mod serializable;
6pub mod symbols;
7
8pub use address::Address;
9pub use definition::{Definition, RawDefinition};
10pub use executable::Executable;
11pub use object_file::ObjectFile;
12pub use serializable::{Architecture, Serializable, SerializationError};
13pub use symbols::{Symbol, SymbolTable};
14
15use object_file::placed::{LinkerError, PlacedSection, Placement};
16
17impl TryFrom<ObjectFile> for Executable {
18    type Error = LinkerError;
19
20    fn try_from(object: ObjectFile) -> Result<Self, Self::Error> {
21        let architecture = object.architecture();
22        let mut placed = Placement::new(
23            object
24                .sections()
25                .into_iter()
26                .map(|section| PlacedSection::new(section))
27                .collect(),
28            architecture,
29        );
30        placed.place();
31        return Ok(Executable::new(architecture, placed.as_segments()?));
32    }
33}