[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
Fri Nov 22 15:16:32 PST 2024


https://github.com/mati865 created https://github.com/llvm/llvm-project/pull/117400

None

>From c38246c5bdf17d14fb5f55db2cd3e8f1be88f45e 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/Driver.cpp               | 5 ++++-
 lld/test/COFF/dependentflags.test | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index a0bff69c6302a2..8fe61d322cbec0 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -2307,8 +2307,11 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
 
   // Handle /dependentloadflag
   for (auto *arg :
-       args.filtered(OPT_dependentloadflag, OPT_dependentloadflag_opt))
+       args.filtered(OPT_dependentloadflag, OPT_dependentloadflag_opt)) {
     parseDependentLoadFlags(arg);
+    if (!ctx.symtab.findUnderscore("_load_config_used"))
+      warn("_load_config_used not found, /delayloadflag will have no effect");
+  }
 
   if (tar) {
     llvm::TimeTraceScope timeScope("Reproducer: response file");
diff --git a/lld/test/COFF/dependentflags.test b/lld/test/COFF/dependentflags.test
index 3e90511591c75e..620e65ae0ff4f3 100644
--- a/lld/test/COFF/dependentflags.test
+++ b/lld/test/COFF/dependentflags.test
@@ -20,6 +20,7 @@ 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
 
+RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /dependentloadflag:0x800 2>&1 | FileCheck %s --check-prefix WARN-NOBASE
 
 BASE: DependentLoadFlags: 0x0
 FLAGS-800: DependentLoadFlags: 0x800
@@ -29,3 +30,4 @@ 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, /delayloadflag will have no effect



More information about the llvm-commits mailing list