[PATCH] D94329: [lld-macho] Fix TLV data initialization

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 8 13:38:43 PST 2021


thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Very nice!



================
Comment at: lld/MachO/InputSection.cpp:50
+        // References from thread-local variable sections are treated as offsets
+        // relative to the start of the first thread-local data section, instead
+        // of as absolute addresses.
----------------
fwiw I think of it as a single thread-local data memory area – it's kind of more like a segment than a section I suppose, and it implicitly consists of __DATA,__thread_data and __DATA,__thread_bss (and, per dyld code, everything in between -- which is why we don't want anything in between, since that'd uselessly waste memory)


================
Comment at: lld/MachO/InputSection.h:78
+  return sectionType(flags) == llvm::MachO::S_THREAD_LOCAL_ZEROFILL ||
+         sectionType(flags) == llvm::MachO::S_THREAD_LOCAL_REGULAR;
 }
----------------
very nit: swap order of ZEROFILL and REGULAR since REGULAR comes first in the TLV area in memory :)


================
Comment at: lld/MachO/Writer.cpp:566
+    // to minimize the amount of memory used. Additionally, since zerofill
+    // sections must be at the end of their segments, and since TLV data
+    // sections can be zerofills, we end up putting all TLV data sections at the
----------------
Are there zerofill sections in segments other than `__DATA`? `__DATA_CONST` I guess, but that can't be TLV. (I'm wondering about the plural "segments" here.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94329/new/

https://reviews.llvm.org/D94329



More information about the llvm-commits mailing list