Line data Source code
1 : //! Module for the ELF file format support in LIEF.
2 : //!
3 : //! The [`Binary`] structure exposes the main API to inspect an ELF file. It can be instantiated,
4 : //! using either: [`crate::elf::parse`], [`crate::elf::Binary::parse`] or [`crate::Binary::parse`]
5 : //!
6 : //! ```
7 : //! let elf = lief::elf::parse("/bin/ls").unwrap();
8 : //! for section in elf.sections() {
9 : //! println!("section: {}", section.name());
10 : //! }
11 : //! ```
12 :
13 : use std::path::Path;
14 :
15 : pub mod binary;
16 : pub mod builder;
17 : pub mod dynamic;
18 : pub mod hash;
19 : pub mod header;
20 : pub mod note;
21 : pub mod relocation;
22 : pub mod section;
23 : pub mod segment;
24 : pub mod symbol;
25 : pub mod symbol_versioning;
26 : pub mod parser_config;
27 :
28 : #[doc(inline)]
29 : pub use binary::Binary;
30 :
31 : #[doc(inline)]
32 : pub use header::Header;
33 :
34 : #[doc(inline)]
35 : pub use section::Section;
36 :
37 : #[doc(inline)]
38 : pub use segment::Segment;
39 :
40 : #[doc(inline)]
41 : pub use symbol::Symbol;
42 :
43 : #[doc(inline)]
44 : pub use hash::Sysv as SysvHash;
45 :
46 : #[doc(inline)]
47 : pub use hash::Gnu as GnuHash;
48 :
49 : #[doc(inline)]
50 : pub use note::Notes;
51 :
52 : #[doc(inline)]
53 : pub use dynamic::Entries as DynamicEntries;
54 :
55 : #[doc(inline)]
56 : pub use relocation::Relocation;
57 :
58 : #[doc(inline)]
59 : pub use symbol_versioning::{
60 : SymbolVersion, SymbolVersionAux, SymbolVersionAuxRequirement, SymbolVersionDefinition,
61 : SymbolVersionRequirement,
62 : };
63 :
64 : #[doc(inline)]
65 : pub use parser_config::Config as ParserConfig;
66 :
67 : /// Parse an ELF file from the given file path
68 0 : pub fn parse<P: AsRef<Path>>(path: P) -> Option<Binary> {
69 0 : Binary::parse(path)
70 0 : }
71 :
72 : /// Parse an ELF file from the given file path and configuration
73 0 : pub fn parse_with_config<P: AsRef<Path>>(path: P, config: &ParserConfig) -> Option<Binary> {
74 0 : Binary::parse_with_config(path, config)
75 0 : }
|