Skip to content

Commit 1fa0302

Browse files
authored
[LLD][COFF] Emit warnings for missing load config on EC targets (#121339)
ARM64EC and ARM64X images require a load configuration to be valid.
1 parent 76a4c45 commit 1fa0302

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lld/COFF/SymbolTable.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,15 @@ void SymbolTable::initializeLoadConfig() {
536536
auto sym =
537537
dyn_cast_or_null<DefinedRegular>(findUnderscore("_load_config_used"));
538538
if (!sym) {
539+
if (isEC()) {
540+
Warn(ctx) << "EC version of '_load_config_used' is missing";
541+
return;
542+
}
543+
if (ctx.hybridSymtab) {
544+
Warn(ctx) << "native version of '_load_config_used' is missing for "
545+
"ARM64X target";
546+
return;
547+
}
539548
if (ctx.config.guardCF != GuardCFLevel::Off)
540549
Warn(ctx)
541550
<< "Control Flow Guard is enabled but '_load_config_used' is missing";

lld/test/COFF/arm64x-loadconfig.s

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@
88
// RUN: llvm-mc -filetype=obj -triple=aarch64-windows loadconfig-short.s -o loadconfig-short.obj
99
// RUN: llvm-mc -filetype=obj -triple=arm64ec-windows loadconfig-short.s -o loadconfig-short-arm64ec.obj
1010

11-
// RUN: lld-link -machine:arm64x -out:out.dll -dll -noentry loadconfig.obj test.obj
11+
// RUN: lld-link -machine:arm64x -out:out-warn.dll -dll -noentry test.obj \
12+
// RUN: 2>&1 | FileCheck --check-prefixes=WARN-LOADCFG,WARN-EC-LOADCFG %s
13+
// WARN-LOADCFG: lld-link: warning: native version of '_load_config_used' is missing for ARM64X target
14+
// WARN-EC-LOADCFG: lld-link: warning: EC version of '_load_config_used' is missing
15+
16+
// RUN: lld-link -machine:arm64x -out:out-nonative.dll -dll -noentry loadconfig-ec.obj chpe.obj \
17+
// RUN: 2>&1 | FileCheck --check-prefixes=WARN-LOADCFG --implicit-check-not EC %s
18+
19+
// RUN: lld-link -machine:arm64ec -out:out-ec.dll -dll -noentry chpe.obj \
20+
// RUN: 2>&1 | FileCheck --check-prefixes=WARN-EC-LOADCFG --implicit-check-not native %s
21+
22+
// RUN: lld-link -machine:arm64x -out:out.dll -dll -noentry loadconfig.obj test.obj \
23+
// RUN: 2>&1 | FileCheck --check-prefixes=WARN-EC-LOADCFG --implicit-check-not native %s
1224

1325
// RUN: llvm-readobj --coff-load-config out.dll | FileCheck --check-prefix=DYNRELOCS %s
1426
// DYNRELOCS: DynamicValueRelocTableOffset: 0xC

0 commit comments

Comments
 (0)