Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions objdiff-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ encoding_rs = { version = "0.8.35", optional = true }

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", optional = true, features = ["winbase"] }
windows-sys = { version = "0.61", optional = true, features = ["Win32_System_Diagnostics_Debug"] }

# For Linux static binaries, use rustls
[target.'cfg(target_os = "linux")'.dependencies]
Expand Down
33 changes: 28 additions & 5 deletions objdiff-core/src/arch/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,35 @@ impl Arch for ArchX86 {

fn demangle(&self, name: &str) -> Option<String> {
if name.starts_with('?') {
msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok()
} else {
cpp_demangle::Symbol::new(name)
.ok()
.and_then(|s| s.demangle(&cpp_demangle::DemangleOptions::default()).ok())
#[cfg(target_os = "windows")]
{
use std::ffi::{CStr, CString};

use windows_sys::Win32::System::Diagnostics::Debug::UnDecorateSymbolName;

let cstr = CString::new(name).ok()?;
let mut buffer = vec![0u8; 1024];

unsafe {
let len = UnDecorateSymbolName(
cstr.as_ptr() as windows_sys::core::PCSTR,
buffer.as_mut_ptr() as windows_sys::core::PSTR,
buffer.len() as u32,
0, // UNDNAME_COMPLETE
);
if len > 0 {
let result =
CStr::from_ptr(buffer.as_ptr() as *const i8).to_str().ok()?.to_string();
return Some(result);
}
}
}
return msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok();
}

cpp_demangle::Symbol::new(name)
.ok()
.and_then(|s| s.demangle(&cpp_demangle::DemangleOptions::default()).ok())
}

fn reloc_name(&self, flags: RelocationFlags) -> Option<&'static str> {
Expand Down
Loading