This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by Bigcheese on Oct 14 2015, 8:21 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

Bigcheese updated this revision to Diff 37442.Oct 14 2015, 8:21 PM
Bigcheese retitled this revision from to [lld][elf2] Sort allocated TLS sections at the start of the R/W PT_LOAD..
Bigcheese updated this object.
Bigcheese added reviewers: rafael, ruiu.
Bigcheese added a subscriber: llvm-commits.
emaste added a subscriber: emaste.Oct 15 2015, 7:43 AM
ruiu added inline comments.Oct 15 2015, 10:05 AM
ELF/Writer.cpp
300–302 ↗(On Diff #37442)

It sounds like a compiler bug if it emits .tbss or .tdata without the writable bit. Do we actually care about this case?

303 ↗(On Diff #37442)

(AFlags & SHF_TLS) && (AFlags & SHF_ALLOC)

Bigcheese marked an inline comment as done.Oct 15 2015, 11:55 AM
Bigcheese added inline comments.
ELF/Writer.cpp
300–302 ↗(On Diff #37442)

There's assembly. It also makes layout a bit simpler, as you can assume all TLS sections are together, and there's no good reason to reject it.

ruiu added inline comments.Oct 15 2015, 12:06 PM
ELF/Writer.cpp
300–302 ↗(On Diff #37442)

That's still a user code bug, no? I'm not convinced unless it is very prevalent issue that we had to take care of this specially.

rafael edited edge metadata.Oct 16 2015, 12:30 PM

Also please remove the "don't care" sections from the test:

.section v,"T",@nobits
.section u,"T"
section h,"aT",@nobits
.section f,"aT"

We only really care how we sort tls sections that are aw

ELF/Writer.cpp
327 ↗(On Diff #37442)

Move this past the comment

// If we got here we know that both A and B are in the same PT_LOAD.

In summary, this is what I think we should do.

This revision was automatically updated to reflect the committed changes.