Am Sun, 22 Dec 2013 02:01:09 +0000 schrieb "Mike" <n...@none.com>:
> I need to make a startup procedure for my ARM Cortex-M platform. > In C/C++ this includs copying the .data segment to RAM and > initializing the .bss segment to 0. > > If I declare global variables in D as... > > __gshared int GlobalDataVar = 2; > __gshared int GlobalBssVar; > > ... these get put in .data and .bss respectively, and I know what > to do in my startup procedure: > > However if I declare thread local variables in D as... > > int TLSDataVar = 1; > int TLSBssVar; > > ... two symbols for each variable are created: one in the section > ".rodata.__emutls_t" and the other in section ".data.__emutls_v" > > minlibd's linker script > (https://bitbucket.org/timosi/minlibd/src/c4503befb556ff3edf04eeb63c384e0ea723a6aa/tools/ldscript4?at=default) > > does not deal with these sections, I'm assuming because my > version of GDC (yesterday's 4.8.2 backport {Thanks Johannes}) has > changes for supporting emulated TLS. > > My GDC is configured with --disable-tls and --disable-threads, so > I believe I could treat these the same as __gshared variables, > but I need to first understand what these sections are and what > they contain. > > I know this may be more specific to GCC than GDC, but if you know > something about these sections, please let me know, or point me > to some resource that will help me understand them. > > Thanks, > Mike I wrote a long answer here and managed to crash the newsreader before it was sent so here's a short summary: The emutls code is here: https://github.com/D-Programming-GDC/GDC/blob/master/libphobos/libdruntime/gcc/emutls.d The compiler calls __emutls_get_address, every symbol gets a emutls_object_t. If you have only one thread you could to reimplement emutls.d to avoid dynamic allocation. But the better solution is probably to add a --single-thread-only option to GDC which rewrites TLS variables to normal variables.