开发者

What is a 'linkonce' section

开发者 https://www.devze.com 2023-02-21 04:12 出处:网络
What is a \'linkonce\' section, and for extra kudos how does it differ from a comdat section? To be clear, I\'m familiar with how comdat sections work, how they\'re used, e开发者_Go百科tc.In googling

What is a 'linkonce' section, and for extra kudos how does it differ from a comdat section?

To be clear, I'm familiar with how comdat sections work, how they're used, e开发者_Go百科tc. In googling, linkonce is almost exclusively discussed in forums where it's assumed the meaning/intent/purpose of that section is already fairly well understood.


https://gcc.gnu.org/legacy-ml/gcc/2003-09/msg00984.html seems to discuss this very thing.

According to that thread, COMDAT is a bit more nebulous in the sense that there's no single correct/standard definition of what constitutes a true COMDAT implementation. g++'s linkonce is /an/ implementation of the concept.

In the COMDAT implementations used by MSVC++ and Wind River's 'diab' compiler, their implementations of COMDAT allow it to remove unused sections; eg, if main.cpp links against foo.cpp, the main binary can exclude any COMDAT sections from foo.o if the section is not referenced.

I'm uncertain whether this type of folding is applied to the g++ linkonce sections, but it seems logical.

0

精彩评论

暂无评论...
验证码 换一张
取 消