summaryrefslogtreecommitdiffstats
path: root/lld/lib/Driver/GnuLdDriver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/lib/Driver/GnuLdDriver.cpp')
-rw-r--r--lld/lib/Driver/GnuLdDriver.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/lld/lib/Driver/GnuLdDriver.cpp b/lld/lib/Driver/GnuLdDriver.cpp
index 612a5f256a2..fb58550fc1d 100644
--- a/lld/lib/Driver/GnuLdDriver.cpp
+++ b/lld/lib/Driver/GnuLdDriver.cpp
@@ -15,6 +15,7 @@
#include "lld/Driver/Driver.h"
#include "lld/ReaderWriter/ELFLinkingContext.h"
+#include "lld/ReaderWriter/ELFTargets.h"
#include "lld/ReaderWriter/LinkerScript.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Optional.h"
@@ -314,6 +315,35 @@ void GnuLdDriver::addPlatformSearchDirs(ELFLinkingContext &ctx,
ctx.addSearchPath("=/usr/lib");
}
+std::unique_ptr<ELFLinkingContext>
+createELFLinkingContext(llvm::Triple triple) {
+ switch (triple.getArch()) {
+ case llvm::Triple::x86:
+ return std::unique_ptr<ELFLinkingContext>(
+ new lld::elf::X86LinkingContext(triple));
+ case llvm::Triple::x86_64:
+ return std::unique_ptr<ELFLinkingContext>(
+ new lld::elf::X86_64LinkingContext(triple));
+ case llvm::Triple::hexagon:
+ return std::unique_ptr<ELFLinkingContext>(
+ new lld::elf::HexagonLinkingContext(triple));
+ case llvm::Triple::mipsel:
+ return std::unique_ptr<ELFLinkingContext>(
+ new lld::elf::MipsLinkingContext(triple));
+ case llvm::Triple::ppc:
+ return std::unique_ptr<ELFLinkingContext>(
+ new lld::elf::PPCLinkingContext(triple));
+ case llvm::Triple::aarch64:
+ return std::unique_ptr<ELFLinkingContext>(
+ new lld::elf::AArch64LinkingContext(triple));
+ case llvm::Triple::arm:
+ return std::unique_ptr<ELFLinkingContext>(
+ new lld::elf::ARMLinkingContext(triple));
+ default:
+ return nullptr;
+ }
+}
+
bool GnuLdDriver::parse(int argc, const char *argv[],
std::unique_ptr<ELFLinkingContext> &context,
raw_ostream &diagnostics) {
@@ -349,7 +379,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
if (!applyEmulation(triple, *parsedArgs, diagnostics))
return false;
- std::unique_ptr<ELFLinkingContext> ctx(ELFLinkingContext::create(triple));
+ std::unique_ptr<ELFLinkingContext> ctx(createELFLinkingContext(triple));
if (!ctx) {
diagnostics << "unknown target triple\n";
OpenPOWER on IntegriCloud