Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 301
uraj Avatar asked Feb 10 '23 10:02

uraj


1 Answers

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.

like image 187
Ross Ridge Avatar answered Feb 16 '23 02:02

Ross Ridge