Skip to content

Commit

Permalink
dol apply: Don't apply gap symbols
Browse files Browse the repository at this point in the history
Also don't overwrite "unknown" scope
with global.

Fixes #30
  • Loading branch information
encounter committed Jan 25, 2024
1 parent 26cc6a1 commit 4a84975
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cmd/dol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1654,6 +1654,9 @@ fn apply(args: ApplyArgs) -> Result<()> {
if linked_scope != ObjSymbolScope::Unknown
&& !is_globalized
&& 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!(
"Changing scope of {} (type {:?}) from {:?} to {:?}",
Expand Down Expand Up @@ -1683,6 +1686,7 @@ fn apply(args: ApplyArgs) -> Result<()> {
// Add symbols from the linked object that aren't in the original
for linked_sym in linked_obj.symbols.iter() {
if matches!(linked_sym.kind, ObjSymbolKind::Section)
|| is_auto_symbol(linked_sym)
|| is_linker_generated_object(&linked_sym.name)
// skip ABS for now
|| linked_sym.section.is_none()
Expand Down
2 changes: 2 additions & 0 deletions src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ pub fn is_auto_symbol(symbol: &ObjSymbol) -> bool {
symbol.name.starts_with("lbl_")
|| symbol.name.starts_with("fn_")
|| 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<()>
Expand Down

0 comments on commit 4a84975

Please sign in to comment.