This (at least roughly?) seems to match how link.exe sets it.
Details
Diff Detail
Event Timeline
Does link.exe set this flag if there are no handlers in .sxdata? This flag seems like it was added as a way to mark DLLs that don't have _load_config_used as not having any exception handlers for /safeseh. Maybe we should just set this flag implicitly if there were no handlers in .sxdata and _load_config_used never resolved.
It doesn't seem so - a plain C hello world exe won't have it set.
This flag seems like it was added as a way to mark DLLs that don't have _load_config_used as not having any exception handlers for /safeseh. Maybe we should just set this flag implicitly if there were no handlers in .sxdata and _load_config_used never resolved.
If we choose to do that, we'd need to make this a no-op flag in the mingw driver instead - I've just run across some code that seems to set this flag (for unknown reasons).
Well, it will link the CRT, which has _except_handler4. You would need to make a no CRT test case and check that. It's probably simplest with a DLL with a custom entry point. You can also use llvm-readobj -coff-load-config to see that it doesn't have a load config directory.
This flag seems like it was added as a way to mark DLLs that don't have _load_config_used as not having any exception handlers for /safeseh. Maybe we should just set this flag implicitly if there were no handlers in .sxdata and _load_config_used never resolved.
If we choose to do that, we'd need to make this a no-op flag in the mingw driver instead - I've just run across some code that seems to set this flag (for unknown reasons).
Makes sense.
So I guess this would make sense and match link.exe. Do you happen to know how this relates to SEH based exception handling in (GCC based) MinGW btw? When I build an executable (or DLL) with mingw-gcc that has SEH exceptions, llvm-readobj -coff-load-config doesn't show anything at all for such a binary. So if we were to link such binaries with LLD (which I don't do yet because libcxxabi lacks support for SEH), wouldn't we end up setting this flag for them as well?
Split out the MinGW part, made it set the flag automatically based on Reid's suggestion.
I suspect that this flag is only meaningful for x86 images, and we should only ever set it for x86 images that have no exception handlers and no load config. GCC's SEH support is x64-only, so this should never interfere with that.
Can you confirm that this is consistent with MSVC? If so, looks good!
COFF/Writer.cpp | ||
---|---|---|
692 | nit: I'd test the Machine first to short-circuit out of the symbol lookup for x64. |
Yes, confirmed that MSVC only sets it on x86.
COFF/Writer.cpp | ||
---|---|---|
692 | Will do before pushing. |
nit: I'd test the Machine first to short-circuit out of the symbol lookup for x64.