dol apply: Don't apply gap symbols

Also don't overwrite "unknown" scope
with global.

Fixes #30
This commit is contained in:
Luke Street 2024-01-24 23:23:05 -07:00
parent 26cc6a13b4
commit 4a84975648
2 changed files with 6 additions and 0 deletions

View File

@ -1654,6 +1654,9 @@ fn apply(args: ApplyArgs) -> Result<()> {
if linked_scope != ObjSymbolScope::Unknown if linked_scope != ObjSymbolScope::Unknown
&& !is_globalized && !is_globalized
&& linked_scope != orig_sym.flags.scope() && linked_scope != orig_sym.flags.scope()
// Don't overwrite unknown scope with global
&& (linked_scope != ObjSymbolScope::Global
|| orig_sym.flags.scope() != ObjSymbolScope::Unknown)
{ {
log::info!( log::info!(
"Changing scope of {} (type {:?}) from {:?} to {:?}", "Changing scope of {} (type {:?}) from {:?} to {:?}",
@ -1683,6 +1686,7 @@ fn apply(args: ApplyArgs) -> Result<()> {
// Add symbols from the linked object that aren't in the original // Add symbols from the linked object that aren't in the original
for linked_sym in linked_obj.symbols.iter() { for linked_sym in linked_obj.symbols.iter() {
if matches!(linked_sym.kind, ObjSymbolKind::Section) if matches!(linked_sym.kind, ObjSymbolKind::Section)
|| is_auto_symbol(linked_sym)
|| is_linker_generated_object(&linked_sym.name) || is_linker_generated_object(&linked_sym.name)
// skip ABS for now // skip ABS for now
|| linked_sym.section.is_none() || linked_sym.section.is_none()

View File

@ -178,6 +178,8 @@ pub fn is_auto_symbol(symbol: &ObjSymbol) -> bool {
symbol.name.starts_with("lbl_") symbol.name.starts_with("lbl_")
|| symbol.name.starts_with("fn_") || symbol.name.starts_with("fn_")
|| symbol.name.starts_with("jumptable_") || symbol.name.starts_with("jumptable_")
|| symbol.name.starts_with("gap_")
|| symbol.name.starts_with("pad_")
} }
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<()>