[elf2] Sort allocated TLS sections at the start of the R/W PT_LOAD.

Differential Revision: http://reviews.llvm.org/D13763

llvm-svn: 250572
This commit is contained in:
Michael J. Spencer
2015-10-16 23:11:07 +00:00
parent d6edce97fb
commit 1bf73000cf
2 changed files with 42 additions and 6 deletions

View File

@@ -317,6 +317,16 @@ static bool compareOutputSections(OutputSectionBase<ELFT> *A,
return BIsExec;
// If we got here we know that both A and B are in the same PT_LOAD.
// The TLS initialization block needs to be a single contiguous block in a R/W
// PT_LOAD, so stick TLS sections directly before R/W sections. The TLS NOBITS
// sections are placed here as they don't take up virtual address space in the
// PT_LOAD.
bool AIsTLS = AFlags & SHF_TLS;
bool BIsTLS = BFlags & SHF_TLS;
if (AIsTLS != BIsTLS)
return AIsTLS;
// The next requirement we have is to put nobits sections last. The
// reason is that the only thing the dynamic linker will see about
// them is a p_memsz that is larger than p_filesz. Seeing that it

View File

@@ -9,10 +9,21 @@
.text
_start:
.section h,""
.section g,"",@nobits
.section f,"aw",@nobits
.section e,"aw"
.section t,"x",@nobits
.section s,"x"
.section r,"w",@nobits
.section q,"w"
.section p,"wx",@nobits
.section o,"wx"
.section n,"",@nobits
.section m,""
.section l,"awx",@nobits
.section k,"awx"
.section j,"aw",@nobits
.section i,"aw"
.section g,"awT",@nobits
.section e,"awT"
.section d,"ax",@nobits
.section c,"ax"
.section b,"a",@nobits
@@ -22,7 +33,22 @@ _start:
// CHECK: Name: b
// CHECK: Name: c
// CHECK: Name: d
// TLS sections are only sorted on NOBITS.
// CHECK: Name: e
// CHECK: Name: f
// CHECK: Name: h
// CHECK: Name: g
// CHECK: Name: i
// CHECK: Name: j
// CHECK: Name: k
// CHECK: Name: l
// Non allocated sections are in input order.
// CHECK: Name: t
// CHECK: Name: s
// CHECK: Name: r
// CHECK: Name: q
// CHECK: Name: p
// CHECK: Name: o
// CHECK: Name: n
// CHECK: Name: m