Index: lld/trunk/COFF/Writer.cpp =================================================================== --- lld/trunk/COFF/Writer.cpp +++ lld/trunk/COFF/Writer.cpp @@ -688,6 +688,9 @@ PE->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_NX_COMPAT; if (!Config->AllowIsolation) PE->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION; + if (Config->Machine == I386 && !SEHTable && + !Symtab->findUnderscore("_load_config_used")) + PE->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_NO_SEH; if (Config->TerminalServerAware) PE->DLLCharacteristics |= IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE; PE->NumberOfRvaAndSize = NumberfOfDataDirectory; Index: lld/trunk/test/COFF/hello32.test =================================================================== --- lld/trunk/test/COFF/hello32.test +++ lld/trunk/test/COFF/hello32.test @@ -42,9 +42,10 @@ HEADER-NEXT: SizeOfImage: 20480 HEADER-NEXT: SizeOfHeaders: 512 HEADER-NEXT: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3) -HEADER-NEXT: Characteristics [ (0x9140) +HEADER-NEXT: Characteristics [ (0x9540) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_APPCONTAINER (0x1000) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE (0x40) +HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_NO_SEH (0x400) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_NX_COMPAT (0x100) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE (0x8000) HEADER-NEXT: ] Index: lld/trunk/test/COFF/safeseh.s =================================================================== --- lld/trunk/test/COFF/safeseh.s +++ lld/trunk/test/COFF/safeseh.s @@ -1,11 +1,12 @@ # RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t.obj # RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main -# RUN: llvm-readobj -coff-basereloc -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-NOGC +# RUN: llvm-readobj -coff-basereloc -coff-load-config -file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC # RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:ref -entry:main -# RUN: llvm-readobj -coff-basereloc -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-GC +# RUN: llvm-readobj -coff-basereloc -coff-load-config -file-headers %t.exe | FileCheck %s --check-prefix=CHECK-GC # __safe_se_handler_table needs to be relocated against ImageBase. # check that the relocation is present. +# CHECK-NOGC-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH # CHECK-NOGC: BaseReloc [ # CHECK-NOGC: Entry { # CHECK-NOGC: Type: HIGHLOW @@ -20,6 +21,7 @@ # Without the SEH table, the address is absolute, so check that we do # not have a relocation for it. +# CHECK-GC-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH # CHECK-GC: BaseReloc [ # CHECK-GC-NEXT: ] # CHECK-GC: LoadConfig [