The RETAIN pragma can be applied to a code or data symbol.
In EABI mode, which assumes that all sections are eligible for removal via conditional linking, this pragma causes a .retain directive to be generated into the section that contains the definition of the symbol. The .retain directive indicates to the linker that the section is ineligible for removal during conditional linking. Therefore, regardless whether or not the section is referenced by another section in the application that is being compiled and linked, it will be included in the output file result of the link.
In COFF mode, which assumes that all sections are ineligible for removal, the RETAIN pragma prevents the compiler from issuing a .clink directive for a symbol.
The RETAIN pragma has the same effect as using the retain function or variable attribute. See Section 6.16.2 and Section 6.16.3, respectively.
The syntax of the pragma in C is:
#pragma RETAIN ( symbol ) |
The syntax of the pragma in C++ is:
#pragma RETAIN |
The CLINK pragma has the opposite effect of the RETAIN pragma and is used only in COFF mode. See Section 6.10.3 for more details.