- Implements R_X86_64_TPOFF32, R_X86_64_DTPOFF32 relocations.
- Implements PT_TLS header.
Details
Diff Detail
Event Timeline
If it's not a big amount of work, can you split PT_TLS and relocations in two different patches? If it is too much, forget about it.
Also, while I haven't reviewed his work very carefully, I think Michael Spencer is working on TLS as well, so I think you guys should coordinate to minimize the overlap.
I could split but just not sure how.
When I add some TLS data (variables) then R_X86_64_TPOFF32/R_X86_64_DTPOFF32 relocations are created and we need the size of TLS and its address to process them.
TLS info currently is calculated during headers creating.
At the same time TLS header will only present if we have some TLS data. And data means relocations.
So just not sure it is easy to split. Ideas are welcome.
ELF/Writer.cpp | ||
---|---|---|
736 | I agree. Its bulky now. |
ELF/Writer.cpp | ||
---|---|---|
612–642 | We don't need to handle the case of multiple disjoint TLS initialization blocks. The spec doesn't allow it. All this needs to do is add a phdr if it sees any allocated TLS section. | |
736 | http://reviews.llvm.org/D13615 provides a much simpler implementation of the layout. |
ELF/Writer.cpp | ||
---|---|---|
612–642 | This code not about multiple disjoints. I tried to reproduce the same behavior as ld do. There are 3 cases (first is cpp code, next is readelf output):
thread int i; Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x0000000000000168 0x0000000000000168 R E 200000 LOAD 0x0000000000000168 0x0000000000600168 0x0000000000600168 0x0000000000000004 0x0000000000000004 RW 200000 TLS 0x0000000000000168 0x0000000000600168 0x0000000000600168 0x0000000000000004 0x0000000000000008 R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 10 Section to Segment mapping: Segment Sections... 00 .text .eh_frame 01 .tdata 02 .tdata .tbss 03
__thread int a = 56; Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x0000000000000168 0x0000000000000168 R E 200000 LOAD 0x0000000000000168 0x0000000000600168 0x0000000000600168 0x0000000000000004 0x0000000000000004 RW 200000 TLS 0x0000000000000168 0x0000000000600168 0x0000000000600168 0x0000000000000004 0x0000000000000004 R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 10 Section to Segment mapping: Segment Sections... 00 .text .eh_frame 01 .tdata 02 .tdata 03
__thread int i; Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align LOAD 0x0000000000000000 0x0000000000400000 0x0000000000400000 0x0000000000000130 0x0000000000000130 R E 200000 TLS 0x0000000000000130 0x0000000000601000 0x0000000000601000 0x0000000000000000 0x0000000000000004 R 4 GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000 RW 10 Section to Segment mapping: Segment Sections... 00 .text .eh_frame 01 .tbss 02 As can be seen,
So output of my implementation is currently compietely equal to ld. |
TLS -> Tls