ARM Optimizing
C/C++ Compiler
v16.12.0.STS User's Guide
SPNU151N - REVISED DECEMBER 2016
8 C++ Name Demangler
The C++ compiler implements function overloading, operator overloading, and type-safe linking by encoding a function's prototype and namespace in its link-level name. The process of encoding the prototype into the linkname is often referred to as name mangling. When you inspect mangled names, such as in assembly files, disassembler output, or compiler or linker diagnostic messages, it can be difficult to associate a mangled name with its corresponding name in the C++ source code. The C++ name demangler is a debugging aid that translates each mangled name it detects to its original name found in the C++ source code.
These topics tell you how to invoke and use the C++ name demangler. The C++ name demangler reads in input, looking for mangled names. All unmangled text is copied to output unaltered. All mangled names are demangled before being copied to output.
8.1 Invoking the C++ Name Demangler
The syntax for invoking the C++ name demangler is:
armdem [options ] [filenames] |
armdem | Command that invokes the C++ name demangler. |
options | Options affect how the name demangler behaves. Options can appear anywhere on the command line. (Options are discussed in Section 8.2.) |
filenames | Text input files, such as the assembly file output by the compiler, the assembler listing file, the disassembly file, and the linker map file. If no filenames are specified on the command line, armdem uses standard input. |
By default, the C++ name demangler outputs to standard output. You can use the -o file option if you want to output to a file.
8.2 C++ Name Demangler Options
The following options apply only to the C++ name demangler:
--debug | Prints debug messages. |
--diag_wrap[=on,off] | Sets diagnostic messages to wrap at 79 columns (on, which is the default) or not (off). |
--help | Prints a help screen that provides an online summary of the C++ name demangler options. |
--output= file | Outputs to the specified file rather than to standard out. |
--quiet | Reduces the number of messages generated during execution. |
-u | Specifies that external names do not have a C++ prefix. |
-v | Enables verbose mode (outputs a banner). |
8.3 Sample Usage of the C++ Name Demangler
The examples in this section illustrate the demangling process. Example 8-1 shows a sample C++ program. Example 8-2 shows the resulting assembly that is output by the compiler. In this example, the linknames of all the functions are mangled; that is, their signature information is encoded into their names.
Example 8-1 C++ Code for calories_in_a_banana
class banana {
public:
int calories(void);
banana();
~banana();
};
int calories_in_a_banana(void)
{
banana x;
return x.calories();
}
Example 8-2 Resulting Assembly for calories_in_a_banana
_Z20calories_in_a_bananav:
STMFD SP!, {A3, A4, V1, LR}
MOV A1, SP
BL _ZN6bananaC1Ev
BL _ZN6banana8caloriesEv
MOV V1, A1
MOV A1, SP
BL _ZN6bananaD1Ev
MOV A1, V1
LDMFD SP!, {A3, A4, V1, LR}
BX LR
Executing the C++ name demangler demangles all names that it believes to be mangled. Enter:
armdem calories_in_a_banana.asm
The result is shown in Example 8-3. The linknames in Example 8-2___ct__6bananaFv, _calories__6bananaFv, and ___dt__6bananaFv are demangled.
Copyright© 2016, Texas Instruments Incorporated. An IMPORTANT NOTICE for this document addresses availability, warranty, changes, use in safety-critical applications, intellectual property matters and other important disclaimers.