-
Bug
-
Resolution: Fixed
-
Medium
-
Code Generation Tools
-
CODEGEN-12362
-
-
-
default
-
Avoid using attribute(persistent) with lfu attribute(preserve)
During an lfu compile/link, for variables with attribute(preserve), the linker incorrectly combines sections with initialized variables with sections for variables that have attribute(persistent).
This could result in the persistent variable being incorrectly initialized at restart.
This may generate an error like below:
<Linking> error #10367-D: output section ".TI.bound:gvar_pre_init" cannot mix noinit sections with sections that require initialization. NOINIT sections: - .TI.bound:gvar_pre_pers:test.obj Sections not specified as NOINIT: - .TI.bound:gvar_pre_init:test.obj error #10010: errors encountered during linking; "test.out" not built
Note: for CLA, initializing global/static data is not supported.
Example with C code and map files.
For lfu attributes preserve/update with attributes noinit/persistent:
__attribute__((preserve)) int gvar_pre_init = 200; __attribute__((preserve)) __attribute__((persistent)) int gvar_pre_pers = 100; __attribute__((preserve)) __attribute__((noinit)) int gvar_pre_noinit;
Current incorrect behavior: "preserve" variable gvar_pre_init is incorrectly combined into a section with "preserve"/"persistent" variable gvar_pre_pers.
.TI.bound:gvar_pre_init * 0 0000013d 00000003 UNINITIALIZED 0000013d 00000001 test.obj (.TI.bound:gvar_pre_init) 0000013e 00000001 --HOLE-- 0000013f 00000001 test.obj (.TI.bound:gvar_pre_pers)
With the fix, above 2 "preserve" variables are in separate sections.
.TI.bound:gvar_pre_init * 0 0000013d 00000001 UNINITIALIZED 0000013d 00000001 test.obj (.TI.bound:gvar_pre_init) .TI.bound:gvar_pre_pers * 0 0000013f 00000001 0000013f 00000001 test.obj (.TI.bound:gvar_pre_pers)