C++ function name demangling: What does this name suffix mean?

北慕城南 提交于 2020-01-23 01:39:31

问题


When I disassemble the Chromium binary I notice there are functions named in this pattern: _ZN6webrtc15DecoderDatabase11DecoderInfoD2Ev.part.1

If I give this string to c++filt, the output is webrtc::DecoderDatabase::DecoderInfo::~DecoderInfo() [clone .part.1]

So what does this .part.1 suffix really mean? If it indicates there are multiple copies of the same function, why do they need that? Is it due to the requirement of being position independent? I used g++ as the compiler.


回答1:


It indicates that destructor was the target of a partial inlining optimization by GCC. With this optimization the function is only partially inlined into another function, the remainder gets emitted into its own partial function. Since this new partial function doesn't implement the complete function it's given a different name, so it can exist beside a definition of the complete function if necessary.

So for example it appears that DecoderDatabase::DecoderInfo::~DecoderInfo is defined like this:

DecoderDatabase::DecoderInfo::~DecoderInfo() {
    if (!external) delete decoder;
}

My guess is that delete decoder invokes a long series of operations, too long to be inlined into another function. The optimizer would accordingly split those operations into a partial function. It would then only inline the if (!external) part of the function into other functions.



来源:https://stackoverflow.com/questions/31683913/c-function-name-demangling-what-does-this-name-suffix-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!