1
Fork 0

Formatted

This commit is contained in:
Jan-Erik Rediger 2023-12-09 00:26:21 +01:00
parent c57a484ab6
commit 9644aa9b95
3 changed files with 30 additions and 33 deletions

View file

@ -6,7 +6,7 @@ enum ExportTyp {
#[default] #[default]
Regular, Regular,
Reexport, Reexport,
Stub Stub,
} }
#[pymethods] #[pymethods]
@ -39,32 +39,28 @@ impl From<goblin::mach::exports::ExportInfo<'_>> for ExportInfo {
fn from(info: goblin::mach::exports::ExportInfo) -> Self { fn from(info: goblin::mach::exports::ExportInfo) -> Self {
use goblin::mach::exports::ExportInfo::*; use goblin::mach::exports::ExportInfo::*;
match info { match info {
Regular { address, flags } => { Regular { address, flags } => Self {
Self {
typ: ExportTyp::Regular, typ: ExportTyp::Regular,
address, address,
flags, flags,
.. Default::default() ..Default::default()
} },
} Reexport {
Reexport { lib, lib_symbol_name, flags } => { lib,
Self { lib_symbol_name,
flags,
} => Self {
typ: ExportTyp::Reexport, typ: ExportTyp::Reexport,
lib: Some(lib.to_string()), lib: Some(lib.to_string()),
lib_symbol_name: lib_symbol_name.map(|s| s.to_string()), lib_symbol_name: lib_symbol_name.map(|s| s.to_string()),
flags, flags,
.. Default::default() ..Default::default()
} },
} Stub { flags, .. } => Self {
Stub {
flags, ..
} => {
Self {
typ: ExportTyp::Stub, typ: ExportTyp::Stub,
flags, flags,
.. Default::default() ..Default::default()
} },
}
} }
} }
} }
@ -99,4 +95,3 @@ impl From<goblin::mach::exports::Export<'_>> for Export {
} }
} }
} }

View file

@ -1,4 +1,7 @@
use std::{fs::{File, self}, io::Read}; use std::{
fs::{self, File},
io::Read,
};
use goblin::mach::Mach; use goblin::mach::Mach;
use pyo3::{exceptions::PyTypeError, prelude::*}; use pyo3::{exceptions::PyTypeError, prelude::*};
@ -12,7 +15,7 @@ mod symbols;
use exports::Export; use exports::Export;
use header::Header; use header::Header;
use imports::Import; use imports::Import;
use sections::{Sections, Section}; use sections::{Section, Sections};
use symbols::Symbols; use symbols::Symbols;
#[pyclass] #[pyclass]
@ -85,11 +88,10 @@ impl Object {
sections.extend(sect_iter.map(|section| { sections.extend(sect_iter.map(|section| {
let (sect, _data) = section.unwrap(); let (sect, _data) = section.unwrap();
Section::from(sect) Section::from(sect)
})); }));
} }
Sections { sections } Sections { sections }
}, }
_ => unimplemented!(), _ => unimplemented!(),
} }
} }

View file

@ -1,4 +1,4 @@
use goblin::mach::symbols::{N_TYPE, n_type_to_str, N_EXT, N_WEAK_REF, N_WEAK_DEF, N_UNDF, N_STAB}; use goblin::mach::symbols::{n_type_to_str, N_EXT, N_STAB, N_TYPE, N_UNDF, N_WEAK_DEF, N_WEAK_REF};
use pyo3::prelude::*; use pyo3::prelude::*;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]