[lld] [LLD] [MinGW] Implement --dependent-load-flag option (PR #113814)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 27 07:36:29 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lld

Author: Mateusz MikuĊ‚a (mati865)

<details>
<summary>Changes</summary>

Implement MSVC's `/DEPENDENTLOADFLAG` as `--dependent-load-flag` and forward it to COFF.
I'm not sure about the name as ld.bfd doesn't support it (yet?).

There is no solid need for it yet, but it's being considered: https://github.com/msys2/MINGW-packages/pull/22216#issuecomment-2428417546

---
Full diff: https://github.com/llvm/llvm-project/pull/113814.diff


3 Files Affected:

- (modified) lld/MinGW/Driver.cpp (+3) 
- (modified) lld/MinGW/Options.td (+1) 
- (modified) lld/test/MinGW/driver.test (+3) 


``````````diff
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index 553698d4f537fc..b65840e57755e1 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -398,6 +398,9 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
                    OPT_no_allow_multiple_definition, false))
     add("-force:multiple");
 
+  if (auto *a = args.getLastArg(OPT_dependent_load_flag))
+    add("-dependentloadflag:" + StringRef(a->getValue()));
+
   if (auto *a = args.getLastArg(OPT_icf)) {
     StringRef s = a->getValue();
     if (s == "all")
diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td
index ff7e21fa808f39..a1a4a581ed8bc1 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -61,6 +61,7 @@ defm demangle: B<"demangle",
     "Do not demangle symbol names">;
 def disable_auto_import: F<"disable-auto-import">,
     HelpText<"Don't automatically import data symbols from other DLLs without dllimport">;
+defm dependent_load_flag: EEq<"dependent-load-flag", "Override default LibraryLoad flags">;
 def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">,
     HelpText<"Don't do automatic imports that require runtime fixups">;
 def disable_stdcall_fixup: F<"disable-stdcall-fixup">,
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 2831d155fef128..c2aceebde7432e 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -455,3 +455,6 @@ RUN: ld.lld -### foo.o -m i386pep --rpath foo 2>&1 | FileCheck -check-prefix=WAR
 RUN: ld.lld -### foo.o -m i386pep -rpath=foo 2>&1 | FileCheck -check-prefix=WARN_RPATH %s
 RUN: ld.lld -### foo.o -m i386pep --rpath=foo 2>&1 | FileCheck -check-prefix=WARN_RPATH %s
 WARN_RPATH: warning: parameter -{{-?}}rpath has no effect on PE/COFF targets
+
+RUN: ld.lld -### foo.o -m i386pe --dependent-load-flag=0x800 2>&1 | FileCheck -check-prefix=DEPENDENT_LOAD_FLAG %s
+DEPENDENT_LOAD_FLAG: -dependentloadflag:0x800

``````````

</details>


https://github.com/llvm/llvm-project/pull/113814


More information about the llvm-commits mailing list