[lld] [LLD] [COFF] Print a warning when using /dependentloadflag without load config (PR #117400)
Mateusz MikuĊa via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 2 16:11:44 PST 2024
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/117400
>From c69accc6ef981106637faeeef071646fbd0121f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <mati865 at gmail.com>
Date: Sat, 23 Nov 2024 00:08:53 +0100
Subject: [PATCH] [LLD] [COFF] Print a warning when using /dependentloadflag
without load config
---
lld/COFF/Writer.cpp | 2 ++
lld/test/COFF/dependentflags.test | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index d3e326378ed2d4..110724c1a1026d 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -2607,6 +2607,8 @@ void Writer::prepareLoadConfig() {
if (!b) {
if (ctx.config.guardCF != GuardCFLevel::Off)
warn("Control Flow Guard is enabled but '_load_config_used' is missing");
+ if (ctx.config.dependentLoadFlags)
+ warn("_load_config_used not found, /dependentloadflag will have no effect");
return;
}
diff --git a/lld/test/COFF/dependentflags.test b/lld/test/COFF/dependentflags.test
index 3e90511591c75e..2ea974c268d5c8 100644
--- a/lld/test/COFF/dependentflags.test
+++ b/lld/test/COFF/dependentflags.test
@@ -20,6 +20,10 @@ RUN: not lld-link %S/Inputs/precomp-a.obj %t.ldcfg.obj /out:%t.exe /nodefaultlib
RUN: not lld-link %S/Inputs/precomp-a.obj %t.ldcfg.obj /out:%t.exe /nodefaultlib /force /dependentloadflag:zz 2>&1 | FileCheck %s --check-prefix FAIL
RUN: not lld-link %S/Inputs/precomp-a.obj %t.ldcfg.obj /out:%t.exe /nodefaultlib /force /dependentloadflag:0xf0000 2>&1 | FileCheck %s --check-prefix FAIL-RANGE
+// ---- Warn if _load_config_used is missing
+RUN: llvm-lib %t.ldcfg.obj /out:%t.lib
+RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /dependentloadflag:0x800 2>&1 | FileCheck %s --check-prefix WARN-NOBASE
+RUN: lld-link %S/Inputs/precomp-a.obj %t.lib /out:%t.exe /nodefaultlib /force /dependentloadflag:0x800 2>&1 | FileCheck %s --allow-empty --check-prefix NO-WARN
BASE: DependentLoadFlags: 0x0
FLAGS-800: DependentLoadFlags: 0x800
@@ -29,3 +33,5 @@ FAIL: lld-link: error: /dependentloadflag: invalid argument: zz
FAIL-RANGE: lld-link: error: /dependentloadflag: invalid argument: 0xf0000
FAIL-NOARG: lld-link: error: /dependentloadflag: no argument specified
+WARN-NOBASE: lld-link: warning: _load_config_used not found, /dependentloadflag will have no effect
+NO-WARN-NOT: lld-link: warning: _load_config_used not found, /dependentloadflag will have no effect
More information about the llvm-commits
mailing list