Merge pull request #267 from 64/alignment

rtdl: Permit TLS alignments greater than 16 bytes
This commit is contained in:
Alexander van der Grinten 2021-05-10 20:29:17 +02:00 committed by GitHub
commit a570ef712d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -712,6 +712,8 @@ Tcb *allocateTcb() {
auto td_buffer = getAllocator().allocate(td_size);
memset(td_buffer, 0, td_size);
__ensure((reinterpret_cast<uintptr_t>(td_buffer) & (tlsMaxAlignment - 1)) == 0);
Tcb *tcb_ptr = nullptr;
if constexpr (tlsAboveTp) {
@ -1047,8 +1049,6 @@ void Loader::_buildTlsMaps() {
object->tlsIndex = runtimeTlsMap->indices.size();
runtimeTlsMap->indices.push_back(object);
__ensure((16 & (object->tlsAlignment - 1)) == 0);
object->tlsModel = TlsModel::initial;
if constexpr (tlsAboveTp) {
@ -1097,7 +1097,6 @@ void Loader::_buildTlsMaps() {
// There are some libraries (e.g. Mesa) that require static TLS even though
// they expect to be dynamically loaded.
if(object->haveStaticTls) {
__ensure((16 & (object->tlsAlignment - 1)) == 0);
auto ptr = runtimeTlsMap->initialPtr + object->tlsSegmentSize;
size_t misalign = ptr & (object->tlsAlignment - 1);
if(misalign)