Fix for jumptable naming in RELs

This commit is contained in:
Luke Street 2024-04-03 00:12:46 -06:00
parent e9a9ed0453
commit ccfbfd1a5a
2 changed files with 14 additions and 2 deletions

View File

@ -13,7 +13,11 @@ use serde_repr::{Deserialize_repr, Serialize_repr};
use crate::{ use crate::{
analysis::cfa::SectionAddress, analysis::cfa::SectionAddress,
obj::{ObjKind, ObjRelocKind}, obj::{ObjKind, ObjRelocKind},
util::{config::is_auto_symbol, nested::NestedVec, split::is_linker_generated_label}, util::{
config::{is_auto_jump_table, is_auto_label, is_auto_symbol},
nested::NestedVec,
split::is_linker_generated_label,
},
}; };
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, Default)] #[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize, Default)]
@ -242,7 +246,11 @@ impl ObjSymbols {
bail!("ABS symbol in relocatable object: {:?}", in_symbol); bail!("ABS symbol in relocatable object: {:?}", in_symbol);
}; };
let target_symbol_idx = if let Some((symbol_idx, existing)) = opt { let target_symbol_idx = if let Some((symbol_idx, existing)) = opt {
let replace = replace || (is_auto_symbol(existing) && !is_auto_symbol(&in_symbol)); let replace = replace
// Replace auto symbols with known symbols
|| (is_auto_symbol(existing) && !is_auto_symbol(&in_symbol))
// Replace lbl_ with jumptable_
|| (is_auto_label(existing) && is_auto_jump_table(&in_symbol));
let size = let size =
if existing.size_known && in_symbol.size_known && existing.size != in_symbol.size { if existing.size_known && in_symbol.size_known && existing.size != in_symbol.size {
// TODO fix this and restore to warning // TODO fix this and restore to warning

View File

@ -182,6 +182,10 @@ pub fn is_auto_symbol(symbol: &ObjSymbol) -> bool {
|| symbol.name.starts_with("pad_") || symbol.name.starts_with("pad_")
} }
pub fn is_auto_label(symbol: &ObjSymbol) -> bool { symbol.name.starts_with("lbl_") }
pub fn is_auto_jump_table(symbol: &ObjSymbol) -> bool { symbol.name.starts_with("jumptable_") }
fn write_if_unchanged<P, Cb>(path: P, cb: Cb, cached_file: Option<FileReadInfo>) -> Result<()> fn write_if_unchanged<P, Cb>(path: P, cb: Cb, cached_file: Option<FileReadInfo>) -> Result<()>
where where
P: AsRef<Path>, P: AsRef<Path>,