pub enum Linkage {
External,
Internal,
Weak,
LinkOnce,
Common,
}Expand description
How a symbol is seen outside the object it is defined in.
The set is the one C needs and no more. C++ vague linkage and the ODR variants are not here because nothing produces them.
Variants§
External
Defined here and visible to every other object. The default, and what a plain definition at file scope gets.
Internal
Defined here and invisible outside it, which is what static at file scope means.
Weak
Defined here, visible, and allowed to be replaced by a strong definition elsewhere.
__attribute__((weak)). A reference to one that nothing defines is a null address
rather than a link error.
LinkOnce
Defined here, visible, and allowed to be identical to a definition in another object,
with one of them kept and the rest discarded. What extern inline under the GNU
semantics and a compiler-generated helper get.
Common
A tentative definition, which the linker merges with any other tentative definition of
the same name and any real definition. int x; at file scope under -fcommon.
Implementations§
Source§impl Linkage
impl Linkage
Sourcepub const fn is_local(self) -> bool
pub const fn is_local(self) -> bool
Whether the symbol is invisible outside this object, so that a pass may rewrite every use of it because it can see every use of it.
Sourcepub const fn may_be_replaced(self) -> bool
pub const fn may_be_replaced(self) -> bool
Whether the definition here may lose to one in another object at link time.
The optimizer must not fold a use against the definition it can see when this is true, because the definition that wins may be a different one.