[PATCH] D44943: Fill the last page of each executable section with 0xcc or equivalent.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 28 03:56:13 PDT 2018


grimar added inline comments.


================
Comment at: lld/ELF/Writer.cpp:2202
+    if ((Sec->Offset + Sec->Size) % Target->PageSize == 0)
+      continue;
+
----------------
Does it really make sense to optimize here? If so, then probably my patch was better,
since it writes fewer bytes and is more straightforward. 
If no (and I expect it is the case), then I would remove the check to simplify the code,
writing few more pages should not be slow.


================
Comment at: lld/ELF/Writer.cpp:2204
+
+    assert(sizeof(Target->TrapInstr) == sizeof(int));
+    memset(Buf + alignDown(Sec->Offset + Sec->Size, Target->PageSize),
----------------
I do not think it is the correct assertion.
`memset` has `int value` argument, though the description is:
`The value is passed as an int, but the function fills the block of memory
using the unsigned char conversion of this value.`

So I think what you want to check here that all bytes of TrapInstr are the same.
Btw, that is true for all targets atm. What about landing D44979 then and removing the assert?


https://reviews.llvm.org/D44943





More information about the llvm-commits mailing list