forked from OSchip/llvm-project
[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
This commit is contained in:
parent
35c96598b1
commit
fe44a531e0
|
@ -132,6 +132,7 @@ struct Configuration {
|
|||
GuardCFLevel guardCF = GuardCFLevel::Off;
|
||||
|
||||
// Used for SafeSEH.
|
||||
bool safeSEH = false;
|
||||
Symbol *sehTable = nullptr;
|
||||
Symbol *sehCount = nullptr;
|
||||
|
||||
|
|
|
@ -1556,6 +1556,11 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
|
|||
}
|
||||
config->wordsize = config->is64() ? 8 : 4;
|
||||
|
||||
// Handle /safeseh, x86 only, on by default, except for mingw.
|
||||
if (config->machine == I386 &&
|
||||
args.hasFlag(OPT_safeseh, OPT_safeseh_no, !config->mingw))
|
||||
config->safeSEH = true;
|
||||
|
||||
// Handle /functionpadmin
|
||||
for (auto *arg : args.filtered(OPT_functionpadmin, OPT_functionpadmin_opt))
|
||||
parseFunctionPadMin(arg, config->machine);
|
||||
|
@ -1795,15 +1800,6 @@ void LinkerDriver::link(ArrayRef<const char *> argsArr) {
|
|||
if (errorCount())
|
||||
return;
|
||||
|
||||
// Handle /safeseh.
|
||||
if (args.hasFlag(OPT_safeseh, OPT_safeseh_no, false)) {
|
||||
for (ObjFile *file : ObjFile::instances)
|
||||
if (!file->hasSafeSEH())
|
||||
error("/safeseh: " + file->getName() + " is not compatible with SEH");
|
||||
if (errorCount())
|
||||
return;
|
||||
}
|
||||
|
||||
if (config->mingw) {
|
||||
// In MinGW, all symbols are automatically exported if no symbols
|
||||
// are chosen to be exported.
|
||||
|
|
|
@ -917,7 +917,7 @@ void Writer::createMiscChunks() {
|
|||
}
|
||||
|
||||
// Create SEH table. x86-only.
|
||||
if (config->machine == I386)
|
||||
if (config->safeSEH)
|
||||
createSEHTable();
|
||||
|
||||
// Create /guard:cf tables if requested.
|
||||
|
@ -1428,23 +1428,15 @@ void Writer::openFile(StringRef path) {
|
|||
}
|
||||
|
||||
void Writer::createSEHTable() {
|
||||
// Set the no SEH characteristic on x86 binaries unless we find exception
|
||||
// handlers.
|
||||
setNoSEHCharacteristic = true;
|
||||
|
||||
SymbolRVASet handlers;
|
||||
for (ObjFile *file : ObjFile::instances) {
|
||||
// FIXME: We should error here instead of earlier unless /safeseh:no was
|
||||
// passed.
|
||||
if (!file->hasSafeSEH())
|
||||
return;
|
||||
|
||||
error("/safeseh: " + file->getName() + " is not compatible with SEH");
|
||||
markSymbolsForRVATable(file, file->getSXDataChunks(), handlers);
|
||||
}
|
||||
|
||||
// Remove the "no SEH" characteristic if all object files were built with
|
||||
// safeseh, we found some exception handlers, and there is a load config in
|
||||
// the object.
|
||||
// Set the "no SEH" characteristic if there really were no handlers, or if
|
||||
// there is no load config object to point to the table of handlers.
|
||||
setNoSEHCharacteristic =
|
||||
handlers.empty() || !symtab->findUnderscore("_load_config_used");
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj %s > %t.obj
|
||||
# RUN: lld-link /dll /noentry /debug %t.obj 2>&1 | FileCheck %s
|
||||
# RUN: lld-link -safeseh:no /dll /noentry /debug %t.obj 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: ignoring section .debug$S with unrecognized magic 0x1
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@ REQUIRES: x86
|
|||
RUN: mkdir -p %t
|
||||
RUN: llvm-mc -triple i686-unknown-windows-msvc -filetype obj -o %t/import.o %S/Inputs/constant-import.s
|
||||
RUN: llc -mtriple i686-unknown-windows-msvc -filetype obj -o %t/export.o %S/Inputs/constant-export.ll
|
||||
RUN: lld-link -machine:x86 -dll -out:%t/export.dll %t/export.o -entry:__CFConstantStringClassReference
|
||||
RUN: lld-link -machine:x86 -dll -out:%t/import.dll %t/import.o %t/export.lib
|
||||
RUN: lld-link -safeseh:no -machine:x86 -dll -out:%t/export.dll %t/export.o -entry:__CFConstantStringClassReference
|
||||
RUN: lld-link -safeseh:no -machine:x86 -dll -out:%t/import.dll %t/import.o %t/export.lib
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=i686-windows-msvc %s -o %t.obj
|
||||
# RUN: echo -e "LIBRARY foo\nEXPORTS\n stdcall\n fastcall\n vectorcall\n _underscored" > %t.def
|
||||
# RUN: lld-link -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib
|
||||
# RUN: lld-link -safeseh:no -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib
|
||||
# RUN: llvm-readobj %t.lib | FileCheck -check-prefix UNDECORATED-IMPLIB %s
|
||||
# RUN: llvm-readobj --coff-exports %t.dll | FileCheck -check-prefix UNDECORATED-EXPORTS %s
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
|||
|
||||
|
||||
# RUN: echo -e "LIBRARY foo\nEXPORTS\n _stdcall@8\n @fastcall@8\n vectorcall@@8" > %t.def
|
||||
# RUN: lld-link -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib
|
||||
# RUN: lld-link -safeseh:no -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib
|
||||
# RUN: llvm-readobj %t.lib | FileCheck -check-prefix DECORATED-IMPLIB %s
|
||||
# RUN: llvm-readobj --coff-exports %t.dll | FileCheck -check-prefix DECORATED-EXPORTS %s
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
|
||||
# RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: lld-link -safeseh:no %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: /entry:main@0 /alternatename:___delayLoadHelper2@8=_main@0 \
|
||||
# RUN: /delayload:std32.dll /out:%t.exe
|
||||
# RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORT %s
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=i686-windows-msvc %s -o %t.obj
|
||||
|
||||
# RUN: lld-link -entry:dllmain -dll %t.obj -out:%t.dll -implib:%t.lib
|
||||
# RUN: lld-link -safeseh:no -entry:dllmain -dll %t.obj -out:%t.dll -implib:%t.lib
|
||||
# RUN: llvm-readobj %t.lib | FileCheck -check-prefix DECORATED-IMPLIB %s
|
||||
# RUN: llvm-readobj --coff-exports %t.dll | FileCheck -check-prefix DECORATED-EXPORTS %s
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj < %s > %t.obj
|
||||
# RUN: lld-link /subsystem:console /out:%t.exe %t.obj
|
||||
# RUN: lld-link -safeseh:no /subsystem:console /out:%t.exe %t.obj
|
||||
|
||||
--- !COFF
|
||||
header:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# RUN: sed -e s/ENTRYNAME/_mainCRTStartup/ %s | yaml2obj > %t.obj
|
||||
# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
|
||||
# RUN: lld-link -safeseh:no /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
|
||||
# RUN: FileCheck %s < %t.log
|
||||
|
||||
# RUN: sed -e s/ENTRYNAME/?mainCRTStartup@@YAHXZ/ %s | yaml2obj > %t.obj
|
||||
# RUN: lld-link /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
|
||||
# RUN: lld-link -safeseh:no /subsystem:console /out:%t.exe %t.obj /verbose /nodefaultlib > %t.log 2>&1
|
||||
# RUN: FileCheck %s < %t.log
|
||||
|
||||
# CHECK: Entry name inferred: _mainCRTStartup
|
||||
|
|
|
@ -25,7 +25,7 @@ _dataSym:
|
|||
|
||||
# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj
|
||||
#
|
||||
# RUN: lld-link -out:%t.dll -dll %t.obj -lldmingw -exclude-all-symbols -output-def:%t.def
|
||||
# RUN: lld-link -safeseh:no -out:%t.dll -dll %t.obj -lldmingw -exclude-all-symbols -output-def:%t.def
|
||||
# RUN: llvm-readobj --coff-exports %t.dll | FileCheck -check-prefix=DLLEXPORT %s
|
||||
|
||||
# DLLEXPORT: Name: exportfn3
|
||||
|
|
|
@ -42,7 +42,7 @@ __imp__unexported:
|
|||
|
||||
# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj
|
||||
#
|
||||
# RUN: lld-link -out:%t.dll -dll %t.obj -lldmingw -export-all-symbols -output-def:%t.def
|
||||
# RUN: lld-link -safeseh:no -out:%t.dll -dll %t.obj -lldmingw -export-all-symbols -output-def:%t.def
|
||||
# RUN: llvm-readobj --coff-exports %t.dll | FileCheck -check-prefix=CHECK2 %s
|
||||
# RUN: cat %t.def | FileCheck -check-prefix=CHECK2-DEF %s
|
||||
|
||||
|
@ -69,7 +69,7 @@ __imp__unexported:
|
|||
# RUN: llvm-ar rcs %T/libs/libmingwex.a %T/libs/mingwfunc.o
|
||||
# RUN: echo -e ".global crtfunc\n.text\ncrtfunc:\nret\n" > %T/libs/crtfunc.s
|
||||
# RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/crtfunc.s -filetype=obj -o %T/libs/crt2.o
|
||||
# RUN: lld-link -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o %T/libs/libmingwex.a -output-def:%t.def
|
||||
# RUN: lld-link -safeseh:no -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o %T/libs/libmingwex.a -output-def:%t.def
|
||||
# RUN: echo "EOF" >> %t.def
|
||||
# RUN: cat %t.def | FileCheck -check-prefix=CHECK-EXCLUDE %s
|
||||
|
||||
|
@ -80,7 +80,7 @@ __imp__unexported:
|
|||
# Test that libraries included with -wholearchive: are autoexported, even if
|
||||
# they are in a library that otherwise normally would be excluded.
|
||||
|
||||
# RUN: lld-link -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o -wholearchive:%T/libs/libmingwex.a -output-def:%t.def
|
||||
# RUN: lld-link -safeseh:no -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o -wholearchive:%T/libs/libmingwex.a -output-def:%t.def
|
||||
# RUN: echo "EOF" >> %t.def
|
||||
# RUN: cat %t.def | FileCheck -check-prefix=CHECK-WHOLEARCHIVE %s
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -triple i686-windows-msvc %s -o %t.obj -filetype=obj
|
||||
# RUN: lld-link %t.obj -out:%t.dll -dll -nodefaultlib -noentry -export:foo_std=bar_std -export:foo_fast=bar_fast
|
||||
# RUN: lld-link -safeseh:no %t.obj -out:%t.dll -dll -nodefaultlib -noentry -export:foo_std=bar_std -export:foo_fast=bar_fast
|
||||
# RUN: llvm-nm %t.lib | FileCheck %s
|
||||
|
||||
# MSVC fudges the lookup of 'bar' to allow it to find the stdcall function
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# RUN: yaml2obj < %s > %t.obj
|
||||
#
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK1 %s
|
||||
#
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 /merge:.edata=.rdata
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 /merge:.edata=.rdata
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK1 %s
|
||||
# RUN: llvm-readobj --file-headers --sections %t.dll | FileCheck -check-prefix=HEADER-MERGE %s
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
|||
# HEADER-MERGE-NEXT: VirtualSize: 0x7E
|
||||
# HEADER-MERGE-NEXT: VirtualAddress: 0x2000
|
||||
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1,@5 \
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1,@5 \
|
||||
# RUN: /export:exportfn2 /export:mangled
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK2 %s
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
|||
# CHECK2-NEXT: 7 0x1010 exportfn3
|
||||
# CHECK2-NEXT: 8 0x1010 mangled
|
||||
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1,@5,noname /export:exportfn2
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1,@5,noname /export:exportfn2
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK3 %s
|
||||
|
||||
# CHECK3: Export Table:
|
||||
|
@ -51,7 +51,7 @@
|
|||
# CHECK3-NEXT: 5 0x1008
|
||||
# CHECK3-NEXT: 6 0x1010 exportfn2
|
||||
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /export:f1=exportfn1 /export:f2=exportfn2
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:f1=exportfn1 /export:f2=exportfn2
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK4 %s
|
||||
|
||||
# CHECK4: Export Table:
|
||||
|
@ -64,12 +64,12 @@
|
|||
|
||||
# RUN: echo "EXPORTS exportfn1 @3" > %t.def
|
||||
# RUN: echo "fn2=exportfn2 @2" >> %t.def
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /def:%t.def
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /def:%t.def
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK5 %s
|
||||
|
||||
# RUN: echo "EXPORTS exportfn1 @ 3" > %t.def
|
||||
# RUN: echo "fn2=exportfn2 @ 2" >> %t.def
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /def:%t.def
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /def:%t.def
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK5 %s
|
||||
|
||||
# CHECK5: Export Table:
|
||||
|
@ -81,14 +81,14 @@
|
|||
# CHECK5-NEXT: 3 0x1008 exportfn1
|
||||
# CHECK5-NEXT: 4 0x1010 exportfn3
|
||||
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 \
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 \
|
||||
# RUN: /export:exportfn1 /export:exportfn2,@5 >& %t.log
|
||||
# RUN: FileCheck -check-prefix=CHECK6 %s < %t.log
|
||||
|
||||
# CHECK6: duplicate /export option: _exportfn2
|
||||
# CHECK6-NOT: duplicate /export option: _exportfn1
|
||||
|
||||
# RUN: lld-link /out:%t.dll /dll %t.obj /export:foo=mangled
|
||||
# RUN: lld-link -safeseh:no /out:%t.dll /dll %t.obj /export:foo=mangled
|
||||
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK7 %s
|
||||
|
||||
# CHECK7: Export Table:
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
|
||||
#
|
||||
# RUN: lld-link %t.obj /fixed %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: lld-link -safeseh:no %t.obj /fixed %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: /entry:main@0 /debug /out:%t.fixed.exe
|
||||
# RUN: llvm-readobj --file-headers %t.fixed.exe | \
|
||||
# RUN: FileCheck -check-prefix=EXEFIXED %s
|
||||
#
|
||||
# RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: lld-link -safeseh:no %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: /entry:main@0 /debug /out:%t.exe
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=EXEREL %s
|
||||
#
|
||||
# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj
|
||||
#
|
||||
# RUN: lld-link %t.obj /dll /fixed /debug /out:%t.fixed.dll
|
||||
# RUN: lld-link -safeseh:no %t.obj /dll /fixed /debug /out:%t.fixed.dll
|
||||
# RUN: llvm-readobj --file-headers %t.fixed.dll | FileCheck -check-prefix=DLLFIXED %s
|
||||
#
|
||||
# RUN: lld-link %t.obj /dll /debug /out:%t.dll
|
||||
# RUN: lld-link -safeseh:no %t.obj /dll /debug /out:%t.dll
|
||||
# RUN: llvm-readobj --file-headers %t.dll | FileCheck -check-prefix=DLLREL %s
|
||||
|
||||
EXEFIXED-NOT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -triple i686-pc-win32 %s -filetype=obj -o %t.obj
|
||||
# RUN: lld-link %t.obj -guard:cf -out:%t.exe -entry:main
|
||||
# RUN: lld-link -safeseh:no %t.obj -guard:cf -out:%t.exe -entry:main
|
||||
# RUN: llvm-readobj --coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK
|
||||
|
||||
# Only f and _main should go in the table.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
|
||||
# RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: lld-link -safeseh:no %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: /entry:main@0 /out:%t.exe /appcontainer
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=HEADER %s
|
||||
# RUN: llvm-readobj --coff-imports %t.exe | FileCheck -check-prefix=IMPORTS %s
|
||||
|
@ -42,10 +42,9 @@ HEADER-NEXT: MinorSubsystemVersion: 0
|
|||
HEADER-NEXT: SizeOfImage: 20480
|
||||
HEADER-NEXT: SizeOfHeaders: 1024
|
||||
HEADER-NEXT: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3)
|
||||
HEADER-NEXT: Characteristics [ (0x9540)
|
||||
HEADER-NEXT: Characteristics [ (0x9140)
|
||||
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: ]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
|
||||
# RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: lld-link -safeseh:no %t.obj %p/Inputs/std32.lib /subsystem:console \
|
||||
# RUN: /entry:main@0 /out:%t.exe /largeaddressaware
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=HEADER %s
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj < %s > %t.obj
|
||||
# RUN: lld-link /out:%t.exe %t.obj /entry:main /subsystem:console
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe %t.obj /entry:main /subsystem:console
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck %s
|
||||
|
||||
# CHECK: LoadConfigTableRVA: 0x2000
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj < %s > %t.obj
|
||||
# RUN: lld-link /out:%t.exe /entry:main %t.obj
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe /entry:main %t.obj
|
||||
# RUN: llvm-objdump -s %t.exe | FileCheck %s
|
||||
|
||||
# CHECK: Contents of section .text:
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
# RUN: yaml2obj %p/Inputs/machine-x64.yaml > %t.obj
|
||||
# RUN: lld-link /entry:main /subsystem:console /out:%t.exe %t.obj
|
||||
# RUN: lld-link -safeseh:no /entry:main /subsystem:console /out:%t.exe %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=AMD64 %s
|
||||
# RUN: lld-link /entry:main /subsystem:console /machine:x64 \
|
||||
# RUN: lld-link -safeseh:no /entry:main /subsystem:console /machine:x64 \
|
||||
# RUN: /out:%t.exe %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=AMD64 %s
|
||||
|
||||
AMD64: Machine: IMAGE_FILE_MACHINE_AMD64
|
||||
|
||||
# RUN: yaml2obj %p/Inputs/machine-x86.yaml > %t.obj
|
||||
# RUN: lld-link /entry:main /subsystem:console /out:%t.exe %t.obj
|
||||
# RUN: lld-link -safeseh:no /entry:main /subsystem:console /out:%t.exe %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=I386 %s
|
||||
# RUN: lld-link /entry:main /subsystem:console /machine:x86 \
|
||||
# RUN: lld-link -safeseh:no /entry:main /subsystem:console /machine:x86 \
|
||||
# RUN: /out:%t.exe %t.obj /fixed
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=I386 %s
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# RUN: rm -rf %t && mkdir %t
|
||||
# RUN: yaml2obj < %p/Inputs/no-ipi-stream-obj.obj.yaml > %t/no-ipi-stream-obj.obj
|
||||
# RUN: llvm-pdbutil yaml2pdb %p/Inputs/no-ipi-stream-pdb.pdb.yaml -pdb=%t/no-ipi-stream-pdb.pdb
|
||||
# RUN: lld-link /dll /noentry /debug %t/no-ipi-stream-obj.obj
|
||||
# RUN: lld-link -safeseh:no /dll /noentry /debug %t/no-ipi-stream-obj.obj
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
# RUN: echo fn1 > %t.order
|
||||
# RUN: echo fn2 >> %t.order
|
||||
|
||||
# RUN: lld-link -entry:fn1 -subsystem:console -opt:noref %t.obj \
|
||||
# RUN: lld-link -safeseh:no -entry:fn1 -subsystem:console -opt:noref %t.obj \
|
||||
# RUN: -lldmap:- -out:%t.exe -order:@%t.order | FileCheck %s
|
||||
# CHECK: fn1
|
||||
# CHECK: fn2
|
||||
|
||||
# RUN: lld-link -entry:fn1 -subsystem:console -opt:noref %t.obj \
|
||||
# RUN: lld-link -safeseh:no -entry:fn1 -subsystem:console -opt:noref %t.obj \
|
||||
# RUN: -lldmap:- -out:%t.exe | FileCheck -check-prefix=DEFAULT %s
|
||||
# DEFAULT: fn2
|
||||
# DEFAULT: fn1
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -triple=i386-pc-win32 -filetype=obj -o %t.obj %s
|
||||
# RUN: lld-link /subsystem:console /debug /nodefaultlib /entry:foo /out:%t.exe /pdb:%t.pdb %t.obj
|
||||
# RUN: lld-link -safeseh:no /subsystem:console /debug /nodefaultlib /entry:foo /out:%t.exe /pdb:%t.pdb %t.obj
|
||||
# RUN: llvm-pdbutil dump -fpo %t.pdb | FileCheck %s
|
||||
|
||||
# CHECK: Old FPO Data
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple=i686-windows-msvc %s -o foo.obj
|
||||
# RUN: llc %S/Inputs/bar.ll -filetype=obj -mtriple=i686-windows-msvc -o bar.obj
|
||||
# RUN: llvm-lib bar.obj -out:bar.lib
|
||||
# RUN: lld-link -debug -pdb:foo.pdb foo.obj bar.lib -out:foo.exe -entry:main
|
||||
# RUN: lld-link -safeseh:no -debug -pdb:foo.pdb foo.obj bar.lib -out:foo.exe -entry:main
|
||||
# RUN: llvm-pdbutil dump -modules %t/foo.pdb | FileCheck %s
|
||||
|
||||
# Make sure that the PDB has module descriptors. foo.obj and bar.lib should be
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj %s -o %t.obj
|
||||
# RUN: lld-link -debug -entry:main -out:%t.exe -pdb:%t.pdb %t.obj
|
||||
# RUN: lld-link -safeseh:no -debug -entry:main -out:%t.exe -pdb:%t.pdb %t.obj
|
||||
# RUN: llvm-pdbutil dump -globals %t.pdb | FileCheck %s
|
||||
|
||||
# There is an S_GDATA32 symbol record with .secrel32 and .secidx relocations in
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -triple=i386-pc-win32 -filetype=obj -o %t.obj %s
|
||||
# RUN: lld-link -subsystem:console -debug -nodefaultlib -entry:foo -out:%t.exe -pdb:%t.pdb %t.obj 2>&1 | FileCheck %s --check-prefix=WARNING
|
||||
# RUN: lld-link -safeseh:no -subsystem:console -debug -nodefaultlib -entry:foo -out:%t.exe -pdb:%t.pdb %t.obj 2>&1 | FileCheck %s --check-prefix=WARNING
|
||||
# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s
|
||||
|
||||
# WARNING-NOT: ignoring unknown
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# REQUIRES: x86
|
||||
# RUN: yaml2obj < %s > %t.obj
|
||||
# RUN: lld-link /out:%t.exe /entry:main /base:0x400000 %t.obj
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe /entry:main /base:0x400000 %t.obj
|
||||
# RUN: llvm-objdump -d %t.exe | FileCheck %s
|
||||
|
||||
# CHECK: .text:
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
# RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t.obj
|
||||
# RUN: not lld-link %t.obj -safeseh -out:%t.exe -entry:main 2>&1 | FileCheck %s --check-prefix=ERROR
|
||||
# safe seh should be on by default.
|
||||
# RUN: not lld-link %t.obj -out:%t.exe -entry:main 2>&1 | FileCheck %s --check-prefix=ERROR
|
||||
# RUN: lld-link %t.obj -safeseh:no -out:%t.exe -entry:main
|
||||
# RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s
|
||||
# -lldmingw should also turn off safeseh by default.
|
||||
# RUN: lld-link %t.obj -lldmingw -out:%t.exe -entry:main
|
||||
# RUN: llvm-readobj --file-headers --coff-load-config %t.exe | FileCheck %s
|
||||
|
||||
# ERROR: /safeseh: {{.*}}safeseh-no.s.tmp.obj is not compatible with SEH
|
||||
|
||||
# CHECK: Characteristics [
|
||||
# CHECK-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH
|
||||
# CHECK: ]
|
||||
# CHECK: LoadConfig [
|
||||
# CHECK: Size: 0x48
|
||||
# CHECK: SEHandlerTable: 0x0
|
||||
# CHECK: SEHandlerCount: 0
|
||||
# CHECK: ]
|
||||
# CHECK-NOT: SEHTable
|
||||
|
||||
|
||||
# Explicitly mark the object as not having safeseh. LLD should error unless
|
||||
# -safeseh:no is passed.
|
||||
.def @feat.00; .scl 3; .type 0; .endef
|
||||
.globl @feat.00
|
||||
@feat.00 = 0
|
||||
|
||||
.def _main;
|
||||
.scl 2;
|
||||
.type 32;
|
||||
.endef
|
||||
.section .text,"xr",one_only,_main
|
||||
.globl _main
|
||||
_main:
|
||||
movl $42, %eax
|
||||
ret
|
||||
|
||||
# Add a handler to create an .sxdata section, which -safeseh:no should ignore.
|
||||
.def _my_handler; .scl 3; .type 32;
|
||||
.endef
|
||||
.section .text,"xr",one_only,_my_handler
|
||||
_my_handler:
|
||||
ret
|
||||
.safeseh _my_handler
|
||||
|
||||
|
||||
.section .rdata,"dr"
|
||||
.globl __load_config_used
|
||||
__load_config_used:
|
||||
.long 72
|
||||
.fill 60, 1, 0
|
||||
.long ___safe_se_handler_table
|
||||
.long ___safe_se_handler_count
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj < %s > %t.obj
|
||||
# RUN: lld-link /dll /noentry /out:%t.dll %t.obj
|
||||
# RUN: lld-link -safeseh:no /dll /noentry /out:%t.dll %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.dll | FileCheck %s
|
||||
|
||||
# CHECK: MajorOperatingSystemVersion: 42
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
# RUN: sed -e s/ENTRYNAME/_main/ %s | yaml2obj > %t.obj
|
||||
# RUN: lld-link /out:%t.exe %t.obj
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=MAIN %s
|
||||
|
||||
# RUN: sed s/ENTRYNAME/_wmain/ %s | yaml2obj > %t.obj
|
||||
# RUN: lld-link /out:%t.exe %t.obj
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=WMAIN %s
|
||||
|
||||
# RUN: sed s/ENTRYNAME/_WinMain@16/ %s | yaml2obj > %t.obj
|
||||
# RUN: lld-link /out:%t.exe %t.obj
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=WINMAIN %s
|
||||
|
||||
# RUN: sed s/ENTRYNAME/_wWinMain@16/ %s | yaml2obj > %t.obj
|
||||
# RUN: lld-link /out:%t.exe %t.obj
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck -check-prefix=WWINMAIN %s
|
||||
|
||||
# MAIN: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# RUN: yaml2obj < %s > %t.obj
|
||||
# RUN: lld-link /out:%t.exe /entry:main %t.obj
|
||||
# RUN: lld-link -safeseh:no /out:%t.exe /entry:main %t.obj
|
||||
# RUN: llvm-readobj --file-headers %t.exe | FileCheck %s
|
||||
|
||||
# CHECK: TLSTableRVA: 0x1000
|
||||
|
|
Loading…
Reference in New Issue