It doesn't make sense on ARM and using default 0 fill is compatible with MSVC.
(It's more noticeable ARM64EC targets, where additional padding mixed with alignment is used for entry thunk association, so there are more gaps).
Differential D145962
[lld] Fill .text section gaps with INT3 only on x86 targets. jacek on Mar 13 2023, 10:15 AM. Authored by
Details It doesn't make sense on ARM and using default 0 fill is compatible with MSVC. (It's more noticeable ARM64EC targets, where additional padding mixed with alignment is used for entry thunk association, so there are more gaps).
Diff Detail
Event TimelineComment Actions 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 Actions Thanks for the review. It seems to be a design choice: link.exe does fill with 0xcc on x64. I will add a test case for x64. FWIW, in on ARM64EC it's a bit more complicated, because we may have both x64 and true ARM64EC code linked together in a single module. Both use the same section (although according to my testing, never the same page, thus even more potential gaps). In theory, it could make sense to use 0xcc fill for x64 parts, but that's not what link.exe does: it uses 0 to fill everything.
Comment Actions LGTM, thanks! Ok, thanks for confirming!
Yeah that sounds more complex. I guess as you say, it could be possible to do varying filling, but that sounds quite complex, so I guess they've just haven't gone out of their way to implement that.
|
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.)