[lld] r226922 - Fix the ELF shared library build targets

Michael Spencer bigcheesegs at gmail.com
Fri Feb 20 16:46:26 PST 2015


On Fri, Jan 23, 2015 at 10:52 AM, Greg Fitzgerald <garious at gmail.com> wrote:
> Author: garious
> Date: Fri Jan 23 12:52:44 2015
> New Revision: 226922
>
> URL: http://llvm.org/viewvc/llvm-project?rev=226922&view=rev
> Log:
>  Fix the ELF shared library build targets
>
>  lldELF is used by each ELF backend.  lldELF's ELFLinkingContext
>  also held a reference to each backend, creating a link-time
>  cycle.  This patch moves the backend references to lldDriver.
>
>  Differential Revision: http://reviews.llvm.org/D7119
>
> Added:
>     lld/trunk/include/lld/ReaderWriter/ELFTargets.h
> Removed:
>     lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64Target.h
>     lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTarget.h
>     lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h
>     lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTarget.h
>     lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTarget.h
>     lld/trunk/lib/ReaderWriter/ELF/Targets.h
>     lld/trunk/lib/ReaderWriter/ELF/X86/X86Target.h
>     lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64Target.h
> Modified:
>     lld/trunk/lib/Driver/CMakeLists.txt
>     lld/trunk/lib/Driver/GnuLdDriver.cpp
>     lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h
>     lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp
>     lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h
>     lld/trunk/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
>     lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp
>     lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h
>     lld/trunk/lib/ReaderWriter/ELF/ARM/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
>     lld/trunk/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/Makefile
>     lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/PPC/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp
>     lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h
>     lld/trunk/lib/ReaderWriter/ELF/X86/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp
>     lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h
>     lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h
>     lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
>     lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h
>     lld/trunk/lib/ReaderWriter/MachO/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/MachO/Makefile
>     lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt
>     lld/trunk/lib/ReaderWriter/PECOFF/Makefile
>
> Added: lld/trunk/include/lld/ReaderWriter/ELFTargets.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFTargets.h?rev=226922&view=auto
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/ELFTargets.h (added)
> +++ lld/trunk/include/lld/ReaderWriter/ELFTargets.h Fri Jan 23 12:52:44 2015
> @@ -0,0 +1,40 @@
> +//===- lld/ReaderWriter/ELFTargets.h --------------------------------------===//
> +//
> +//                             The LLVM Linker
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===----------------------------------------------------------------------===//
> +
> +#ifndef LLD_READER_WRITER_ELF_TARGETS_H
> +#define LLD_READER_WRITER_ELF_TARGETS_H
> +
> +#include "ELFLinkingContext.h"
> +
> +namespace lld {
> +namespace elf {
> +
> +#define LLVM_TARGET(TargetName) \
> +  class TargetName##LinkingContext final : public ELFLinkingContext { \
> +  public: \
> +    TargetName##LinkingContext(llvm::Triple); \
> +  };

This violates the One Definition Rule.

There's no need to try to inject a static function into these. This
can just be a free create##TargetName##LinkingContext(llvm::Tripple)
function.

- Michael Spencer

> +#include "llvm/Config/Targets.def"
> +
> +// X86 => X86,X86_64
> +class X86_64LinkingContext final : public ELFLinkingContext {
> +public:
> +  X86_64LinkingContext(llvm::Triple);
> +};
> +
> +// PowerPC => PPC
> +class PPCLinkingContext final : public ELFLinkingContext {
> +public:
> +  PPCLinkingContext(llvm::Triple);
> +};
> +
> +} // end namespace elf
> +} // end namespace lld
> +
> +#endif
>
> Modified: lld/trunk/lib/Driver/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/Driver/CMakeLists.txt (original)
> +++ lld/trunk/lib/Driver/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -24,6 +24,13 @@ add_llvm_library(lldDriver
>      lldMachO
>      lldPECOFF
>      lldELF
> +    lldAArch64ELFTarget
> +    lldARMELFTarget
> +    lldHexagonELFTarget
> +    lldMipsELFTarget
> +    lldPPCELFTarget
> +    lldX86ELFTarget
> +    lldX86_64ELFTarget
>      lldCore
>      lldNative
>      lldReaderWriter
>
> Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
> +++ lld/trunk/lib/Driver/GnuLdDriver.cpp Fri Jan 23 12:52:44 2015
> @@ -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(
>    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
>    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";
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h Fri Jan 23 12:52:44 2015
> @@ -10,6 +10,7 @@
>  #define AARCH64_DYNAMIC_LIBRARY_WRITER_H
>
>  #include "AArch64LinkingContext.h"
> +#include "AArch64TargetHandler.h"
>  #include "DynamicLibraryWriter.h"
>
>  namespace lld {
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp Fri Jan 23 12:52:44 2015
> @@ -9,9 +9,14 @@
>
>  #include "AArch64LinkingContext.h"
>  #include "AArch64RelocationPass.h"
> +#include "AArch64TargetHandler.h"
>
>  using namespace lld;
>
> +elf::AArch64LinkingContext::AArch64LinkingContext(llvm::Triple triple)
> +    : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> +                        new AArch64TargetHandler(*this))) {}
> +
>  void elf::AArch64LinkingContext::addPasses(PassManager &pm) {
>    auto pass = createAArch64RelocationPass(*this);
>    if (pass)
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h Fri Jan 23 12:52:44 2015
> @@ -10,7 +10,6 @@
>  #ifndef LLD_READER_WRITER_ELF_AARCH64_AARCH64_LINKING_CONTEXT_H
>  #define LLD_READER_WRITER_ELF_AARCH64_AARCH64_LINKING_CONTEXT_H
>
> -#include "AArch64TargetHandler.h"
>  #include "lld/ReaderWriter/ELFLinkingContext.h"
>  #include "llvm/Object/ELF.h"
>  #include "llvm/Support/ELF.h"
> @@ -25,9 +24,7 @@ enum {
>
>  class AArch64LinkingContext final : public ELFLinkingContext {
>  public:
> -  AArch64LinkingContext(llvm::Triple triple)
> -      : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> -                                      new AArch64TargetHandler(*this))) {}
> +  AArch64LinkingContext(llvm::Triple);
>
>    void addPasses(PassManager &) override;
>
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64Target.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64Target.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64Target.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64Target.h (removed)
> @@ -1,10 +0,0 @@
> -//===- lib/ReaderWriter/ELF/AArch64/AArch64Target.h -----------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "AArch64LinkingContext.h"
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -5,5 +5,7 @@ add_llvm_library(lldAArch64ELFTarget
>    AArch64RelocationPass.cpp
>    LINK_LIBS
>      lldCore
> +    lldELF
> +    LLVMObject
>      LLVMSupport
>    )
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h Fri Jan 23 12:52:44 2015
> @@ -11,6 +11,7 @@
>
>  #include "ExecutableWriter.h"
>  #include "ARMLinkingContext.h"
> +#include "ARMTargetHandler.h"
>
>  namespace lld {
>  namespace elf {
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp Fri Jan 23 12:52:44 2015
> @@ -9,10 +9,15 @@
>
>  #include "ARMLinkingContext.h"
>  #include "ARMRelocationPass.h"
> +#include "ARMTargetHandler.h"
>
>  using namespace lld;
>  using namespace lld::elf;
>
> +elf::ARMLinkingContext::ARMLinkingContext(llvm::Triple triple)
> +    : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> +                        new ARMTargetHandler(*this))) {}
> +
>  void elf::ARMLinkingContext::addPasses(PassManager &pm) {
>    auto pass = createARMRelocationPass(*this);
>    if (pass)
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h Fri Jan 23 12:52:44 2015
> @@ -10,10 +10,7 @@
>  #ifndef LLD_READER_WRITER_ELF_ARM_ARM_LINKING_CONTEXT_H
>  #define LLD_READER_WRITER_ELF_ARM_ARM_LINKING_CONTEXT_H
>
> -#include "ARMTargetHandler.h"
> -
>  #include "lld/ReaderWriter/ELFLinkingContext.h"
> -
>  #include "llvm/Object/ELF.h"
>  #include "llvm/Support/ELF.h"
>
> @@ -22,9 +19,7 @@ namespace elf {
>
>  class ARMLinkingContext final : public ELFLinkingContext {
>  public:
> -  ARMLinkingContext(llvm::Triple triple)
> -      : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> -                                      new ARMTargetHandler(*this))) {}
> +  ARMLinkingContext(llvm::Triple);
>
>    void addPasses(PassManager &) override;
>
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTarget.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTarget.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTarget.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMTarget.h (removed)
> @@ -1,10 +0,0 @@
> -//===--------- lib/ReaderWriter/ELF/ARM/ARMTarget.h -----------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "ARMLinkingContext.h"
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ARM/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ARM/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -5,4 +5,7 @@ add_llvm_library(lldARMELFTarget
>    ARMRelocationPass.cpp
>    LINK_LIBS
>      lldCore
> +    lldELF
> +    LLVMObject
> +    LLVMSupport
>    )
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -4,15 +4,10 @@ add_llvm_library(lldELF
>    Reader.cpp
>    Writer.cpp
>    LINK_LIBS
> -    lldHexagonELFTarget
> -    lldMipsELFTarget
> -    lldPPCELFTarget
> +    lldCore
>      lldPasses
> -    lldReaderWriter
> -    lldX86ELFTarget
> -    lldX86_64ELFTarget
> -    lldAArch64ELFTarget
> -    lldARMELFTarget
> +    lldYAML
> +    LLVMSupport
>    )
>
>  include_directories(.)
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Fri Jan 23 12:52:44 2015
> @@ -11,8 +11,8 @@
>  #include "ArrayOrderPass.h"
>  #include "ELFFile.h"
>  #include "TargetHandler.h"
> -#include "Targets.h"
>  #include "lld/Core/Instrumentation.h"
> +#include "lld/Core/SharedLibraryFile.h"
>  #include "lld/Passes/LayoutPass.h"
>  #include "lld/Passes/RoundTripYAMLPass.h"
>  #include "llvm/ADT/Triple.h"
> @@ -56,7 +56,7 @@ public:
>
>  ELFLinkingContext::ELFLinkingContext(
>      llvm::Triple triple, std::unique_ptr<TargetHandlerBase> targetHandler)
> -    : _outputELFType(elf::ET_EXEC), _triple(triple),
> +    : _outputELFType(llvm::ELF::ET_EXEC), _triple(triple),
>        _targetHandler(std::move(targetHandler)), _baseAddress(0),
>        _isStaticExecutable(false), _noInhibitExec(false), _exportDynamic(false),
>        _mergeCommonStrings(false), _runLayoutPass(true),
> @@ -93,7 +93,7 @@ uint16_t ELFLinkingContext::getOutputMac
>  }
>
>  StringRef ELFLinkingContext::entrySymbolName() const {
> -  if (_outputELFType == elf::ET_EXEC && _entrySymbolName.empty())
> +  if (_outputELFType == llvm::ELF::ET_EXEC && _entrySymbolName.empty())
>      return "_start";
>    return _entrySymbolName;
>  }
> @@ -129,35 +129,6 @@ bool ELFLinkingContext::isRelativeReloc(
>
>  Writer &ELFLinkingContext::writer() const { return *_writer; }
>
> -std::unique_ptr<ELFLinkingContext>
> -ELFLinkingContext::create(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;
> -  }
> -}
> -
>  static void buildSearchPath(SmallString<128> &path, StringRef dir,
>                              StringRef sysRoot) {
>    if (!dir.startswith("=/"))
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -4,5 +4,7 @@ add_llvm_library(lldHexagonELFTarget
>    HexagonTargetHandler.cpp
>    LINK_LIBS
>      lldCore
> +    lldELF
> +    LLVMObject
>      LLVMSupport
>    )
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h (removed)
> @@ -1,10 +0,0 @@
> -//===- lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h -----------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "HexagonLinkingContext.h"
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Makefile
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Makefile?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Makefile (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Makefile Fri Jan 23 12:52:44 2015
> @@ -9,10 +9,7 @@
>
>  LLD_LEVEL := ../../..
>  LIBRARYNAME := lldELF
> -USEDLIBS = lldHexagonELFTarget.a lldPPCELFTarget.a lldMipsELFTarget.a \
> -           lldX86ELFTarget.a lldX86_64ELFTarget.a lldAArch64ELFTarget.a \
> -           lldARMELFTarget.a \
> -           lldReaderWriter.a lldPasses.a
> +USEDLIBS = lldPasses.a
>
>  CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLD_LEVEL)/lib/ReaderWriter/ELF
>
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -7,5 +7,7 @@ add_llvm_library(lldMipsELFTarget
>    MipsTargetHandler.cpp
>    LINK_LIBS
>      lldCore
> +    lldELF
> +    LLVMObject
>      LLVMSupport
>    )
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTarget.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTarget.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTarget.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsTarget.h (removed)
> @@ -1,10 +0,0 @@
> -//===- lib/ReaderWriter/ELF/Mips/MipsTarget.h -----------------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "MipsLinkingContext.h"
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/PPC/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/PPC/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/PPC/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/PPC/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -3,5 +3,7 @@ add_llvm_library(lldPPCELFTarget
>    PPCTargetHandler.cpp
>    LINK_LIBS
>      lldCore
> +    lldELF
> +    LLVMObject
>      LLVMSupport
>    )
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp Fri Jan 23 12:52:44 2015
> @@ -8,9 +8,14 @@
>  //===----------------------------------------------------------------------===//
>
>  #include "PPCLinkingContext.h"
> +#include "PPCTargetHandler.h"
>  #include "lld/Core/LLVM.h"
>  #include "llvm/ADT/StringSwitch.h"
>  #include "llvm/Support/ErrorOr.h"
>
>  using namespace lld;
>
> +elf::PPCLinkingContext::PPCLinkingContext(llvm::Triple triple)
> +    : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> +                        new PPCTargetHandler(*this))) {}
> +
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h Fri Jan 23 12:52:44 2015
> @@ -10,7 +10,6 @@
>  #ifndef LLD_READER_WRITER_ELF_PPC_PPC_LINKING_CONTEXT_H
>  #define LLD_READER_WRITER_ELF_PPC_PPC_LINKING_CONTEXT_H
>
> -#include "PPCTargetHandler.h"
>  #include "lld/ReaderWriter/ELFLinkingContext.h"
>  #include "llvm/Object/ELF.h"
>  #include "llvm/Support/ELF.h"
> @@ -20,9 +19,7 @@ namespace elf {
>
>  class PPCLinkingContext final : public ELFLinkingContext {
>  public:
> -  PPCLinkingContext(llvm::Triple triple)
> -      : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> -                                      new PPCTargetHandler(*this))) {}
> +  PPCLinkingContext(llvm::Triple triple);
>
>    /// \brief PPC has no relative relocations defined
>    bool isRelativeReloc(const Reference &) const override { return false; }
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTarget.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTarget.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTarget.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/PPC/PPCTarget.h (removed)
> @@ -1,10 +0,0 @@
> -//===- lib/ReaderWriter/ELF/PPC/PPCTarget.h -------------------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "PPCLinkingContext.h"
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/Targets.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Targets.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/Targets.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/Targets.h (removed)
> @@ -1,21 +0,0 @@
> -//===- lib/ReaderWriter/ELF/Targets.h -------------------------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#ifndef LLD_READER_WRITER_ELF_TARGETS_H
> -#define LLD_READER_WRITER_ELF_TARGETS_H
> -
> -#include "AArch64/AArch64Target.h"
> -#include "ARM/ARMTarget.h"
> -#include "Hexagon/HexagonTarget.h"
> -#include "Mips/MipsTarget.h"
> -#include "PPC/PPCTarget.h"
> -#include "X86/X86Target.h"
> -#include "X86_64/X86_64Target.h"
> -
> -#endif
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -4,5 +4,7 @@ add_llvm_library(lldX86ELFTarget
>    X86RelocationHandler.cpp
>    LINK_LIBS
>      lldCore
> +    lldELF
> +    LLVMObject
>      LLVMSupport
>    )
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp Fri Jan 23 12:52:44 2015
> @@ -8,9 +8,13 @@
>  //===----------------------------------------------------------------------===//
>
>  #include "X86LinkingContext.h"
> +#include "X86TargetHandler.h"
>  #include "lld/Core/LLVM.h"
>  #include "llvm/ADT/StringSwitch.h"
>  #include "llvm/Support/ErrorOr.h"
>
>  using namespace lld;
>
> +elf::X86LinkingContext::X86LinkingContext(llvm::Triple triple)
> +    : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> +                        new X86TargetHandler(*this))) {}
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86LinkingContext.h Fri Jan 23 12:52:44 2015
> @@ -10,7 +10,6 @@
>  #ifndef LLD_READER_WRITER_ELF_X86_TARGETINFO_H
>  #define LLD_READER_WRITER_ELF_X86_TARGETINFO_H
>
> -#include "X86TargetHandler.h"
>  #include "lld/ReaderWriter/ELFLinkingContext.h"
>  #include "llvm/Object/ELF.h"
>  #include "llvm/Support/ELF.h"
> @@ -19,9 +18,7 @@ namespace lld {
>  namespace elf {
>  class X86LinkingContext final : public ELFLinkingContext {
>  public:
> -  X86LinkingContext(llvm::Triple triple)
> -      : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> -                                      new X86TargetHandler(*this))) {}
> +  X86LinkingContext(llvm::Triple);
>
>    /// \brief X86 has only two relative relocation
>    /// a) for supporting IFUNC relocs - R_386_IRELATIVE
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/X86/X86Target.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86/X86Target.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86/X86Target.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86/X86Target.h (removed)
> @@ -1,10 +0,0 @@
> -//===- lib/ReaderWriter/ELF/X86/X86Target.h -------------------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "X86LinkingContext.h"
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -5,5 +5,7 @@ add_llvm_library(lldX86_64ELFTarget
>    X86_64RelocationPass.cpp
>    LINK_LIBS
>      lldCore
> +    lldELF
> +    LLVMObject
>      LLVMSupport
>    )
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h Fri Jan 23 12:52:44 2015
> @@ -11,6 +11,7 @@
>
>  #include "DynamicLibraryWriter.h"
>  #include "X86_64LinkingContext.h"
> +#include "X86_64TargetHandler.h"
>
>  namespace lld {
>  namespace elf {
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp Fri Jan 23 12:52:44 2015
> @@ -8,10 +8,15 @@
>  //===----------------------------------------------------------------------===//
>
>  #include "X86_64LinkingContext.h"
> +#include "X86_64TargetHandler.h"
>  #include "X86_64RelocationPass.h"
>
>  using namespace lld;
>
> +elf::X86_64LinkingContext::X86_64LinkingContext(llvm::Triple triple)
> +    : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> +                        new X86_64TargetHandler(*this))) {}
> +
>  void elf::X86_64LinkingContext::addPasses(PassManager &pm) {
>    auto pass = createX86_64RelocationPass(*this);
>    if (pass)
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h Fri Jan 23 12:52:44 2015
> @@ -10,7 +10,6 @@
>  #ifndef LLD_READER_WRITER_ELF_X86_64_X86_64_LINKING_CONTEXT_H
>  #define LLD_READER_WRITER_ELF_X86_64_X86_64_LINKING_CONTEXT_H
>
> -#include "X86_64TargetHandler.h"
>  #include "lld/ReaderWriter/ELFLinkingContext.h"
>  #include "llvm/Object/ELF.h"
>  #include "llvm/Support/ELF.h"
> @@ -27,9 +26,7 @@ enum {
>
>  class X86_64LinkingContext final : public ELFLinkingContext {
>  public:
> -  X86_64LinkingContext(llvm::Triple triple)
> -      : ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
> -                                      new X86_64TargetHandler(*this))) {}
> +  X86_64LinkingContext(llvm::Triple);
>
>    void addPasses(PassManager &) override;
>
>
> Removed: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64Target.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64Target.h?rev=226921&view=auto
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64Target.h (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64Target.h (removed)
> @@ -1,10 +0,0 @@
> -//===- lib/ReaderWriter/ELF/X86_64/X86_64Target.h -------------------------===//
> -//
> -//                             The LLVM Linker
> -//
> -// This file is distributed under the University of Illinois Open Source
> -// License. See LICENSE.TXT for details.
> -//
> -//===----------------------------------------------------------------------===//
> -
> -#include "X86_64LinkingContext.h"
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -16,8 +16,10 @@ add_llvm_library(lldMachO
>    StubsPass.cpp
>    WriterMachO.cpp
>    LINK_LIBS
> -    lldReaderWriter
> +    lldCore
>      lldPasses
> +    lldYAML
> +    LLVMObject
>      LLVMSupport
>    )
>
>
> Modified: lld/trunk/lib/ReaderWriter/MachO/Makefile
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/Makefile?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/MachO/Makefile (original)
> +++ lld/trunk/lib/ReaderWriter/MachO/Makefile Fri Jan 23 12:52:44 2015
> @@ -9,6 +9,6 @@
>
>  LLD_LEVEL := ../../..
>  LIBRARYNAME := lldMachO
> -USEDLIBS = lldReaderWriter.a lldCore.a
> +USEDLIBS = lldCore.a
>
>  include $(LLD_LEVEL)/Makefile
>
> Modified: lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt (original)
> +++ lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt Fri Jan 23 12:52:44 2015
> @@ -10,7 +10,8 @@ add_llvm_library(lldPECOFF
>    WriterImportLibrary.cpp
>    WriterPECOFF.cpp
>    LINK_LIBS
> -    lldReaderWriter
> +    lldCore
> +    lldPasses
>      LLVMObject
>      LLVMSupport
>    )
>
> Modified: lld/trunk/lib/ReaderWriter/PECOFF/Makefile
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/Makefile?rev=226922&r1=226921&r2=226922&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/PECOFF/Makefile (original)
> +++ lld/trunk/lib/ReaderWriter/PECOFF/Makefile Fri Jan 23 12:52:44 2015
> @@ -9,6 +9,6 @@
>
>  LLD_LEVEL := ../../..
>  LIBRARYNAME := lldPECOFF
> -USEDLIBS = lldReaderWriter.a lldCore.a
> +USEDLIBS = lldCore.a
>
>  include $(LLD_LEVEL)/Makefile
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list