Skip to content

Commit 1a63495

Browse files
committed
[LLD] [MinGW] Implement --dependent-load-flag option
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: msys2/MINGW-packages#22216 (comment)
1 parent cfc574a commit 1a63495

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lld/MinGW/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
407407
OPT_no_allow_multiple_definition, false))
408408
add("-force:multiple");
409409

410+
if (auto *a = args.getLastArg(OPT_dependent_load_flag))
411+
add("-dependentloadflag:" + StringRef(a->getValue()));
412+
410413
if (auto *a = args.getLastArg(OPT_icf)) {
411414
StringRef s = a->getValue();
412415
if (s == "all")

lld/MinGW/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ def _HASH_HASH_HASH : Flag<["-"], "###">,
202202
HelpText<"Print (but do not run) the commands to run for this compilation">;
203203
def appcontainer: F<"appcontainer">, HelpText<"Set the appcontainer flag in the executable">;
204204
defm delayload: Eq<"delayload", "DLL to load only on demand">;
205+
defm dependent_load_flag: EEq<"dependent-load-flag", "Override default LibraryLoad flags">;
205206
defm mllvm: EqNoHelp<"mllvm">;
206207
defm pdb: Eq<"pdb", "Output PDB debug info file, chosen implicitly if the argument is empty">;
207208
defm Xlink : Eq<"Xlink", "Pass <arg> to the COFF linker">, MetaVarName<"<arg>">;
@@ -212,7 +213,7 @@ defm guard_longjmp : B<"guard-longjmp",
212213
"Do not enable Control Flow Guard long jump hardening">;
213214
defm error_limit:
214215
EqLong<"error-limit", "Maximum number of errors to emit before stopping (0 = no limit)">;
215-
def build_id: J<"build-id=">, HelpText<"Generate build ID note (pass none to disable)">,
216+
def build_id: J<"build-id=">, HelpText<"Generate build ID note (pass none to disable)">,
216217
MetaVarName<"<arg>">;
217218
def : F<"build-id">, Alias<build_id>, HelpText<"Alias for --build-id=">;
218219
def functionpadmin: J<"functionpadmin=">, HelpText<"Prepares an image for hotpatching">,

lld/test/MinGW/driver.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,3 +462,6 @@ RUN: ld.lld -### foo.o -m i386pep --rpath foo 2>&1 | FileCheck -check-prefix=WAR
462462
RUN: ld.lld -### foo.o -m i386pep -rpath=foo 2>&1 | FileCheck -check-prefix=WARN_RPATH %s
463463
RUN: ld.lld -### foo.o -m i386pep --rpath=foo 2>&1 | FileCheck -check-prefix=WARN_RPATH %s
464464
WARN_RPATH: warning: parameter -{{-?}}rpath has no effect on PE/COFF targets
465+
466+
RUN: ld.lld -### foo.o -m i386pe --dependent-load-flag=0x800 2>&1 | FileCheck -check-prefix=DEPENDENT_LOAD_FLAG %s
467+
DEPENDENT_LOAD_FLAG: -dependentloadflag:0x800

0 commit comments

Comments
 (0)