nm_binutils/object/
symbol.rs1use goblin::elf::{Elf, sym::*};
2
3#[derive(Debug, Clone)]
10pub struct Symbol<'a> {
11 pub name: &'a str,
13 pub binding: &'static str,
15 pub typ: &'static str,
17 pub visibility: &'static str,
19 pub address: u64,
21 pub size: u64,
23}
24
25impl<'a> Symbol<'a> {
26 pub fn new<'b> (elf: &'a Elf, sym: &'b Sym) -> Self {
28 Symbol {
29 name: Self::name(elf, sym),
30 binding: bind_to_str(sym.st_bind()),
31 typ: type_to_str(sym.st_type()),
32 visibility: visibility_to_str(sym.st_visibility()),
33 address: sym.st_value,
34 size: sym.st_size,
35 }
36 }
37
38 pub fn name<'b> (elf: &'b Elf, sym: &Sym) -> &'b str {
39 elf.strtab.get_at(sym.st_name).unwrap()
40 }
41}