SPRUI03E June 2015 – January 2023
Create a Common Symbol
.farcommon symbol,size in bytes[, alignment]
.farcommon symbol,structure tag[, alignment]
.nearcommon symbol,size in bytes[, alignment]
.nearcommon symbol,structure tag[, alignment]
The .farcommon and .nearcommon directives create a common symbol in a common block, rather than placing variables in a section. The .farcommon directive places the symbol in far memory, and the .nearcommon directive places the symbol in near memory.
A common symbol cannot be created for a symbol that has a memory bank specification, for example because the DATA_MEM_BANK pragma was used to align the variable.
These directives are used by the compiler when the --common option is enabled (the default), which causes uninitialized file scope variables to be emitted as common symbols. The benefit of common symbols is that generated code can remove unused variables that would otherwise increase the size of the .bss section. (Uninitialized variables of a size larger than 32 bytes are separately optimized through placement in separate subsections that can be omitted from a link.) This optimization happens for C/C++ code by default unless you use the --common=off compiler option.