[lld] [LLD][COFF] Set __guard_flags to CF_INSTRUMENTED if any object is instrumented (PR #115374)

via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 01:01:07 PST 2024


alvinhochun wrote:

Just speculating here without having tested the patch: I'm not sure if this is fine for llvm-mingw, which builds mingw-w64 with CFG. It looks like this patch would effectively set `CF_INSTRUMENTED` on all binaries built with llvm-mingw even if the user hasn't asked for it. In mingw-w64 CRT (and by extension ucrt/msvcrt) there may be functions that calls function pointers to user code (`.ctors`/`.dtors` are probably some of them, maybe `atexit` handlers too), which may trip CFG if calling functions from object files not built with `-mguard=cf`.

Though LLD may have some fallbacks to heuristically add functions to the list of valid call targets. I don't know, maybe it is possible to craft some object files in assembly that would trip CFG? I recall there being a problem with OpenSSL that enabling CFG with llvm-mingw will crash when calling into some objects built with NASM.


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


More information about the llvm-commits mailing list