[PATCH] D145962: [lld] Fill .text section gaps with INT3 only on x86 targets.

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 03:30:25 PDT 2023


mstorsjo added a subscriber: efriedma.
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

Thanks for the patch - I've consiered doing something about this at some time. At the time, I considered filling areas with a more specific pattern, mapping to trapping instructions similar to `int3`, but since it requires multibyte patterns instead of filling with a single byte, I never got to doing anything about it.

So, MS link.exe fills sections with zero? Is that a specific design choice (i.e. does it fill with `0xcc` on x86) or is it simply the case that link.exe doesn't try to fill sections with sentinel instructions at all?

Overall I guess this patch is fine with me - the previous pattern with `0xcc` doesn't seem to have mapped to any specific useful thumb/aarch64 instruction anyway (although I guess it's more likely that the previous one would have trapped, especially on aarch64 it seems to not be recognized by the disassembler) than this plain-zeros instruction.



================
Comment at: lld/test/COFF/gaps-fill.test:11
+# CHECK: 180001004: d65f03c0     ret
+# CHECK:                         ...
+# CHECK: 180001010: 52800040     mov     w0, #0x2
----------------
Is this a case where `llvm-objdump` prints just `...` for contiguous areas with plain zeros? (I guess that's primarily what this test should be looking for - it seems a bit odd that that checked aspect is so implicit here.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145962/new/

https://reviews.llvm.org/D145962



More information about the llvm-commits mailing list