Revert " Fix the ELF shared library build targets"

This reverts commit 6a3f545b44cea46321e025d9ab773786af86cb51.

llvm-svn: 226928
This commit is contained in:
Greg Fitzgerald 2015-01-23 19:24:32 +00:00
parent 30609b8a78
commit ba2bcb0da3
38 changed files with 162 additions and 139 deletions

View File

@ -1,40 +0,0 @@
//===- 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); \
};
#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

View File

@ -24,13 +24,6 @@ add_llvm_library(lldDriver
lldMachO
lldPECOFF
lldELF
lldAArch64ELFTarget
lldARMELFTarget
lldHexagonELFTarget
lldMipsELFTarget
lldPPCELFTarget
lldX86ELFTarget
lldX86_64ELFTarget
lldCore
lldNative
lldReaderWriter

View File

@ -15,7 +15,6 @@
#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"
@ -315,35 +314,6 @@ 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) {
@ -379,7 +349,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
if (!applyEmulation(triple, *parsedArgs, diagnostics))
return false;
std::unique_ptr<ELFLinkingContext> ctx(createELFLinkingContext(triple));
std::unique_ptr<ELFLinkingContext> ctx(ELFLinkingContext::create(triple));
if (!ctx) {
diagnostics << "unknown target triple\n";

View File

@ -10,7 +10,6 @@
#define AARCH64_DYNAMIC_LIBRARY_WRITER_H
#include "AArch64LinkingContext.h"
#include "AArch64TargetHandler.h"
#include "DynamicLibraryWriter.h"
namespace lld {

View File

@ -9,14 +9,9 @@
#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)

View File

@ -10,6 +10,7 @@
#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"
@ -24,7 +25,9 @@ enum {
class AArch64LinkingContext final : public ELFLinkingContext {
public:
AArch64LinkingContext(llvm::Triple);
AArch64LinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new AArch64TargetHandler(*this))) {}
void addPasses(PassManager &) override;

View File

@ -0,0 +1,10 @@
//===- 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"

View File

@ -5,7 +5,5 @@ add_llvm_library(lldAArch64ELFTarget
AArch64RelocationPass.cpp
LINK_LIBS
lldCore
lldELF
LLVMObject
LLVMSupport
)

View File

@ -11,7 +11,6 @@
#include "ExecutableWriter.h"
#include "ARMLinkingContext.h"
#include "ARMTargetHandler.h"
namespace lld {
namespace elf {

View File

@ -9,15 +9,10 @@
#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)

View File

@ -10,7 +10,10 @@
#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"
@ -19,7 +22,9 @@ namespace elf {
class ARMLinkingContext final : public ELFLinkingContext {
public:
ARMLinkingContext(llvm::Triple);
ARMLinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new ARMTargetHandler(*this))) {}
void addPasses(PassManager &) override;

View File

@ -0,0 +1,10 @@
//===--------- 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"

View File

@ -5,7 +5,4 @@ add_llvm_library(lldARMELFTarget
ARMRelocationPass.cpp
LINK_LIBS
lldCore
lldELF
LLVMObject
LLVMSupport
)

View File

@ -4,10 +4,15 @@ add_llvm_library(lldELF
Reader.cpp
Writer.cpp
LINK_LIBS
lldCore
lldHexagonELFTarget
lldMipsELFTarget
lldPPCELFTarget
lldPasses
lldYAML
LLVMSupport
lldReaderWriter
lldX86ELFTarget
lldX86_64ELFTarget
lldAArch64ELFTarget
lldARMELFTarget
)
include_directories(.)

View File

@ -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(llvm::ELF::ET_EXEC), _triple(triple),
: _outputELFType(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::getOutputMachine() const {
}
StringRef ELFLinkingContext::entrySymbolName() const {
if (_outputELFType == llvm::ELF::ET_EXEC && _entrySymbolName.empty())
if (_outputELFType == elf::ET_EXEC && _entrySymbolName.empty())
return "_start";
return _entrySymbolName;
}
@ -129,6 +129,35 @@ bool ELFLinkingContext::isRelativeReloc(const Reference &) const {
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("=/"))

View File

@ -4,7 +4,5 @@ add_llvm_library(lldHexagonELFTarget
HexagonTargetHandler.cpp
LINK_LIBS
lldCore
lldELF
LLVMObject
LLVMSupport
)

View File

@ -0,0 +1,10 @@
//===- 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"

View File

@ -9,7 +9,10 @@
LLD_LEVEL := ../../..
LIBRARYNAME := lldELF
USEDLIBS = lldPasses.a
USEDLIBS = lldHexagonELFTarget.a lldPPCELFTarget.a lldMipsELFTarget.a \
lldX86ELFTarget.a lldX86_64ELFTarget.a lldAArch64ELFTarget.a \
lldARMELFTarget.a \
lldReaderWriter.a lldPasses.a
CPP.Flags += -I$(PROJ_SRC_DIR)/$(LLD_LEVEL)/lib/ReaderWriter/ELF

View File

@ -7,7 +7,5 @@ add_llvm_library(lldMipsELFTarget
MipsTargetHandler.cpp
LINK_LIBS
lldCore
lldELF
LLVMObject
LLVMSupport
)

View File

@ -0,0 +1,10 @@
//===- 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"

View File

@ -3,7 +3,5 @@ add_llvm_library(lldPPCELFTarget
PPCTargetHandler.cpp
LINK_LIBS
lldCore
lldELF
LLVMObject
LLVMSupport
)

View File

@ -8,14 +8,9 @@
//===----------------------------------------------------------------------===//
#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))) {}

View File

@ -10,6 +10,7 @@
#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"
@ -19,7 +20,9 @@ namespace elf {
class PPCLinkingContext final : public ELFLinkingContext {
public:
PPCLinkingContext(llvm::Triple triple);
PPCLinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new PPCTargetHandler(*this))) {}
/// \brief PPC has no relative relocations defined
bool isRelativeReloc(const Reference &) const override { return false; }

View File

@ -0,0 +1,10 @@
//===- 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"

View File

@ -0,0 +1,21 @@
//===- 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

View File

@ -4,7 +4,5 @@ add_llvm_library(lldX86ELFTarget
X86RelocationHandler.cpp
LINK_LIBS
lldCore
lldELF
LLVMObject
LLVMSupport
)

View File

@ -8,13 +8,9 @@
//===----------------------------------------------------------------------===//
#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))) {}

View File

@ -10,6 +10,7 @@
#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"
@ -18,7 +19,9 @@ namespace lld {
namespace elf {
class X86LinkingContext final : public ELFLinkingContext {
public:
X86LinkingContext(llvm::Triple);
X86LinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new X86TargetHandler(*this))) {}
/// \brief X86 has only two relative relocation
/// a) for supporting IFUNC relocs - R_386_IRELATIVE

View File

@ -0,0 +1,10 @@
//===- 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"

View File

@ -5,7 +5,5 @@ add_llvm_library(lldX86_64ELFTarget
X86_64RelocationPass.cpp
LINK_LIBS
lldCore
lldELF
LLVMObject
LLVMSupport
)

View File

@ -11,7 +11,6 @@
#include "DynamicLibraryWriter.h"
#include "X86_64LinkingContext.h"
#include "X86_64TargetHandler.h"
namespace lld {
namespace elf {

View File

@ -8,15 +8,10 @@
//===----------------------------------------------------------------------===//
#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)

View File

@ -10,6 +10,7 @@
#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"
@ -26,7 +27,9 @@ enum {
class X86_64LinkingContext final : public ELFLinkingContext {
public:
X86_64LinkingContext(llvm::Triple);
X86_64LinkingContext(llvm::Triple triple)
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new X86_64TargetHandler(*this))) {}
void addPasses(PassManager &) override;

View File

@ -0,0 +1,10 @@
//===- 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"

View File

@ -16,10 +16,8 @@ add_llvm_library(lldMachO
StubsPass.cpp
WriterMachO.cpp
LINK_LIBS
lldCore
lldReaderWriter
lldPasses
lldYAML
LLVMObject
LLVMSupport
)

View File

@ -9,6 +9,6 @@
LLD_LEVEL := ../../..
LIBRARYNAME := lldMachO
USEDLIBS = lldCore.a
USEDLIBS = lldReaderWriter.a lldCore.a
include $(LLD_LEVEL)/Makefile

View File

@ -10,8 +10,7 @@ add_llvm_library(lldPECOFF
WriterImportLibrary.cpp
WriterPECOFF.cpp
LINK_LIBS
lldCore
lldPasses
lldReaderWriter
LLVMObject
LLVMSupport
)

View File

@ -9,6 +9,6 @@
LLD_LEVEL := ../../..
LIBRARYNAME := lldPECOFF
USEDLIBS = lldCore.a
USEDLIBS = lldReaderWriter.a lldCore.a
include $(LLD_LEVEL)/Makefile