[PECOFF] Emit Load Configuration and SEH Table for x86.
If all input files are compatible with Structured Exception Handling, linker
is supposed to create an exectuable with a table for SEH handlers. The table
consists of exception handlers entry point addresses.
The basic idea of SEH in x86 Microsoft ABI is to list all valid entry points
of exception handlers in an read-only memory, so that an attacker cannot
override the addresses in it. In x86 ABI, data for exception handling is mostly
on stack, so it's volnerable to stack overflow attack. In order to protect
against it, Windows runtime uses the table to check a return address, to
ensure that the address is really an valid entry point for an exception handler.
Compiler emits a list of exception handler functions to .sxdata section. It
also emits a marker symbol "@feat.00" to indicate that the object is compatible
with SEH. SEH is a relatively new feature for COFF, and mixing SEH-compatible
and SEH-incompatible objects will result in an invalid executable, so is the
marker.
If all input files are compatible with SEH, LLD emits a SEH table. SEH table
needs to be pointed by Load Configuration strucutre, so when emitting a SEH
table LLD emits it too. The address of a Load Configuration will be stored to
the file header.
llvm-svn: 202248
2014-02-26 16:27:59 +08:00
|
|
|
# RUN: yaml2obj %p/Inputs/seh.obj.yaml > %t.obj
|
|
|
|
#
|
|
|
|
# RUN: lld -flavor link /out:%t.exe /subsystem:console /force /nodefaultlib \
|
|
|
|
# RUN: -- %t.obj
|
|
|
|
# RUN: llvm-objdump -private-headers %t.exe | FileCheck %s
|
|
|
|
|
|
|
|
CHECK: Load configuration:
|
|
|
|
CHECK: Timestamp: 0
|
|
|
|
CHECK: Major Version: 0
|
|
|
|
CHECK: Minor Version: 0
|
|
|
|
CHECK: GlobalFlags Clear: 0
|
|
|
|
CHECK: GlobalFlags Set: 0
|
|
|
|
CHECK: Critical Section Default Timeout: 0
|
|
|
|
CHECK: Decommit Free Block Threshold: 0
|
|
|
|
CHECK: Decommit Total Free Threshold: 0
|
|
|
|
CHECK: Lock Prefix Table: 0
|
|
|
|
CHECK: Maximum Allocation Size: 0
|
|
|
|
CHECK: Virtual Memory Threshold: 0
|
|
|
|
CHECK: Process Affinity Mask: 0
|
|
|
|
CHECK: Process Heap Flags: 0
|
|
|
|
CHECK: CSD Version: 0
|
|
|
|
CHECK: Security Cookie: 0
|
|
|
|
CHECK: SEH Table: 4210688
|
2014-03-01 06:17:53 +08:00
|
|
|
CHECK: SEH Count: 2
|
|
|
|
CHECK: SEH Table: 0x{{[0-9a-f]+}} 0x{{[0-9a-f]+}}
|
2014-02-27 07:15:41 +08:00
|
|
|
|
|
|
|
# RUN: lld -flavor link /out:%t.exe /subsystem:console /force /nodefaultlib \
|
|
|
|
# RUN: /safeseh:no -- %t.obj
|
|
|
|
# RUN: llvm-objdump -private-headers %t.exe | FileCheck -check-prefix=NOSEH %s
|
|
|
|
|
|
|
|
NOSEH-NOT: SEH Table:
|