[PATCH] D52749: [LLD][COFF] Fix CRT global initializers

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 2 09:10:00 PDT 2018


aganea added inline comments.


================
Comment at: COFF/Writer.cpp:1605
+        case 1:
+          return false;
+        case 0:
----------------
mstorsjo wrote:
> mstorsjo wrote:
> > Won't this override the internal ordering based on the section name suffixes like .CRT$ABC?
> Or what actually does `getBufferIdentifier()` return - the name of the object file? In that case I'd say this is wrong. If it returns the section name it might be ok...
@mstorsjo `getBufferIdentifier()` indeed returns the file name. However at this point, chunks were already grouped by specific section. Meaning that this function will sort only, say, `.CRT$XCU` chunks at once. Internal TU order is guaranteed by the test below (`return SA->SectionNumber < SB->SectionNumber;`)

The only side-effect I could see is that this change makes **deterministic **initialization of global initializers (which in this case, means the TUs will be called in lexicographic order, based on their relative/absolute path and filename). The C++ std says the behavior is "indefinite", but this makes it "definite", at least for LLD. What is your stance on this? @ruiu @zturner @pcc @rnk 


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D52749





More information about the llvm-commits mailing list