1# REQUIRES: x86 2# RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t.obj 3# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main 4# RUN: llvm-readobj --coff-basereloc --coff-load-config --file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC 5# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main -debug:dwarf 6# RUN: llvm-readobj --coff-basereloc --coff-load-config --file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC 7# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:ref -entry:main 8# RUN: llvm-readobj --coff-basereloc --coff-load-config --file-headers %t.exe | FileCheck %s --check-prefix=CHECK-GC 9 10# __safe_se_handler_table needs to be relocated against ImageBase. 11# check that the relocation is present. 12# 13# CHECK-NOGC-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH 14# CHECK-NOGC: BaseReloc [ 15# CHECK-NOGC: Entry { 16# CHECK-NOGC: Type: HIGHLOW 17# CHECK-NOGC: LoadConfig [ 18# CHECK-NOGC: Size: 0x48 19# CHECK-NOGC: SEHandlerTable: 0x 20# CHECK-NOGC: SEHandlerCount: 1 21# CHECK-NOGC: ] 22# CHECK-NOGC: SEHTable [ 23# CHECK-NOGC-NEXT: 0x401006 24# CHECK-NOGC-NEXT: ] 25 26# If we enable GC, the exception handler should be removed, and we should add 27# the DLL characteristic flag that indicates that there are no exception 28# handlers in this DLL. The exception handler table in the load config should 29# be empty and there should be no relocations for it. 30# 31# CHECK-GC: Characteristics [ 32# CHECK-GC: IMAGE_DLL_CHARACTERISTICS_NO_SEH 33# CHECK-GC: ] 34# CHECK-GC: BaseReloc [ 35# CHECK-GC-NEXT: ] 36# CHECK-GC: LoadConfig [ 37# CHECK-GC: Size: 0x48 38# CHECK-GC: SEHandlerTable: 0x0 39# CHECK-GC: SEHandlerCount: 0 40# CHECK-GC: ] 41# CHECK-GC-NOT: SEHTable 42 43 44 .def @feat.00; 45 .scl 3; 46 .type 0; 47 .endef 48 .globl @feat.00 49@feat.00 = 1 50 51 .def _main; 52 .scl 2; 53 .type 32; 54 .endef 55 .section .text,"xr",one_only,_main 56 .globl _main 57_main: 58 movl $42, %eax 59 ret 60 61# This handler can be GCd, which will make the safeseh table empty, so it should 62# appear null. 63 .def _my_handler; 64 .scl 3; 65 .type 32; 66 .endef 67 .section .text,"xr",one_only,_my_handler 68_my_handler: 69 ret 70 71.safeseh _my_handler 72 73 74 .section .rdata,"dr" 75.globl __load_config_used 76__load_config_used: 77 .long 72 78 .fill 60, 1, 0 79 .long ___safe_se_handler_table 80 .long ___safe_se_handler_count 81