use goblin::elf::{Elf, sym::*};
#[derive(Debug, Clone)]
pub struct Symbol<'a> {
pub name: &'a str,
pub binding: &'static str,
pub typ: &'static str,
pub visibility: &'static str,
pub address: u64,
pub size: u64,
}
impl<'a> Symbol<'a> {
pub fn new<'b> (elf: &'a Elf, sym: &'b Sym) -> Self {
Symbol {
name: Self::name(elf, sym),
binding: bind_to_str(sym.st_bind()),
typ: type_to_str(sym.st_type()),
visibility: visibility_to_str(sym.st_visibility()),
address: sym.st_value,
size: sym.st_size,
}
}
pub fn name<'b> (elf: &'b Elf, sym: &Sym) -> &'b str {
elf.strtab.get_at(sym.st_name).unwrap()
}
}