From ccfbfd1a5a745a6a2eae00e75e11000cbb86c558 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 3 Apr 2024 00:12:46 -0600 Subject: [PATCH] Fix for jumptable naming in RELs --- src/obj/symbols.rs | 12 ++++++++++-- src/util/config.rs | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/obj/symbols.rs b/src/obj/symbols.rs index c1040b6..76f77e7 100644 --- a/src/obj/symbols.rs +++ b/src/obj/symbols.rs @@ -13,7 +13,11 @@ use serde_repr::{Deserialize_repr, Serialize_repr}; use crate::{ analysis::cfa::SectionAddress, 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)] @@ -242,7 +246,11 @@ impl ObjSymbols { bail!("ABS symbol in relocatable object: {:?}", in_symbol); }; 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 = if existing.size_known && in_symbol.size_known && existing.size != in_symbol.size { // TODO fix this and restore to warning diff --git a/src/util/config.rs b/src/util/config.rs index b18e446..41855bf 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -182,6 +182,10 @@ pub fn is_auto_symbol(symbol: &ObjSymbol) -> bool { || 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(path: P, cb: Cb, cached_file: Option) -> Result<()> where P: AsRef,