Skip to content

Conversation

AngheloAlf
Copy link
Contributor

@AngheloAlf AngheloAlf commented Sep 18, 2025

I tested it locally and works fine.

I'm unsure about a few things.

  • I only added this new demangler to mips and x86, should I add it to any other arch?
  • Should cpp_demangle be removed from mips? I don't know if there's any mips project that uses a new enough g++ compiler that uses the new mangling abi. Or maybe invert cwdemangle and cpp_demangle since it is more likely for cw to be used in mips than a new g++.

@tomsons26
Copy link
Contributor

I've seen old and new mangling formats in gcc built binaries for Windows and Mac so it's definitely not a old mips binary exclusive thing

@AngheloAlf
Copy link
Contributor Author

What arch is used for Mac? I assume Windows uses x86, but dunno what Mac uses. Maybe ppc?

@AngheloAlf AngheloAlf changed the title [MIPS] Use gnuv2_demangle for better demangling of old g++ compiled projects Use gnuv2_demangle for better demangling of old g++ compiled projects Sep 20, 2025
@benny-dreamly
Copy link

What arch is used for Mac? I assume Windows uses x86, but dunno what Mac uses. Maybe ppc?

Yes it is ppc/intel but most likely ppc

@AngheloAlf AngheloAlf changed the title Use gnuv2_demangle for better demangling of old g++ compiled projects Arch-independent demangling and add gnuv2_demangle for old g++ projects Sep 20, 2025
@AngheloAlf
Copy link
Contributor Author

I refactored the demangling code to be architecture-independent.

Now the user can manually select which demangler they prefer to use. objdiff will still try to guess demangling the symbols by default.

image

I also updated the "Tools" -> "Demangle..." pop-up to use the selected demangler instead of leaving it hardcoded to codewarrior.

Copy link
Owner

@encounter encounter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big improvement!

if name.starts_with('?') {
msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok()
} else {
name = name.trim_start_matches('.');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep this . trimming logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can see only ppc has this trimming logic.

Do you want to always trim . when the demangler is not msvc? Or should it be only be applied to specific demanglers (cpp_demangle, cwdemangle, etc) ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just add it for itanium/gnuv2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.

btw, I'm a bit curious, do you have an example a mangled symbol like this? I would like to take an small look at it.
It is okay if you don't have any, don't worry much about it.

if name.starts_with('?') {
msvc_demangler::demangle(name, msvc_demangler::DemangleFlags::llvm()).ok()
} else {
name = name.trim_start_matches('.');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just add it for itanium/gnuv2

@tomsons26
Copy link
Contributor

What arch is used for Mac? I assume Windows uses x86, but dunno what Mac uses. Maybe ppc?

PPC and later x86, usually both target elfs packed in another elf, later then PPC was made obsolete just x86

@encounter encounter merged commit fe8e702 into encounter:main Sep 22, 2025
24 checks passed
@AngheloAlf AngheloAlf deleted the gnuv2_demangle branch September 23, 2025 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants