7

Using Visual Studio 2010/2012, one can compile a c++ source file with the /FAs switch to generate the assembly output of the resulting code. But the generated asm file contains all symbols in their mangled form.

Is there a switch or other smart way to make Visual Studio generate unmangled symbols instead? I know that one could manually feed the asm file through undname.exe but a switch would be much more convenient than a custom post-build event.

Bloops
  • 485
  • 4
  • 11

2 Answers2

1

It is not possible to do so, because of the nature of /FA's output. FA outputs valid assembly code. The symbols one needs to express a C++ function unmangled are simply not valid label names in microsoft's x86 assembly. There is also no good notation for anonymous namespaces.

Any output which handled those cases would not be compilable using an assembler. If you made an assembler which did handle such names, it would need to know whose name mangling rules to apply to assemble it. This defeats the main purpose of outputting assembly (to see EXACTLY what is going on).

Cort Ammon
  • 10,221
  • 31
  • 45
0

If all of your symbols are compatible with extern "C" than you could wrap all of your code in the C++ source file in an extern "C" block to force all symbols to be emitted in unmangled C style rather than having C++ name mangling applied.

The Microsoft Research project http://en.wikipedia.org/wiki/Phoenix_%28compiler_framework%29 provides hooks into the toolchain and it might allow direct manipulation of how symbol names are formed, but unfortunately its last public release was for VS 2008 and it doesn't appear to have been productized for inclusion in either VS 2010 or VS 2012.

Josh Heitzman
  • 1,816
  • 1
  • 14
  • 26