From 2e4bf49949e08772543289043c5347c379bb27a0 Mon Sep 17 00:00:00 2001 From: Daniel Paoliello Date: Wed, 14 Oct 2026 12:10:42 -0700 Subject: [PATCH] [coff] Symbol renaming stored the original name, not the undecorated name A previous PR changed `symbol_edit` to store the undecorated Arm64EC symbol in the set of renamed symbols. While the lookup for symbols in that set did use `undecorate_coff_symbol`, it is possible that we had a untyped reference to a symbol (for example `_RNvCsVsdZgbfeYr_7___rustc12___rust_alloc` or `_RINvNtCs1dnTqovEYZ_3std9panicking11begin_panicReEB4_`), which does not get undecorated hence the lookup fails. The fix is to store the original, decorated name in the set, which also saves having to undecorate when looking up the symbol. --- compiler/rustc_codegen_ssa/src/back/symbol_edit.rs | 8 +++----- .../staticlib-rename-internal-symbols-coff/rmake.rs | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs index 2ed758112a9fb..8fdbd304c4c2d 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_edit.rs @@ -483,8 +483,8 @@ fn coff_collect_impl<'data, Coff: CoffHeader>( } let Ok(name_bytes) = sym.name(strings) else { continue }; let Ok(name) = str::from_utf8(name_bytes) else { continue }; - let name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym)); - if !exported.contains(name) { + let export_name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym)); + if !exported.contains(export_name) { out.insert(name.to_string()); } } @@ -522,7 +522,6 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( let Ok(symbols) = header.symbols(data) else { return None }; let strings = symbols.strings(); - let machine = header.machine(); let mut renames = Vec::new(); for (index, sym) in symbols.iter() { @@ -532,8 +531,7 @@ fn coff_edit_impl<'data, Coff: CoffHeader>( } let Ok(name_bytes) = sym.name(strings) else { continue }; let Ok(name) = str::from_utf8(name_bytes) else { continue }; - let check_name = undecorate_coff_symbol(name, machine, coff_symbol_kind(sym)); - if rename.is_some_and(|(rename_set, _)| rename_set.contains(check_name)) { + if rename.is_some_and(|(rename_set, _)| rename_set.contains(name)) { renames.push(RenameEntry { name_field_offset: symbol_bytes_offset + index.0 * sym_size, name: name.to_string(), diff --git a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs index 12ddd353bc24d..9e47a6277622c 100644 --- a/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs +++ b/tests/run-make/staticlib-rename-internal-symbols-coff/rmake.rs @@ -120,6 +120,8 @@ fn decorated_exports() -> Vec<&'static str> { "_decorated_stdcall@8", "@decorated_fastcall@8", ] + } else if target().starts_with("arm64ec") { + vec!["#decorated_cdecl", "#decorated_calls_internal"] } else { vec!["decorated_cdecl", "decorated_calls_internal"] };