[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
Sat Nov 23 13:41:58 PST 2024
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/117400
>From 9704ea06ef7f466a37910a1cef9d54ec37e7d901 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 | 6 ++++++
2 files changed, 10 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..a5dd40bd6a279a 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, /delayloadflag will have no effect
+NO-WARN-NOT: lld-link: warning: _load_config_used not found, /delayloadflag will have no effect
More information about the llvm-commits
mailing list