Skip to content

Commit 31c1648

Browse files
committed
tweak logic for detecting anonymous MSVC symbols
1 parent 821fcdb commit 31c1648

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

objdiff-core/src/obj/read.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,16 @@ fn get_normalized_symbol_name(name: &str) -> Option<String> {
6060
{
6161
// Match GCC symbol.1234 against symbol.2345
6262
Some(format!("{prefix}.{DUMMY_UNIQUE_ID}"))
63-
} else if name.starts_with('?') {
64-
// We're likely working with an MSVC symbol, so check for anonymous namespaces and zero out the hashes
65-
Some(
66-
Regex::new(r"\?A0x[0-9A-Fa-f]{8}@@")
67-
.unwrap()
68-
.replace_all(name, format!("?Ax{DUMMY_UNIQUE_MSVC_ID}@@"))
69-
.to_string(),
70-
)
7163
} else {
72-
None
64+
let re = Regex::new(r"\?A0x[0-9A-Fa-f]{8}@@").unwrap();
65+
// Match MSVC anonymous class symbol names, ignoring the unique ID.
66+
// e.g. ?CheckContextOr@?A0x24773155@@YA_NPBVDataArray@@@Z
67+
// and: ?CheckContextOr@?A0xddf6240c@@YA_NPBVDataArray@@@Z
68+
if name.starts_with('?') && re.is_match(name) {
69+
Some(re.replace_all(name, format!("?Ax{DUMMY_UNIQUE_MSVC_ID}@@")).to_string())
70+
} else {
71+
None
72+
}
7373
}
7474
}
7575

0 commit comments

Comments
 (0)