Search code examples
c++visual-c++name-mangling

Function symbols in windows executeable


I want to get a list of with the mangled names of all functions of an executeable for some external analysis.

On Linux this a an easy task. I just need to compile as usual and run nm to get a list with the mangled names.

$ nm test    
                 U _GLOBAL_OFFSET_TABLE_
                 U printf
                 U __stack_chk_fail
0000000000000012 T _Z3fooi
0000000000000000 T _Z3foov
0000000000000007 T _Z4footv
0000000000000000 W _ZN3BarC1Ev
0000000000000000 W _ZN3BarC2Ev
0000000000000000 n _ZN3BarC5Ev

On windows and microsoft's visual c++ (msvc?) I can't figure a way to get information in the same way. I tried compiling my application with cl /Od /DEBUG and run dumpbin /EXPORTS /HEADERS but I don't get a list of the mangled function names of my application.

dumpbin /EXPORTS test.exe
Microsoft (R) COFF/PE Dumper Version 14.00.24245.0
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file test.exe

File Type: EXECUTABLE IMAGE

Summary

2000 .data
1000 .gfids
1000 .pdata
9000 .rdata
1000 .reloc
C000 .text
Type a message

Is dumpbin only working on shared libraries instead of executables? Since I only need all mangled names (e.g. _Z3foov, _ZN3BarC1Ev) without changing my application code, is there a better solution to get this strings? I'm usually developing c++ application on linux. Therefore I don't know much about windows specifics.


Solution

  • In Visual Studio, you're looking for the "MAP file". The linker option is /MAP, it's found under the "Debugging" properties in Visual Studio. This is generated as part of the build, not afterwards. The output is a simple text file similar to nm output.