run_make_support nm implementation + bin-emit-no-symbols rmake rewrite
This commit is contained in:
parent
8814b926f4
commit
83cb760e2c
12 changed files with 74 additions and 17 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit a1f47ec3f7cd076986f1bfcd7061f2e8cb1a726e
|
||||
Subproject commit 431db31d0dbeda320caf8ef8535ea48eb3093407
|
||||
48
src/tools/run-make-support/src/nm/mod.rs
Normal file
48
src/tools/run-make-support/src/nm/mod.rs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
use crate::{fs_wrapper, object};
|
||||
use object::{Object, ObjectSection};
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Nm {
|
||||
file: Option<object::File>,
|
||||
}
|
||||
|
||||
pub fn nm() -> Nm {
|
||||
Nm::new()
|
||||
}
|
||||
|
||||
impl Nm {
|
||||
/// Construct a bare `nm` invocation.
|
||||
pub fn new() -> Self {
|
||||
Self { file: None }
|
||||
}
|
||||
|
||||
/// Specify the file to analyze the symbols of.
|
||||
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
|
||||
&mut Self {
|
||||
file: Some(
|
||||
object::File::parse(fs_wrapper::read(path))
|
||||
.expect(format!("Failed to parse ELF file at {:?}", path.as_ref().display())),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Collect all symbols of an object file into a String.
|
||||
pub fn collect_symbols(&self) -> String {
|
||||
let object_file = self.file;
|
||||
let mut symbols_str = String::new();
|
||||
for section in object_file.sections() {
|
||||
if let Ok(ObjectSection::SymbolTable(st)) = section.parse::<object::SymbolTable>() {
|
||||
for symbol in st.symbols() {
|
||||
symbols_str.push_str(&format!(
|
||||
"{:016x} {:?} {}\n",
|
||||
symbol.address(),
|
||||
symbol.kind(),
|
||||
symbol.name()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
symbols_str
|
||||
}
|
||||
}
|
||||
|
|
@ -84,7 +84,6 @@ run-make/issue-37839/Makefile
|
|||
run-make/issue-40535/Makefile
|
||||
run-make/issue-47384/Makefile
|
||||
run-make/issue-47551/Makefile
|
||||
run-make/issue-51671/Makefile
|
||||
run-make/issue-68794-textrel-on-minimal-lib/Makefile
|
||||
run-make/issue-69368/Makefile
|
||||
run-make/issue-83045/Makefile
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue