[PATCH] [lld][ELF] Add static TLS support.
Sean Silva
silvas at purdue.edu
Wed Jan 30 13:22:43 PST 2013
================
Comment at: lib/ReaderWriter/ELF/DefaultLayout.h:75-76
@@ -74,2 +74,4 @@
ORDER_BSS = 210,
+ ORDER_TLSDATA = 215,
+ ORDER_TLSBSS = 216,
ORDER_OTHER = 220,
----------------
Michael Spencer wrote:
> Shankar Kalpathi Easwaran wrote:
> > I see that gnu ld / gold puts .tdata/.tbss before .data, why are you ordering it differently ?
> >
> > $cat t.c
> > __thread int a = 10;
> > __thread int b = 20;
> > __thread int f;
> > __thread int g;
> > int initdata = 10;
> > int bssdata;
> >
> > int main()
> > {
> > return 0;
> > }
> >
> > $gcc -c t.c
> > $gold t.o
> > $readelf -S a.out
> > There are 12 section headers, starting at offset 0x2ac:
> >
> > Section Headers:
> > [Nr] Name Type Addr Off Size ES Flg Lk Inf Al
> > [ 0] NULL 00000000 000000 000000 00 0 0 0
> > [ 1] .text PROGBITS 080480b4 0000b4 00000a 00 AX 0 0 4
> > [ 2] .eh_frame PROGBITS 080480c0 0000c0 000038 00 A 0 0 4
> > [ 3] .tdata PROGBITS 080490f8 0000f8 000008 00 WAT 0 0 4
> > [ 4] .tbss NOBITS 08049100 000100 000008 00 WAT 0 0 4
> > [ 5] .data PROGBITS 08049100 000100 000004 00 WA 0 0 4
> > [ 6] .bss NOBITS 08049104 000104 000004 00 WA 0 0 4
> > [ 7] .comment PROGBITS 00000000 000104 00002b 01 MS 0 0 1
> > [ 8] .note.gnu.gold-ve NOTE 00000000 000130 00001c 00 0 0 4
> > [ 9] .symtab SYMTAB 00000000 00014c 0000c0 10 10 2 4
> > [10] .strtab STRTAB 00000000 00020c 00003b 00 0 0 1
> > [11] .shstrtab STRTAB 00000000 000247 000063 00 0 0 1
> > Key to Flags:
> > W (write), A (alloc), X (execute), M (merge), S (strings)
> > I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
> > O (extra OS processing required) o (OS specific), p (processor specific)
> >
> I'll fix. I see how they are handling it now. Note that they are still going to get separate LOAD segments currently because we don't have a way to say that .tbss should be ignored in the LOAD segment, but not the TLS segment.
> I see how they are handling it now.
If you are seeing these things by experimenting with their behavior, you can instead just read it off the relevant default linker script in `/usr/lib/ldscripts/`. E.g. for the default ldscript for x86_64 ELF executables on my machine (`elf_x86_64.x`), you can just read off:
```
.tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
.tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
[...snip...]
.data :
{
*(.data .data.* .gnu.linkonce.d.*)
SORT(CONSTRUCTORS)
}
```
http://llvm-reviews.chandlerc.com/D351
More information about the llvm-commits
mailing list