Index: MinGW/Driver.cpp =================================================================== --- MinGW/Driver.cpp +++ MinGW/Driver.cpp @@ -212,6 +212,9 @@ else Add("-alternatename:__image_base__=__ImageBase"); + for (auto *A : Args.filtered(OPT_require_defined)) + Add("-include:" + StringRef(A->getValue())); + std::vector SearchPaths; for (auto *A : Args.filtered(OPT_L)) SearchPaths.push_back(A->getValue()); Index: MinGW/Options.td =================================================================== --- MinGW/Options.td +++ MinGW/Options.td @@ -40,6 +40,9 @@ def whole_archive: F<"whole-archive">, HelpText<"Include all object files for following archives">; def verbose: F<"verbose">, HelpText<"Verbose mode">; +def require_defined: S<"require-defined">, + HelpText<"Force symbol to be added to symbol table as an undefined one">; +def require_defined_eq: J<"require-defined=">, Alias; // LLD specific options def _HASH_HASH_HASH : Flag<["-"], "###">, Index: test/MinGW/driver.test =================================================================== --- test/MinGW/driver.test +++ test/MinGW/driver.test @@ -145,3 +145,6 @@ RUN: ld.lld -### foo.o -m i386pep -Map=bar.map | FileCheck -check-prefix=MAP %s RUN: ld.lld -### foo.o -m i386pep --Map=bar.map | FileCheck -check-prefix=MAP %s MAP: -lldmap:bar.map + +RUN: ld.lld -### foo.o -m i386pe -require-defined _foo --require-defined _bar -require-defined=_baz --require-defined=_foo2 | FileCheck -check-prefix=REQUIRE-DEFINED %s +REQUIRE-DEFINED: -include:_foo -include:_bar -include:_baz -include:_foo2