C ++ class function in assembly

Hi, community. I look at the C ++ assembly, I have compiled a control sample from the PARSEC package, and it’s hard for me to understand how they call the class attribute functions in assembly language. for example, if I have a class with some functions to handle it, in cpp we call them test.increment(); After some research, it turned out that this function

 atomic_load_acq_ptr 

presented as:

 _ZL19atomic_load_acq_intPVj 

in the assembly, or at least that's what I discovered.

Let me know if I am wrong! Is there any fixed rule to display? or are they random? Thanks

+1
source share
4 answers

It is called a name change, it is necessary due to overloads and patterns, etc. (i.e., a simple name of symbols and numbers is not enough to uniquely identify a piece of code, embed spaces or <> or :: in names are usually not legal, and copying additional information in a non-condensed, readable form will be useless), and therefore it depends from types, arity, etc.

The exact layout may vary, but usually each compiler is self-consistent for a relatively long time (sometimes even several compilers can rely on one method).

+6
source

This is called name mangling. . It depends on the compiler. There is no standard way, sorry :)

+2
source

C ++ allows function overloading, which means that you can have two functions with the same name but with different parameters. Since your binary formats do not understand the type, this is not easy. The way this works is to use a circuit called mangling. This adds a whole function of type information to the name used in the source file and ensures that you invoke the correct overload.

Additional letters, etc. that are added are determined by the specific binary application interface (ABI). Different compilers (and sometimes different versions) can use different ABIs.

+2
source

Yes, there is a standard method for creating these characters, known as name mangling.

0
source

All Articles