[COFF] Implement /safeseh:no and check @feat.00 flags by default
authorReid Kleckner <rnk@google.com>
Tue, 16 Jul 2019 18:17:33 +0000 (18:17 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 16 Jul 2019 18:17:33 +0000 (18:17 +0000)
commitfe44a531e0e2aba07213442b1930369316a112b0
tree81ab71660ce8f300a4075bec5013060def3a6409
parent35c96598b1246ea038677d7c4580f3c758ff1d93
[COFF] Implement /safeseh:no and check @feat.00 flags by default

Summary:
Fixes PR41828. Before this, LLD always emitted SafeSEH chunks and
defined __safe_se_handler_table & size. Now, /safeseh:no leaves those
undefined.

Additionally, we were checking for the safeseh @feat.00 flag in two
places: once to emit errors, and once during safeseh table construction.
The error was set up to be off by default, but safeseh is supposed to be
on by default. I combined the two checks, so now LLD emits an error if
an input object lacks @feat.00 and safeseh is enabled. This caused the
majority of 32-bit LLD tests to fail, since many test input object files
lack @feat.00 symbols. I explicitly added -safeseh:no to those tests to
preserve behavior.

Finally, LLD no longer sets IMAGE_DLL_CHARACTERISTICS_NO_SEH if any
input file wasn't compiled for safeseh.

Reviewers: mstorsjo, ruiu, thakis

Reviewed By: ruiu, thakis

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D63570

llvm-svn: 366238
32 files changed:
lld/COFF/Config.h
lld/COFF/Driver.cpp
lld/COFF/Writer.cpp
lld/test/COFF/allow-unknown-debug-info.test
lld/test/COFF/constant.test
lld/test/COFF/def-export-stdcall.s
lld/test/COFF/delayimports32.test
lld/test/COFF/dllexport.s
lld/test/COFF/entry-drectve.test
lld/test/COFF/entry-inference332.test
lld/test/COFF/exclude-all.s
lld/test/COFF/export-all.s
lld/test/COFF/export-stdcall.s
lld/test/COFF/export32.test
lld/test/COFF/fixed.test
lld/test/COFF/gfids-relocations32.s
lld/test/COFF/hello32.test
lld/test/COFF/largeaddressaware.test
lld/test/COFF/loadcfg32.test
lld/test/COFF/locally-imported32.test
lld/test/COFF/machine.test
lld/test/COFF/no-ipi-stream.test
lld/test/COFF/order-i386.test
lld/test/COFF/pdb-debug-f.s
lld/test/COFF/pdb-lib.s
lld/test/COFF/pdb-safeseh.yaml
lld/test/COFF/pdb-unknown-subsection.s
lld/test/COFF/reloc-x86.test
lld/test/COFF/safeseh-no.s [new file with mode: 0644]
lld/test/COFF/subsystem-drectve.test
lld/test/COFF/subsystem-inference32.test
lld/test/COFF/tls32.test