#[repr(C)]pub struct Symbol32 {
pub st_name: Elf32Word,
pub st_value: Elf32Addr,
pub st_size: Elf32Word,
pub st_info: u8,
pub st_other: u8,
pub st_shndx: Elf32Section,
pub symbol_name: String,
}
Expand description
Symbol32 is a entry of symbol table section.
Symbol32 はシンボルテーブルセクションのエントリである. ELF32で用いることを想定している.
Defaultトレイトを実装しているので,
Default::default()
を呼び出すことで簡単にNULLシンボルを作成できる.
§Examples
use elf_utilities::symbol::Symbol32;
let null_sym : Symbol32 = Default::default();
// Symbol32::new_null_symbol() のエイリアスでも作成可能.
let null_sym2 : Symbol32 = Symbol32::new_null_symbol();
assert_eq!(null_sym, null_sym2);
ELFファイルを生成する用途でこのライブラリを使用できるように, バイト列への変換もサポートしている.
§Examples
use elf_utilities::symbol::Symbol32;
let null_sym : Symbol32 = Default::default();
// to_le_bytes() を利用してバイト列に変換できる.
let sym_bytes = null_sym.to_le_bytes();
assert_eq!(Symbol32::SIZE as usize, sym_bytes.len())
Fields§
§st_name: Elf32Word
Symbol name index.
st_value: Elf32Addr
Symbol’s value.
st_size: Elf32Word
Symbol’s size.
st_info: u8
Information that includes symbol binds and symbol types.
st_other: u8
Symbol’s visibility. See symbol::VISIBILITY.
st_shndx: Elf32Section
A section table index that includes the symbol.
symbol_name: String
option member for utilities.
Implementations§
Source§impl Symbol32
impl Symbol32
Sourcepub const SIZE: usize = 16usize
pub const SIZE: usize = 16usize
SIZE provides Symbol32’s size used by Shdr32.sh_entsize or else.
pub fn new_null_symbol() -> Self
Sourcepub fn compare_by<P>(&self, predicate: P) -> bool
pub fn compare_by<P>(&self, predicate: P) -> bool
for utilities
pub fn get_type(&self) -> Type
pub fn get_bind(&self) -> Bind
pub fn get_visibility(&self) -> Visibility
Sourcepub fn set_info(&mut self, sym_type: Type, bind: Bind)
pub fn set_info(&mut self, sym_type: Type, bind: Bind)
Set symbol’s information to Symbol32
§Examples
use elf_utilities::symbol;
let mut null_sym = symbol::Symbol32::new_null_symbol();
null_sym.set_info(symbol::Type::Func, symbol::Bind::Global);
assert_eq!((1 << 4) | 2, null_sym.st_info);
Sourcepub fn to_le_bytes(&self) -> Vec<u8> ⓘ
pub fn to_le_bytes(&self) -> Vec<u8> ⓘ
Create Vec
§Examples
use elf_utilities::symbol::Symbol32;
let null_sym : Symbol32 = Default::default();
assert_eq!([0].repeat(Symbol32::SIZE as usize), null_sym.to_le_bytes());
pub fn deserialize(buf: &[u8], start: usize) -> Result<Self, Box<dyn Error>>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Symbol32
impl<'de> Deserialize<'de> for Symbol32
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Ord for Symbol32
impl Ord for Symbol32
Source§impl PartialOrd for Symbol32
impl PartialOrd for Symbol32
impl Eq for Symbol32
impl StructuralPartialEq for Symbol32
Auto Trait Implementations§
impl Freeze for Symbol32
impl RefUnwindSafe for Symbol32
impl Send for Symbol32
impl Sync for Symbol32
impl Unpin for Symbol32
impl UnwindSafe for Symbol32
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more