[PATCH] D84701: [LLD] [MinGW] Implement the --no-seh flag

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 27 22:29:51 PDT 2020


mstorsjo added inline comments.


================
Comment at: lld/COFF/Writer.cpp:1396
     pe->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY;
-  if (setNoSEHCharacteristic)
+  if (setNoSEHCharacteristic || config->noSEH)
     pe->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_NO_SEH;
----------------
amccarth wrote:
> Should `setNoSEHCharacteristic` and `config->noSEH` always agree?  What happens when they don't?
> 
> `setNoSEHCharacteristic` is set in `Writer::createSEHTable` when there are no SEH handlers.  Should this logical-OR happen there?
> 
> What happens if the user chooses `--noSEH` but there are SEH handlers?
> Should `setNoSEHCharacteristic` and `config->noSEH` always agree?  What happens when they don't?
> 
> `setNoSEHCharacteristic` is set in `Writer::createSEHTable` when there are no SEH handlers.  Should this logical-OR happen there?

We generally don't want to call `createSEHTable` in mingw mode. That function errors out on any input object file without the `@feat` marker indicating support for safe SEH (which happens for e.g. most handwritten mingw asm sources).

In practice, that doesn't happen as the safeseh option defaults to false in mingw mode, and the lld-link level `/safeseh` option isn't set by any mingw driver option (unless it's given `-Xlink=/safeseh` to manually set lld-link level options from the mingw driver).

> What happens if the user chooses `--noSEH` but there are SEH handlers?

In that case, the image could end up lying about this aspect.

Mingw mode compilers don't use SEH at all in i386 mode at the moment though, so the mingw driver level `--no-seh` flag should be pretty safe for users. And it matches what GNU ld does in this case; if the option is set, the capability flag is set, without verification.

For msvc mode users, the lld-link level `/noseh` option that is added here is undocumented and private, and thus not meant to be used by users directly - only by the mingw driver.


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

https://reviews.llvm.org/D84701



More information about the llvm-commits mailing list