8.6.8 Warn-common Option
--warn-common
option warns when a
common symbol is combined with another common symbol or with a symbol definition.
This option allows you to find potential problems from combining global symbols.
There are three kinds of global symbols, illustrated here by C
examples:int i = 1;
extern int i;
int i;
A common symbol. If there are only (one or more) common symbols for a variable, it goes in the uninitialized data area of the output file.
The linker merges multiple common symbols for the same variable into a single symbol. If they are of different sizes, it picks the largest size. The linker turns a common symbol into a declaration, if there is a definition of the same variable.
The --warn-common
option can produce five kinds of warnings. Each warning consists of a pair of lines: the first describes the symbol just encountered, and the second describes the previous symbol encountered with the same name. One or both of the two symbols will be a common symbol.
file(section): warning: common of ‘symbol’ overridden by definition
file(section): warning: defined here
file(section): warning: definition of ‘symbol’ overriding common
file(section): warning: common is here
file(section): warning: multiple common of ‘symbol’
file(section): warning: previous common is here
file(section): warning: common of ‘symbol’ overridden by larger common
file(section): warning: larger common is here
file(section): warning: common of ‘symbol’ overriding smaller common
file(section): warning: smaller common is here