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]
Regular,
Reexport,
Stub
Stub,
}
#[pymethods]
@ -39,32 +39,28 @@ impl From<goblin::mach::exports::ExportInfo<'_>> for ExportInfo {
fn from(info: goblin::mach::exports::ExportInfo) -> Self {
use goblin::mach::exports::ExportInfo::*;
match info {
Regular { address, flags } => {
Self {
typ: ExportTyp::Regular,
address,
flags,
.. Default::default()
}
}
Reexport { lib, lib_symbol_name, flags } => {
Self {
typ: ExportTyp::Reexport,
lib: Some(lib.to_string()),
lib_symbol_name: lib_symbol_name.map(|s| s.to_string()),
flags,
.. Default::default()
}
}
Stub {
flags, ..
} => {
Self {
typ: ExportTyp::Stub,
flags,
.. Default::default()
}
}
Regular { address, flags } => Self {
typ: ExportTyp::Regular,
address,
flags,
..Default::default()
},
Reexport {
lib,
lib_symbol_name,
flags,
} => Self {
typ: ExportTyp::Reexport,
lib: Some(lib.to_string()),
lib_symbol_name: lib_symbol_name.map(|s| s.to_string()),
flags,
..Default::default()
},
Stub { flags, .. } => Self {
typ: ExportTyp::Stub,
flags,
..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 pyo3::{exceptions::PyTypeError, prelude::*};
@ -12,7 +15,7 @@ mod symbols;
use exports::Export;
use header::Header;
use imports::Import;
use sections::{Sections, Section};
use sections::{Section, Sections};
use symbols::Symbols;
#[pyclass]
@ -85,11 +88,10 @@ impl Object {
sections.extend(sect_iter.map(|section| {
let (sect, _data) = section.unwrap();
Section::from(sect)
}));
}
Sections { sections }
},
}
_ => 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::*;
#[derive(Debug, Clone)]