diff options
author | Martell Malone <martellmalone@gmail.com> | 2017-09-11 17:02:59 +0000 |
---|---|---|
committer | Martell Malone <martellmalone@gmail.com> | 2017-09-11 17:02:59 +0000 |
commit | b42b3bc59f5a071f04ace2ee72e4b9fd326e3b82 (patch) | |
tree | a9c211f39a48f3bc4c637f8820c93eeeacc362fc /tools/lld/lld.cpp | |
parent | ee085a3fb368deb81fbe398db0606f8ba2c4e70b (diff) |
LLD: Introduce a GNU LD style driver for COFF
When building COFF programs many targets such as mingw prefer
to have a gnu ld frontend. Rather then having a fully fledged
standalone driver we wrap a shim around the LINK driver.
Extra tests were provided by mstorsjo
Reviewers: mstorsjo, ruiu
Differential Revision: https://reviews.llvm.org/D33880
git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@312926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lld/lld.cpp')
-rw-r--r-- | tools/lld/lld.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/lld/lld.cpp b/tools/lld/lld.cpp index 09f807901..3b45aecd7 100644 --- a/tools/lld/lld.cpp +++ b/tools/lld/lld.cpp @@ -49,6 +49,16 @@ static Flavor getFlavor(StringRef S) { .Default(Invalid); } +static bool isPETarget(const std::vector<const char *> &V) { + for (auto It = V.begin(); It + 1 != V.end(); ++It) { + if (StringRef(*It) != "-m") + continue; + StringRef S = *(It + 1); + return S == "i386pe" || S == "i386pep" || S == "thumb2pe" || S == "arm64pe"; + } + return false; +} + static Flavor parseProgname(StringRef Progname) { #if __APPLE__ // Use Darwin driver for "ld" on Darwin. @@ -101,6 +111,8 @@ int main(int Argc, const char **Argv) { std::vector<const char *> Args(Argv, Argv + Argc); switch (parseFlavor(Args)) { case Gnu: + if (isPETarget(Args)) + return !mingw::link(Args); return !elf::link(Args, true); case WinLink: return !coff::link(Args); |