SPRUIG8J January 2018 – March 2024
The examples in this section illustrate the demangling process.
This example shows a sample C++ program. In this example, the linknames of all the functions are mangled; that is, their signature information is encoded into their names.
class banana {
public:
int calories(void);
banana();
~banana();
};
int calories_in_a_banana(void)
{
banana x;
return x.calories();
}
Executing the C++ name demangler will demangle all names that it believes to be mangled. Enter:
dem7x calories_in_a_banana.asm
The result after running the C++ name demangler is as follows. The linknames _ZN6bananaC1Ev, _ZN6banana8caloriesEv, and _ZN6bananaD1Ev are demangled.
||calories_in_a_banana()||:
;** --------------------------------------------------------------------------*
MVC .S1 RP,A9 ; [A_S1]
|| STD .D1 A8,*SP(8) ; [A_D1]
|| STD .D2X A9,*SP++(-24) ; [A_D2]
CALL .B1 ||banana::banana()|| ; [A_B] |9|
|| ADDD .D1 SP,0x10,A4 ; [A_D1] |9|
$C$RL0: ; CALL OCCURS (||banana::banana()||) arg:{A4} ret:{} ; [] |9|
CALL .B1 ||banana::calories()|| ; [A_B] |10|
|| ADDD .D1 SP,0x10,A4 ; [A_D1] |10|
$C$RL1: ; CALL OCCURS (||banana::calories()||) arg:{A4} ret:{A4} ; [] |10|
CALL .B1 ||banana::~banana()|| ; [A_B] |10|
|| ADDD .D1 SP,0x10,A4 ; [A_D1] |10|
|| MV .D2 A4,A8 ; [A_D2] |10|
$C$RL2: ; CALL OCCURS (||banana::~banana()||) arg:{A4} ret:{} ; [] |10|
MV .D1 A8,A4 ; [A_D1] |10|
MVC .S1 A9,RP ; [A_S1] BARRIER
LDD .D1 *SP(24),A9 ; [A_D1]
|| LDD .D2 *SP(32),A8 ; [A_D2]
RET .B1 ; [A_B]
|| ADDD .D1 SP,0x18,SP ; [A_D1]
; RETURN OCCURS {RP} ; []