[lld] [llvm] [LLD][COFF] Add more variety of CET flags (PR #150761)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 28 03:36:51 PDT 2025


================
@@ -1237,10 +1239,31 @@ void Writer::createMiscChunks() {
     });
   }
 
+  uint16_t ex_characteristics_flags = 0;
   if (config->cetCompat) {
-    debugRecords.emplace_back(COFF::IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS,
-                              make<ExtendedDllCharacteristicsChunk>(
-                                  IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT));
+    ex_characteristics_flags |= IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT;
+  }
+  if (config->cetCompatStrict) {
+    ex_characteristics_flags |=
+        IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE;
+  }
----------------
mstorsjo wrote:

The braces around each of these `if (cond) flags |= FLAG;` is probably a bit superfluous. Earlier when this was one nontrivial multiline `debugRecords.emplace_back()`, the braces were good for readability though, but when this is a long list of repeated trivial if statements, it's probably nicer to reduce the number of lines spent on it (while potentially keeping them for the `debugRecords.emplace_back()` at the end).

https://github.com/llvm/llvm-project/pull/150761


More information about the llvm-commits mailing list