C + + ABI name change, compiler generation symbol study (QT for example)

Source: Internet
Author: User
Tags microsoft c qtest

In C + +, due to the existence of overloading and other technologies, the compiler to the function, struct, class, and so on to the linker, it can not be as simple as the C language through the function name, it needs to provide additional parameter information, but also with the C language to share the linker, which requires a name adaptation (name mangling), also called name retouching (name decoration).

Name adaptation, but for historical reasons, C + + does not have this standard (C + + does not have ABI standards, name adaptation is only part of the ABI problem). So the compilers are fragmented and the resulting files are not generic.

So: Under Windows, you will find that the same version of QtCore4.dll, different compilers compiled by the cannot be common. The same function void F (std::wstring s), the same compiler (MSVC), different options (/zc:wchar_t- or /zc:wchar_t), the exported symbols are different.

In Qt, we only focus on the following two types of name adaptations:

    • Itanium C + + ABI (GCC3, GCC4, including MinGW)
    • Microsoft C + + ABI

Note: For Intel compilers, it is consistent with the Microsoft ABI under Windows, and in other platforms, with GCC.

Use examples to speak

What's an example? The amount ... Find a simple dynamic library and see the name of the function it derives from. QT's core and GUI modules are too complex, take the QT test module to see it, QtTest4.dll or libqttest.so.4.8.0

How do you see the symbols?

    • Under Windows, we can use the DUMPBIN tool:

Dumpbin/exports Qttest4.dll
    • On Linux, we can use NM or readelf tools:

nm-d libqttest.so.4.8.0readelf-ws libqttest.so.4.8.0

Ready to work, you run the above command, you can see a lot of symbols appear on the screen, we compare the functions given by QT Manual, look at these symbols (only a few, otherwise I can not understand)

Put a line too long, have to do this, prototype/itanium/microsoft


void Qtest::qsleep (int ms)



Itanium ABI

[Email Protected]@@[email protected]

Microsoft ABI


const char * qtest::currenttestfunction ()


[Email protected]@ @YAPBDXZ


int qtest::qexec (qobject *testobject, int argc=0, char **argv=0)


[Email protected]@@[email protected]@[email protected]


int qtest::qexec (qobject *testobject, const qstringlist &arguments)


[Email protected]@@[email protected]@[email protected]@@z


Qtestdata & Qtest::newrow (const char * datatag)


[Email protected]@@[email protected]@[email protected]





This pile of things, a mess, how to see Ah??

Try to read and read.

void Qtest::qsleep (int ms)



Itanium ABI

[Email Protected]@@[email protected]

Microsoft ABI



Add a few spaces

_z N 5 qtest 6 Qsleep E I


C + + name prefixes

N... E

Compound name start character Qtest::qsleep

5 Qtest

Name of length 5 qtest

6 Qsleep

Name of length 6 qsleep


Parameter type int


[Email Protected]@@[email protected]

This information is a bit more, a little messy, far worse than the previous style. And a lot of outdated things are mixed up in them.

C + + name prefixes


The name of the inner layer


Name Separator


The outer name of the previous name


End of name


Function call is near mode


Call Convention __cdecl


return value type void


Parameter type int


End of parameter table


Indicates that this is a function

For explanations of these things, see calling_conventions

    • Http://www.agner.org/optimize/calling_conventions.pdf

    • Http://en.wikipedia.org/wiki/Name_mangling

    • Http://stackoverflow.com/questions/4667266/c-name-mangling-by-hand

    • http://labs.qt.nokia.com/2009/08/12/some-thoughts-on-binary-compatibility/

    • Http://developer.qt.nokia.com/wiki/toStdWStringAndBuiltInWchar_SimplifiedChinese


C + + ABI name change, compiler generation symbol study (QT for example)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.