[lld] 8a6f1ab - [LLD] [COFF] Print a warning when using /dependentloadflag without load config (#117400)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 12:28:42 PST 2024


Author: Mateusz MikuĊ‚a
Date: 2024-12-05T22:28:38+02:00
New Revision: 8a6f1abe16577b79dd4bdf52082f3c84c5630e86

URL: https://github.com/llvm/llvm-project/commit/8a6f1abe16577b79dd4bdf52082f3c84c5630e86
DIFF: https://github.com/llvm/llvm-project/commit/8a6f1abe16577b79dd4bdf52082f3c84c5630e86.diff

LOG: [LLD] [COFF] Print a warning when using /dependentloadflag without load config (#117400)

As per request in https://github.com/llvm/llvm-project/pull/113814.

Added: 
    

Modified: 
    lld/COFF/Writer.cpp
    lld/test/COFF/dependentflags.test

Removed: 
    


################################################################################
diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index f47262188ba103..e6b3a9a88e67e0 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -2654,6 +2654,9 @@ void Writer::prepareLoadConfig() {
     if (ctx.config.guardCF != GuardCFLevel::Off)
       Warn(ctx)
           << "Control Flow Guard is enabled but '_load_config_used' is missing";
+    if (ctx.config.dependentLoadFlags)
+      Warn(ctx) << "_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