.weak pseudo-op

Purpose

Declares a symbol to be a global symbol with weak binding.

Syntax

.weak Name [ , Visibility ]

Description

The .weak pseudo-op indicates that the symbol Name is a global symbol with weak binding, which can be referred to by other files at link time. The .extern, .globl, or .comm pseudo-op can also be used to make a global symbol.

Once the .weak pseudo-op has been used for a symbol, using the .globl, .extern, or .comm pseudo-op for the same symbol does not affect the symbol’s weak binding property.

The linker ignores duplicate definitions for symbols with weak binding. If a global symbol is not weak in one file, and is weak in other files, the global definition is used and the weak definitions are ignored. If all definitions are weak, the first weak definition is used.

The visibility of the weak symbol can be specified by using the Visibility parameter.

Parameters

Item Description
Name Declares Name as a global symbol with weak binding. Name can be a Qualname. (A Qualname specifies a Name and StorageMappingClass for the control section.)
Visibility Specifies the visibility of the symbol. Valid visibility values are exported, hidden, internal, and protected. Symbol visibilities are used by the linker.

Examples

The following example illustrates the use of the .weak pseudo-op:


.weak foo[RW]
.csect data[RW]