[PATCH] D52053: [LLD] [COFF] Provide __CTOR_LIST__ and __DTOR_LIST__ symbols for MinGW

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 14 11:03:18 PDT 2018


ruiu added inline comments.


================
Comment at: COFF/Chunks.h:483
+public:
+  // This does a deep copy of the provided data.
+  CustomDataChunk(const std::vector<uint8_t> &Data, int A) : Data(Data) {
----------------
... but should be okay since the data is small?

If so, I'd add that to the comment.


================
Comment at: COFF/Writer.cpp:1392
 
+// MinGW specific.
+void Writer::insertCtorDtorSymbols() {
----------------
I'd explain the structure of .ctors and .dtors here. E.g. They have to start with a null pointer and end with a (void *)-1, so we add these sentinels in this function.


================
Comment at: COFF/Writer.cpp:1408
+  // The lists start with an (uintptr_t)-1 and end with an (uintptr_t)0.
+  CustomDataChunk *CtorListHead = make<CustomDataChunk>(AllOnes, PtrSize);
+  CustomDataChunk *CtorListEnd = make<CustomDataChunk>(AllZeros, PtrSize);
----------------
Looks like CustomDataChunk is a bit over-designed, because we are using it only to represent a single-word data chunk. Instead of generalizing it, you could define a chunk that takes an integer and handle it as a pointer-size data. Then you can eliminate std::vector from this function.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D52053





More information about the llvm-commits mailing list