This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++] GCC tree linkage types


Chris Lattner <sabre@nondot.org> writes:

> In LLVM, we currently have the following linkage types:
> 
> * internal linkage (ie, static)
> * linkonce (globals which merge when linking, but can be deleted from a
>   translation unit if they are not used, basically like 'extern inline').

I would normally say that linkonce means that all but one copy can be
deleted.  It may be that the way gcc uses linkonce ensures that it is
OK to delete all copies, but it is logically possible to make a global
constructor linkonce, and it would not be OK to delete that even if
nothing referred to it.

> * weak (like linkonce, but cannot be deleted if they are unused in a
>   xlation unit)

I wouldn't say that weak symbols merge; I would say that weak symbols
are hidden by strong symbols, or by earlier weak symbols.

> * external (normal strong, externally visible symbol)
> 
> Is there anything wrong with this classification of linkage types?  Is
> there something we are missing?

You didn't mention common symbols, which really do merge.  Even g++
can generate common symbols when using the -fconserve-space option.

The GNU linker supports more exotic linkage types like `indirect',
`warning', and `set'.  But these are probably not of interest to the
compiler.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]