SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
A weak symbol definition is a valid definition, but the definition is discarded in favor of a non-weak definition if such a definition is found at link time. You can define weak symbols C/C++ or in the linker command file.
In C/C++, define a weak symbol as follows:
__attribute__((weak)) int bar;
In a linker command file, use an assignment expression outside a MEMORY or SECTIONS directive to define a linker-defined symbol. To define a weak symbol in a linker command file, use the "weak" operator in an assignment expression to designate that the symbol as eligible for removal from the output file's symbol table if the symbol is not referenced. For example, you can define "ext_addr_sym" as follows:
weak(ext_addr_sym) = 0x12345678;
When the linker command file is used to perform the final link, "ext_addr_sym" is presented to the linker as a weak absolute symbol. This symbol is not included in the resulting output file if the symbol is not referenced.