[lld] e597262 - [LLD] [COFF] Align all debug directories

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 10:51:23 PST 2020


Author: Peter Penzin
Date: 2020-11-02T10:47:51-08:00
New Revision: e59726220f3d1234b8cdecb906722b3ecc13cb77

URL: https://github.com/llvm/llvm-project/commit/e59726220f3d1234b8cdecb906722b3ecc13cb77
DIFF: https://github.com/llvm/llvm-project/commit/e59726220f3d1234b8cdecb906722b3ecc13cb77.diff

LOG: [LLD] [COFF] Align all debug directories

Match MSVC linker output - align all debug directories on four bytes,
while removing debug directory alignment. This would have the same
effect on CETCOMPAT support as D89919.

Chromium bug: https://crbug.com/1136664

Differential Revision: https://reviews.llvm.org/D89921

Added: 
    

Modified: 
    lld/COFF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index 534ea82dc3c2..344e83f41014 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -978,16 +978,15 @@ void Writer::createMiscChunks() {
   }
 
   if (config->cetCompat) {
-    ExtendedDllCharacteristicsChunk *extendedDllChars =
-        make<ExtendedDllCharacteristicsChunk>(
-            IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT);
-    debugRecords.push_back(
-        {COFF::IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS, extendedDllChars});
+    debugRecords.push_back({COFF::IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS,
+                            make<ExtendedDllCharacteristicsChunk>(
+                                IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT)});
   }
 
-  if (debugRecords.size() > 0) {
-    for (std::pair<COFF::DebugType, Chunk *> r : debugRecords)
-      debugInfoSec->addChunk(r.second);
+  // Align and add each chunk referenced by the debug data directory.
+  for (std::pair<COFF::DebugType, Chunk *> r : debugRecords) {
+    r.second->setAlignment(4);
+    debugInfoSec->addChunk(r.second);
   }
 
   // Create SEH table. x86-only.


        


More information about the llvm-commits mailing list