File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -1213,8 +1213,7 @@ void Writer::createMiscChunks() {
12131213 createSEHTable ();
12141214
12151215 // Create /guard:cf tables if requested.
1216- if (config->guardCF != GuardCFLevel::Off)
1217- createGuardCFTables ();
1216+ createGuardCFTables ();
12181217
12191218 if (isArm64EC (config->machine ))
12201219 createECChunks ();
@@ -1973,6 +1972,15 @@ void Writer::markSymbolsWithRelocations(ObjFile *file,
19731972void Writer::createGuardCFTables () {
19741973 Configuration *config = &ctx.config ;
19751974
1975+ if (config->guardCF == GuardCFLevel::Off) {
1976+ if (isArm64EC (config->machine )) {
1977+ Symbol *flagSym = ctx.symtab .findUnderscore (" __guard_flags" );
1978+ cast<DefinedAbsolute>(flagSym)->setVA (
1979+ uint32_t (GuardFlags::CF_INSTRUMENTED));
1980+ }
1981+ return ;
1982+ }
1983+
19761984 SymbolRVASet addressTakenSyms;
19771985 SymbolRVASet giatsRVASet;
19781986 std::vector<Symbol *> giatsSymbols;
Original file line number Diff line number Diff line change 1+ // ARM64EC code is always instrumented, check that CF_INSTRUMENTED flag is set even with -guard:no argument.
2+
3+ // REQUIRES: aarch64
4+
5+ // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %s -o %t.obj
6+ // RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o %t-loadconfig.obj
7+
8+ // RUN: lld-link -out:%t1.dll -machine:arm64ec %t.obj %t-loadconfig.obj -dll -noentry
9+ // RUN: lld-link -out:%t2.dll -machine:arm64ec %t.obj %t-loadconfig.obj -dll -noentry -guard:no
10+
11+ // RUN: llvm-readobj --coff-load-config %t1.dll | FileCheck %s
12+ // RUN: llvm-readobj --coff-load-config %t2.dll | FileCheck %s
13+ // CHECK: GuardFlags [ (0x100)
14+ // CHECK-NEXT: CF_INSTRUMENTED (0x100)
15+ // CHECK-NEXT: ]
16+
17+ // RUN: llvm-readobj --hex-dump=.test %t1.dll | FileCheck --check-prefix=SYM %s
18+ // RUN: llvm-readobj --hex-dump=.test %t2.dll | FileCheck --check-prefix=SYM %s
19+ // SYM: 0x180003000 00010000
20+
21+ .section .test , "r"
22+ .word __guard_flags
You can’t perform that action at this time.
0 commit comments