[PATCH] D133099: [LLD][COFF] Add load config checks to warn if incorrect for CFGuard

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 23:56:46 PDT 2022


mstorsjo added a comment.

This looks like a good idea IMO! Especially the check for the basic condition that `_load_config_used` must exist if this flag is enabled; I was surprised to see that you don't get any diagnostics for this combination today.

Other than that, the rest of the checks are certainly useful when implementing these things. (I didn't check all the details of what is verified.) On the other hand, since LLD is quite focused on performance, LLD omits pedantic checks of all inputs where it's relevant for performance (i.e. it's considered ok to not handle corrupted inputs cleanly) - but these checks shouldn't really have any performance impact I think, so they could be considered fine in that aspect.



================
Comment at: lld/COFF/Writer.cpp:2123
+  uint8_t *symBuf = secBuf + (b->getRVA() - sec->getRVA());
+  if (!isAligned(Align(config->is64() ? 8 : 4), b->getRVA()))
+    warn("'_load_config_used' may be misaligned (RVA is 0x" +
----------------
Do you think it would be worthwhile to check that the section chunk itself also has got the right alignment? Since even if the section doesn't flag the right required alignment, we can accidentally end up on a correctly aligned RVA anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133099



More information about the llvm-commits mailing list