Skip to content

Commit 50cfe1d

Browse files
committed
[llvm-readobj][COFF] Add support for more CET and hotpatch flags
Split out the COFF dumper from issue llvm#150761. - Decreased the size of existing `has-cet.exe`. - Added `IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE` - Added `IMAGE_DLL_CHARACTERISTICS_EX_CET_SET_CONTEXT_IP_VALIDATION_RELAXED_MODE` - Added `IMAGE_DLL_CHARACTERISTICS_EX_CET_DYNAMIC_APIS_ALLOW_IN_PROC_ONLY` - Added `IMAGE_DLL_CHARACTERISTICS_EX_CET_RESERVED_1` - Added `IMAGE_DLL_CHARACTERISTICS_EX_CET_RESERVED_2` - Added `IMAGE_DLL_CHARACTERISTICS_EX_FORWARD_CFI_COMPAT` - Added `IMAGE_DLL_CHARACTERISTICS_EX_HOTPATCH_COMPATIBLE`
1 parent 166493d commit 50cfe1d

File tree

11 files changed

+92
-2
lines changed

11 files changed

+92
-2
lines changed

llvm/include/llvm/BinaryFormat/COFF.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,24 @@ enum DLLCharacteristics : unsigned {
694694

695695
enum ExtendedDLLCharacteristics : unsigned {
696696
/// Image is CET compatible
697-
IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT = 0x0001
697+
IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT = 0x0001,
698+
/// Image is CET compatible in strict mode
699+
IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE = 0x0002,
700+
/// Image is CET compatible in such a way that context IP validation is
701+
/// relaxed
702+
IMAGE_DLL_CHARACTERISTICS_EX_CET_SET_CONTEXT_IP_VALIDATION_RELAXED_MODE =
703+
0x0004,
704+
/// Image is CET compatible in such a way that the use of
705+
/// dynamic APIs is restricted to processes only
706+
IMAGE_DLL_CHARACTERISTICS_EX_CET_DYNAMIC_APIS_ALLOW_IN_PROC_ONLY = 0x0008,
707+
/// Reserved for future use. Not used by MSVC link.exe
708+
IMAGE_DLL_CHARACTERISTICS_EX_CET_RESERVED_1 = 0x0010,
709+
/// Reserved for future use. Not used by MSVC link.exe
710+
IMAGE_DLL_CHARACTERISTICS_EX_CET_RESERVED_2 = 0x0020,
711+
/// Image is CFI compatible.
712+
IMAGE_DLL_CHARACTERISTICS_EX_FORWARD_CFI_COMPAT = 0x0040,
713+
/// Image is hotpatch compatible.
714+
IMAGE_DLL_CHARACTERISTICS_EX_HOTPATCH_COMPATIBLE = 0x0080,
698715
};
699716

700717
enum DebugType : unsigned {
-82.5 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 KB
Binary file not shown.
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To regenerate has-cetstrict.exe
2+
# $ echo int main() { return 0; } > has-cetstrict.c
3+
# $ cl has-cetstruct.c /link /cetcompatstrict
4+
RUN: llvm-readobj --coff-debug-directory %p/Inputs/has-cetstrict.exe | FileCheck %s
5+
6+
CHECK: DebugEntry {
7+
CHECK: Characteristics: 0x0
8+
CHECK: Type: ExtendedDLLCharacteristics (0x14)
9+
CHECK: ExtendedCharacteristics [ (0x2)
10+
CHECK: IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT_STRICT_MODE (0x2)
11+
CHECK: ]
12+
CHECK: RawData (
13+
CHECK: 0000: 02000000 |....|
14+
CHECK: )
15+
CHECK: }
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To regenerate has-cetdynamicapisinproc.exe
2+
# $ echo int main() { return 0; } > has-cetdynamicapisinproc.c
3+
# $ cl has-cetdynamicapisinproc.c /link /cetdynamicapisinproc
4+
RUN: llvm-readobj --coff-debug-directory %p/Inputs/has-cetdynamicapisinproc.exe | FileCheck %s
5+
6+
CHECK: DebugEntry {
7+
CHECK: Characteristics: 0x0
8+
CHECK: Type: ExtendedDLLCharacteristics (0x14)
9+
CHECK: ExtendedCharacteristics [ (0x8)
10+
CHECK: IMAGE_DLL_CHARACTERISTICS_EX_CET_DYNAMIC_APIS_ALLOW_IN_PROC_ONLY (0x8)
11+
CHECK: ]
12+
CHECK: RawData (
13+
CHECK: 0000: 08000000 |....|
14+
CHECK: )
15+
CHECK: }
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To regenerate has-cetipvalidationrelaxed.exe
2+
# $ echo int main() { return 0; } > has-cetipvalidationrelaxed.c
3+
# $ cl has-cetipvalidationrelaxed.c /link /cetipvalidationrelaxed
4+
RUN: llvm-readobj --coff-debug-directory %p/Inputs/has-cetipvalidationrelaxed.exe | FileCheck %s
5+
6+
CHECK: DebugEntry {
7+
CHECK: Characteristics: 0x0
8+
CHECK: Type: ExtendedDLLCharacteristics (0x14)
9+
CHECK: ExtendedCharacteristics [ (0x4)
10+
CHECK: IMAGE_DLL_CHARACTERISTICS_EX_CET_SET_CONTEXT_IP_VALIDATION_RELAXED_MODE (0x4)
11+
CHECK: ]
12+
CHECK: RawData (
13+
CHECK: 0000: 04000000 |....|
14+
CHECK: )
15+
CHECK: }
16+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# To regenerate has-hotpatchcompatible.exe
2+
# $ echo int main() { return 0; } > has-hotpatchcompatible.c
3+
# $ cl has-hotpatchcompatible.c /link /hotpatchcompatible
4+
RUN: llvm-readobj --coff-debug-directory %p/Inputs/has-hotpatchcompatible.exe | FileCheck %s
5+
6+
CHECK: DebugEntry {
7+
CHECK: Characteristics: 0x0
8+
CHECK: Type: ExtendedDLLCharacteristics (0x14)
9+
CHECK: ExtendedCharacteristics [ (0x80)
10+
CHECK: IMAGE_DLL_CHARACTERISTICS_EX_HOTPATCH_COMPATIBLE (0x80)
11+
CHECK: ]
12+
CHECK: RawData (
13+
CHECK: 0000: 80000000 |....|
14+
CHECK: )
15+
CHECK: }
16+

0 commit comments

Comments
 (0)