[lld] [lld][COFF] Fill only gaps in code sections. (PR #72138)

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 04:01:50 PST 2023


================
@@ -2021,8 +2021,16 @@ void Writer::writeSections() {
     // instead of leaving as NUL bytes (which can be interpreted as
     // ADD instructions).
     if ((sec->header.Characteristics & IMAGE_SCN_CNT_CODE) &&
-        (ctx.config.machine == AMD64 || ctx.config.machine == I386))
-      memset(secBuf, 0xCC, sec->getRawSize());
+        (ctx.config.machine == AMD64 || ctx.config.machine == I386)) {
+      uint32_t prevEnd = 0;
+      for (Chunk *c : sec->chunks) {
----------------
mstorsjo wrote:

I think it'd be nice to leave a comment here, saying what this does. E.g. something like this? "Only fill the gaps between chunks. Most chunks overwrite it anyway, but uninitialized data chunks merged into a code section don't."

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


More information about the llvm-commits mailing list