Address comments from PR

This commit is contained in:
Syrus Akbary
2020-06-13 09:49:57 -07:00
parent 4213e052b1
commit f0c8542e1e
7 changed files with 22 additions and 21 deletions

View File

@ -12,6 +12,7 @@ pub struct WriterRelocate {
}
impl WriterRelocate {
pub const FUNCTION_SYMBOL: usize = 0;
pub fn new(endianness: Option<Endianness>) -> Self {
let endianness = match endianness {
Some(Endianness::Little) => RunTimeEndian::Little,
@ -61,7 +62,7 @@ impl Writer for WriterRelocate {
Address::Constant(val) => self.write_udata(val, size),
Address::Symbol { symbol, addend } => {
// Is a function relocation
if symbol == 0 {
if symbol == Self::FUNCTION_SYMBOL {
// We use the addend to detect the function index
let function_index = LocalFunctionIndex::new(addend as _);
let reloc_target = RelocationTarget::LocalFunc(function_index);
@ -79,7 +80,7 @@ impl Writer for WriterRelocate {
});
self.write_udata(addend as u64, size)
} else {
unreachable!("Symbol {} in Dwarf not recongnized", symbol);
unreachable!("Symbol {} in DWARF not recognized", symbol);
}
}
}