I am trying to use thread-local storage in a SYS/BIOS project. I am hoping that "thread-local" storage would be implemented as "task-local" storage in the SYS/BIOS environment.
I use the SYS/BIOS > TI Target Examples > Minimal project template, and the ti.platforms.evm6657 platform. I then add two lines to the default main.c, shown below in bold.
...
Void taskFxn(UArg a0, UArg a1)
{
System_printf("enter taskFxn()\n");
Task_sleep(10);
System_printf("exit taskFxn()\n");
}
__thread unsigned int gInt = 0;
/*
* ======== main ========
*/
Int main()
{
/*
* use ROV->SysMin to view the characters in the circular buffer
*/
System_printf("enter main()\n");
gInt = 1;
BIOS_start(); /* does not return */
return(0);
}
I get the following build warnings:
- #10015-D output file "Tls_sysbios_proj.out" cannot be loaded and run on a target system
- #10247-D creating output section ".tdata" without a SECTIONS specification
- #10247-D creating output section ".TI.tls_init" without a SECTIONS specification
- #17003-D relocation from function "main" to symbol "gInt" overflowed; the 22-bit relocated address 0x202f43 is too large to encode in the 15-bit unsigned field (type = 'R_C6000_TPR_U15_W' (40), file = "./main.obj", offset = 0x00000060, section = ".text")
I can add a .tdata section to the default app.cfg > Program > Sections, but doing so does not resolve the warning.
Similarly adding a .TI.tls_init section does not resolve the warning, and adds an additional warning (xdc.cfg.Program.SectionSpec#1 : Entry for the section '.TI.tls_init' in Program.sectMap is set to 'undefined'. This section allocation will be ignored).
I tried experimenting by marking the gInt as a far variable, but that did not help.
If instead of the SYS/BIOS template, I use Empty Projects > Empty Project (with main.c), and I add the two lines related to the thread-local storage variable, it will build the executable with only two warnings
- #10247-D creating output section ".tdata" without a SECTIONS specification
- #10247-D creating output section ".TI.tls_init" without a SECTIONS specification
If I add the .tdata and .TI.tls_init sections to the linker command file, the .TI.tls_init warning goes away, but the .tdata warning remains.
So my question is, how do I use thread-local storage, as implemented via the __thread qualifier, on a SYS/BIOS project?
c6655, SYS/BIOS 6.42.1.20, cgt 8.1.0, CCS 6.1.1.00022
Thanks.