Index: include/lld/ReaderWriter/ELF/AArch64LinkingContext.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/AArch64LinkingContext.h @@ -0,0 +1,96 @@ +//===- lld/ReaderWriter/ELF/AArch64LinkingContext.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_AARCH64_LINKING_CONTEXT_H +#define LLD_READER_WRITER_ELF_AARCH64_LINKING_CONTEXT_H + +#include "lld/ReaderWriter/ELFLinkingContext.h" +#include "llvm/Object/ELF.h" +#include "llvm/Support/ELF.h" + +namespace lld { +namespace elf { + +enum { + /// \brief The offset to add operation for a R_AARCH64_ADR_GOT_PAGE + ADD_AARCH64_GOTRELINDEX = 0xE000, +}; + +class AArch64LinkingContext final : public ELFLinkingContext { +public: + AArch64LinkingContext(llvm::Triple); + + void addPasses(PassManager &) override; + + uint64_t getBaseAddress() const override { + if (_baseAddress == 0) + return 0x400000; + return _baseAddress; + } + + bool isDynamicRelocation(const DefinedAtom &, + const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::AArch64); + switch (r.kindValue()) { + case llvm::ELF::R_AARCH64_COPY: + case llvm::ELF::R_AARCH64_GLOB_DAT: + case llvm::ELF::R_AARCH64_RELATIVE: + case llvm::ELF::R_AARCH64_TLS_DTPREL64: + case llvm::ELF::R_AARCH64_TLS_DTPMOD64: + case llvm::ELF::R_AARCH64_TLS_TPREL64: + case llvm::ELF::R_AARCH64_TLSDESC: + case llvm::ELF::R_AARCH64_IRELATIVE: + return true; + default: + return false; + } + } + + bool isCopyRelocation(const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::AArch64); + if (r.kindValue() == llvm::ELF::R_AARCH64_COPY) + return true; + return false; + } + + bool isPLTRelocation(const DefinedAtom &, + const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::AArch64); + switch (r.kindValue()) { + case llvm::ELF::R_AARCH64_JUMP_SLOT: + case llvm::ELF::R_AARCH64_IRELATIVE: + return true; + default: + return false; + } + } + + bool isRelativeReloc(const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::AArch64); + switch (r.kindValue()) { + case llvm::ELF::R_AARCH64_IRELATIVE: + case llvm::ELF::R_AARCH64_RELATIVE: + return true; + default: + return false; + } + } +}; +} // end namespace elf +} // end namespace lld + +#endif Index: include/lld/ReaderWriter/ELF/ARMLinkingContext.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/ARMLinkingContext.h @@ -0,0 +1,36 @@ +//===--------- lld/ReaderWriter/ELF/ARMLinkingContext.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_ARM_LINKING_CONTEXT_H +#define LLD_READER_WRITER_ELF_ARM_LINKING_CONTEXT_H + +#include "lld/ReaderWriter/ELFLinkingContext.h" + +#include "llvm/Object/ELF.h" +#include "llvm/Support/ELF.h" + +namespace lld { +namespace elf { + +class ARMLinkingContext final : public ELFLinkingContext { +public: + ARMLinkingContext(llvm::Triple); + + void addPasses(PassManager &) override; + + uint64_t getBaseAddress() const override { + if (_baseAddress == 0) + return 0x400000; + return _baseAddress; + } +}; +} // end namespace elf +} // end namespace lld + +#endif Index: include/lld/ReaderWriter/ELF/HexagonLinkingContext.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/HexagonLinkingContext.h @@ -0,0 +1,69 @@ +//===- lld/ReaderWriter/ELF/HexagonLinkingContext.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_HEXAGON_LINKING_CONTEXT_H +#define LLD_READER_WRITER_ELF_HEXAGON_LINKING_CONTEXT_H + +#include "lld/ReaderWriter/ELFLinkingContext.h" +#include "llvm/Object/ELF.h" +#include "llvm/Support/ELF.h" + +namespace lld { +namespace elf { + +typedef llvm::object::ELFType HexagonELFType; + +class HexagonLinkingContext final : public ELFLinkingContext { +public: + HexagonLinkingContext(llvm::Triple); + + void addPasses(PassManager &) override; + + bool isDynamicRelocation(const DefinedAtom &, + const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + switch (r.kindValue()) { + case llvm::ELF::R_HEX_RELATIVE: + case llvm::ELF::R_HEX_GLOB_DAT: + return true; + default: + return false; + } + } + + bool isPLTRelocation(const DefinedAtom &, const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + switch (r.kindValue()) { + case llvm::ELF::R_HEX_JMP_SLOT: + return true; + default: + return false; + } + } + + /// \brief Hexagon has only one relative relocation + /// a) for supporting relative relocs - R_HEX_RELATIVE + bool isRelativeReloc(const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + switch (r.kindValue()) { + case llvm::ELF::R_HEX_RELATIVE: + return true; + default: + return false; + } + } +}; + +} // elf +} // lld + +#endif // LLD_READER_WRITER_ELF_HEXAGON_HEXAGON_LINKING_CONTEXT_H Index: include/lld/ReaderWriter/ELF/MipsELFFlagsMerger.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/MipsELFFlagsMerger.h @@ -0,0 +1,35 @@ +//===- lld/ReaderWriter/ELF/MipsELFFlagsMerger.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_MIPS_ELF_FLAGS_MERGER_H +#define LLD_READER_WRITER_ELF_MIPS_ELF_FLAGS_MERGER_H + +#include +#include + +namespace lld { +namespace elf { + +class MipsELFFlagsMerger { +public: + MipsELFFlagsMerger(); + + uint32_t getMergedELFFlags() const; + + /// \brief Merge saved ELF header flags and the new set of flags. + std::error_code merge(uint8_t newClass, uint32_t newFlags); + +private: + std::mutex _mutex; + uint32_t _flags; +}; + +} // namespace elf +} // namespace lld + +#endif Index: include/lld/ReaderWriter/ELF/MipsLinkingContext.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/MipsLinkingContext.h @@ -0,0 +1,65 @@ +//===- lld/ReaderWriter/ELF/MipsLinkingContext.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_MIPS_LINKING_CONTEXT_H +#define LLD_READER_WRITER_ELF_MIPS_LINKING_CONTEXT_H + +#include "lld/ReaderWriter/ELF/MipsELFFlagsMerger.h" +#include "lld/ReaderWriter/ELFLinkingContext.h" + +namespace lld { +namespace elf { + +/// \brief Mips internal references. +enum { + /// \brief Do nothing but mark GOT entry as a global one. + LLD_R_MIPS_GLOBAL_GOT = 1024, + /// \brief Apply high 16 bits of symbol + addend. + LLD_R_MIPS_32_HI16 = 1025, + /// \brief The same as R_MIPS_26 but for global symbols. + LLD_R_MIPS_GLOBAL_26 = 1026, + /// \brief Setup hi 16 bits using the symbol this reference refers to. + LLD_R_MIPS_HI16 = 1027, + /// \brief Setup low 16 bits using the symbol this reference refers to. + LLD_R_MIPS_LO16 = 1028, + /// \brief Represents a reference between PLT and dynamic symbol. + LLD_R_MIPS_STO_PLT = 1029, + /// \brief The same as R_MICROMIPS_26_S1 but for global symbols. + LLD_R_MICROMIPS_GLOBAL_26_S1 = 1030, +}; + +typedef llvm::object::ELFType Mips32ElELFType; + +template class MipsTargetLayout; + +class MipsLinkingContext final : public ELFLinkingContext { +public: + MipsLinkingContext(llvm::Triple); + + uint32_t getMergedELFFlags() const; + MipsELFFlagsMerger &getELFFlagsMerger(); + + // ELFLinkingContext + uint64_t getBaseAddress() const override; + StringRef entrySymbolName() const override; + StringRef getDefaultInterpreter() const override; + void addPasses(PassManager &pm) override; + bool isRelaOutputFormat() const override { return false; } + bool isDynamicRelocation(const DefinedAtom &, + const Reference &r) const override; + bool isCopyRelocation(const Reference &r) const override; + bool isPLTRelocation(const DefinedAtom &, const Reference &r) const override; + +private: + MipsELFFlagsMerger _flagsMerger; +}; + +} // elf +} // lld + +#endif Index: include/lld/ReaderWriter/ELF/PPCLinkingContext.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/PPCLinkingContext.h @@ -0,0 +1,31 @@ +//===- lld/ReaderWriter/ELF/PPCLinkingContext.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_PPC_LINKING_CONTEXT_H +#define LLD_READER_WRITER_ELF_PPC_LINKING_CONTEXT_H + +#include "lld/ReaderWriter/ELFLinkingContext.h" +#include "llvm/Object/ELF.h" +#include "llvm/Support/ELF.h" + +namespace lld { +namespace elf { + +class PPCLinkingContext final : public ELFLinkingContext { +public: + PPCLinkingContext(llvm::Triple); + + /// \brief PPC has no relative relocations defined + bool isRelativeReloc(const Reference &) const override { return false; } +}; + +} // elf +} // lld + +#endif // LLD_READER_WRITER_ELF_PPC_PPC_LINKING_CONTEXT_H Index: include/lld/ReaderWriter/ELF/Targets.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/Targets.h @@ -0,0 +1,21 @@ +//===- lld/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 "AArch64LinkingContext.h" +#include "ARMLinkingContext.h" +#include "HexagonLinkingContext.h" +#include "MipsLinkingContext.h" +#include "PPCLinkingContext.h" +#include "X86LinkingContext.h" +#include "X86_64LinkingContext.h" + +#endif Index: include/lld/ReaderWriter/ELF/X86LinkingContext.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/X86LinkingContext.h @@ -0,0 +1,41 @@ +//===- lld/ReaderWriter/ELF/X86LinkingContext.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_X86_LINKING_CONTEXT_H +#define LLD_READER_WRITER_ELF_X86_LINKING_CONTEXT_H + +#include "lld/ReaderWriter/ELFLinkingContext.h" +#include "llvm/Object/ELF.h" +#include "llvm/Support/ELF.h" + +namespace lld { +namespace elf { +class X86LinkingContext final : public ELFLinkingContext { +public: + X86LinkingContext(llvm::Triple); + + /// \brief X86 has only two relative relocation + /// a) for supporting IFUNC relocs - R_386_IRELATIVE + /// b) for supporting relative relocs - R_386_RELATIVE + bool isRelativeReloc(const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::x86); + switch (r.kindValue()) { + case llvm::ELF::R_386_IRELATIVE: + case llvm::ELF::R_386_RELATIVE: + return true; + default: + return false; + } + } +}; +} // end namespace elf +} // end namespace lld +#endif Index: include/lld/ReaderWriter/ELF/X86_64LinkingContext.h =================================================================== --- /dev/null +++ include/lld/ReaderWriter/ELF/X86_64LinkingContext.h @@ -0,0 +1,98 @@ +//===- lld/ReaderWriter/ELF/X86_64LinkingContext.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_X86_64_LINKING_CONTEXT_H +#define LLD_READER_WRITER_ELF_X86_64_LINKING_CONTEXT_H + +#include "lld/ReaderWriter/ELFLinkingContext.h" +#include "llvm/Object/ELF.h" +#include "llvm/Support/ELF.h" + +namespace lld { +namespace elf { + +/// \brief x86-64 internal references. +enum { + /// \brief The 32 bit index of the relocation in the got this reference refers + /// to. + LLD_R_X86_64_GOTRELINDEX = 1024, +}; + +class X86_64LinkingContext final : public ELFLinkingContext { +public: + X86_64LinkingContext(llvm::Triple); + + void addPasses(PassManager &) override; + + uint64_t getBaseAddress() const override { + if (_baseAddress == 0) + return 0x400000; + return _baseAddress; + } + + bool isDynamicRelocation(const DefinedAtom &, + const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::x86_64); + switch (r.kindValue()) { + case llvm::ELF::R_X86_64_RELATIVE: + case llvm::ELF::R_X86_64_GLOB_DAT: + case llvm::ELF::R_X86_64_COPY: + case llvm::ELF::R_X86_64_DTPMOD64: + case llvm::ELF::R_X86_64_DTPOFF64: + return true; + default: + return false; + } + } + + bool isCopyRelocation(const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::x86_64); + if (r.kindValue() == llvm::ELF::R_X86_64_COPY) + return true; + return false; + } + + virtual bool isPLTRelocation(const DefinedAtom &, + const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::x86_64); + switch (r.kindValue()) { + case llvm::ELF::R_X86_64_JUMP_SLOT: + case llvm::ELF::R_X86_64_IRELATIVE: + return true; + default: + return false; + } + } + + /// \brief X86_64 has two relative relocations + /// a) for supporting IFUNC - R_X86_64_IRELATIVE + /// b) for supporting relative relocs - R_X86_64_RELATIVE + bool isRelativeReloc(const Reference &r) const override { + if (r.kindNamespace() != Reference::KindNamespace::ELF) + return false; + assert(r.kindArch() == Reference::KindArch::x86_64); + switch (r.kindValue()) { + case llvm::ELF::R_X86_64_IRELATIVE: + case llvm::ELF::R_X86_64_RELATIVE: + return true; + default: + return false; + } + } +}; +} // end namespace elf +} // end namespace lld + +#endif Index: lib/Driver/CMakeLists.txt =================================================================== --- lib/Driver/CMakeLists.txt +++ lib/Driver/CMakeLists.txt @@ -24,6 +24,13 @@ lldMachO lldPECOFF lldELF + lldHexagonELFTarget + lldMipsELFTarget + lldPPCELFTarget + lldX86ELFTarget + lldX86_64ELFTarget + lldAArch64ELFTarget + lldARMELFTarget lldCore lldNative lldReaderWriter Index: lib/Driver/GnuLdDriver.cpp =================================================================== --- lib/Driver/GnuLdDriver.cpp +++ lib/Driver/GnuLdDriver.cpp @@ -14,6 +14,7 @@ //===----------------------------------------------------------------------===// #include "lld/Driver/Driver.h" +#include "lld/ReaderWriter/ELF/Targets.h" #include "lld/ReaderWriter/ELFLinkingContext.h" #include "lld/ReaderWriter/LinkerScript.h" #include "llvm/ADT/ArrayRef.h" @@ -314,6 +315,35 @@ ctx.addSearchPath("=/usr/lib"); } +std::unique_ptr +createELFLinkingContext(llvm::Triple triple) { + switch (triple.getArch()) { + case llvm::Triple::x86: + return std::unique_ptr( + new lld::elf::X86LinkingContext(triple)); + case llvm::Triple::x86_64: + return std::unique_ptr( + new lld::elf::X86_64LinkingContext(triple)); + case llvm::Triple::hexagon: + return std::unique_ptr( + new lld::elf::HexagonLinkingContext(triple)); + case llvm::Triple::mipsel: + return std::unique_ptr( + new lld::elf::MipsLinkingContext(triple)); + case llvm::Triple::ppc: + return std::unique_ptr( + new lld::elf::PPCLinkingContext(triple)); + case llvm::Triple::aarch64: + return std::unique_ptr( + new lld::elf::AArch64LinkingContext(triple)); + case llvm::Triple::arm: + return std::unique_ptr( + new lld::elf::ARMLinkingContext(triple)); + default: + return nullptr; + } +} + bool GnuLdDriver::parse(int argc, const char *argv[], std::unique_ptr &context, raw_ostream &diagnostics) { @@ -349,7 +379,7 @@ if (!applyEmulation(triple, *parsedArgs, diagnostics)) return false; - std::unique_ptr ctx(ELFLinkingContext::create(triple)); + std::unique_ptr ctx(createELFLinkingContext(triple)); if (!ctx) { diagnostics << "unknown target triple\n"; Index: lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/AArch64/AArch64DynamicLibraryWriter.h @@ -9,7 +9,8 @@ #ifndef AARCH64_DYNAMIC_LIBRARY_WRITER_H #define AARCH64_DYNAMIC_LIBRARY_WRITER_H -#include "AArch64LinkingContext.h" +#include "lld/ReaderWriter/ELF/AArch64LinkingContext.h" +#include "AArch64TargetHandler.h" #include "DynamicLibraryWriter.h" namespace lld { Index: lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.h +++ lib/ReaderWriter/ELF/AArch64/AArch64ExecutableWriter.h @@ -9,7 +9,7 @@ #ifndef AARCH64_EXECUTABLE_WRITER_H #define AARCH64_EXECUTABLE_WRITER_H -#include "AArch64LinkingContext.h" +#include "lld/ReaderWriter/ELF/AArch64LinkingContext.h" #include "ExecutableWriter.h" namespace lld { Index: lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.h +++ /dev/null @@ -1,99 +0,0 @@ -//===- lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.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_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" - -namespace lld { -namespace elf { - -enum { - /// \brief The offset to add operation for a R_AARCH64_ADR_GOT_PAGE - ADD_AARCH64_GOTRELINDEX = 0xE000, -}; - -class AArch64LinkingContext final : public ELFLinkingContext { -public: - AArch64LinkingContext(llvm::Triple triple) - : ELFLinkingContext(triple, std::unique_ptr( - new AArch64TargetHandler(*this))) {} - - void addPasses(PassManager &) override; - - uint64_t getBaseAddress() const override { - if (_baseAddress == 0) - return 0x400000; - return _baseAddress; - } - - bool isDynamicRelocation(const DefinedAtom &, - const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::AArch64); - switch (r.kindValue()) { - case llvm::ELF::R_AARCH64_COPY: - case llvm::ELF::R_AARCH64_GLOB_DAT: - case llvm::ELF::R_AARCH64_RELATIVE: - case llvm::ELF::R_AARCH64_TLS_DTPREL64: - case llvm::ELF::R_AARCH64_TLS_DTPMOD64: - case llvm::ELF::R_AARCH64_TLS_TPREL64: - case llvm::ELF::R_AARCH64_TLSDESC: - case llvm::ELF::R_AARCH64_IRELATIVE: - return true; - default: - return false; - } - } - - bool isCopyRelocation(const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::AArch64); - if (r.kindValue() == llvm::ELF::R_AARCH64_COPY) - return true; - return false; - } - - bool isPLTRelocation(const DefinedAtom &, - const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::AArch64); - switch (r.kindValue()) { - case llvm::ELF::R_AARCH64_JUMP_SLOT: - case llvm::ELF::R_AARCH64_IRELATIVE: - return true; - default: - return false; - } - } - - bool isRelativeReloc(const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::AArch64); - switch (r.kindValue()) { - case llvm::ELF::R_AARCH64_IRELATIVE: - case llvm::ELF::R_AARCH64_RELATIVE: - return true; - default: - return false; - } - } -}; -} // end namespace elf -} // end namespace lld - -#endif Index: lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp +++ lib/ReaderWriter/ELF/AArch64/AArch64LinkingContext.cpp @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "AArch64LinkingContext.h" +#include "lld/ReaderWriter/ELF/AArch64LinkingContext.h" #include "AArch64RelocationPass.h" +#include "AArch64TargetHandler.h" using namespace lld; +elf::AArch64LinkingContext::AArch64LinkingContext(llvm::Triple triple) + : ELFLinkingContext(triple, std::unique_ptr( + new AArch64TargetHandler(*this))) { +} + void elf::AArch64LinkingContext::addPasses(PassManager &pm) { auto pass = createAArch64RelocationPass(*this); if (pass) Index: lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp +++ lib/ReaderWriter/ELF/AArch64/AArch64RelocationHandler.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "AArch64TargetHandler.h" -#include "AArch64LinkingContext.h" +#include "lld/ReaderWriter/ELF/AArch64LinkingContext.h" #include "llvm/Support/Debug.h" using namespace lld; Index: lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp +++ lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp @@ -17,8 +17,8 @@ //===----------------------------------------------------------------------===// #include "AArch64RelocationPass.h" -#include "AArch64LinkingContext.h" #include "Atoms.h" +#include "lld/ReaderWriter/ELF/AArch64LinkingContext.h" #include "lld/Core/Simple.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Debug.h" Index: lib/ReaderWriter/ELF/AArch64/AArch64Target.h =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64Target.h +++ /dev/null @@ -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" Index: lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp +++ lib/ReaderWriter/ELF/AArch64/AArch64TargetHandler.cpp @@ -10,8 +10,8 @@ #include "Atoms.h" #include "AArch64DynamicLibraryWriter.h" #include "AArch64ExecutableWriter.h" -#include "AArch64LinkingContext.h" #include "AArch64TargetHandler.h" +#include "lld/ReaderWriter/ELF/AArch64LinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/AArch64/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/AArch64/CMakeLists.txt +++ lib/ReaderWriter/ELF/AArch64/CMakeLists.txt @@ -5,5 +5,7 @@ AArch64RelocationPass.cpp LINK_LIBS lldCore + lldELF + LLVMObject LLVMSupport ) Index: lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h +++ lib/ReaderWriter/ELF/ARM/ARMExecutableWriter.h @@ -10,7 +10,8 @@ #define LLD_READER_WRITER_ELF_ARM_ARM_EXECUTABLE_WRITER_H #include "ExecutableWriter.h" -#include "ARMLinkingContext.h" +#include "ARMTargetHandler.h" +#include "lld/ReaderWriter/ELF/ARMLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMLinkingContext.h +++ /dev/null @@ -1,40 +0,0 @@ -//===--------- lib/ReaderWriter/ELF/ARM/ARMLinkingContext.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_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" - -namespace lld { -namespace elf { - -class ARMLinkingContext final : public ELFLinkingContext { -public: - ARMLinkingContext(llvm::Triple triple) - : ELFLinkingContext(triple, std::unique_ptr( - new ARMTargetHandler(*this))) {} - - void addPasses(PassManager &) override; - - uint64_t getBaseAddress() const override { - if (_baseAddress == 0) - return 0x400000; - return _baseAddress; - } -}; -} // end namespace elf -} // end namespace lld - -#endif Index: lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp +++ lib/ReaderWriter/ELF/ARM/ARMLinkingContext.cpp @@ -7,12 +7,18 @@ // //===----------------------------------------------------------------------===// -#include "ARMLinkingContext.h" #include "ARMRelocationPass.h" +#include "ARMTargetHandler.h" +#include "lld/ReaderWriter/ELF/ARMLinkingContext.h" using namespace lld; using namespace lld::elf; +elf::ARMLinkingContext::ARMLinkingContext(llvm::Triple triple) + : ELFLinkingContext(triple, std::unique_ptr( + new ARMTargetHandler(*this))) { +} + void elf::ARMLinkingContext::addPasses(PassManager &pm) { auto pass = createARMRelocationPass(*this); if (pass) Index: lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp +++ lib/ReaderWriter/ELF/ARM/ARMRelocationHandler.cpp @@ -8,8 +8,7 @@ //===----------------------------------------------------------------------===// #include "ARMTargetHandler.h" -#include "ARMLinkingContext.h" - +#include "lld/ReaderWriter/ELF/ARMLinkingContext.h" #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" Index: lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp +++ lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp @@ -17,13 +17,10 @@ //===----------------------------------------------------------------------===// #include "ARMRelocationPass.h" - +#include "Atoms.h" #include "lld/Core/Simple.h" - +#include "lld/ReaderWriter/ELF/ARMLinkingContext.h" #include "llvm/ADT/DenseMap.h" - -#include "Atoms.h" -#include "ARMLinkingContext.h" #include "llvm/Support/Debug.h" using namespace lld; Index: lib/ReaderWriter/ELF/ARM/ARMTarget.h =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMTarget.h +++ /dev/null @@ -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" Index: lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp +++ lib/ReaderWriter/ELF/ARM/ARMTargetHandler.cpp @@ -10,7 +10,7 @@ #include "Atoms.h" #include "ARMExecutableWriter.h" #include "ARMTargetHandler.h" -#include "ARMLinkingContext.h" +#include "lld/ReaderWriter/ELF/ARMLinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/ARM/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/ARM/CMakeLists.txt +++ lib/ReaderWriter/ELF/ARM/CMakeLists.txt @@ -5,4 +5,7 @@ ARMRelocationPass.cpp LINK_LIBS lldCore + lldELF + LLVMObject + LLVMSupport ) Index: lib/ReaderWriter/ELF/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/CMakeLists.txt +++ lib/ReaderWriter/ELF/CMakeLists.txt @@ -4,15 +4,10 @@ Reader.cpp Writer.cpp LINK_LIBS - lldHexagonELFTarget - lldMipsELFTarget - lldPPCELFTarget + lldCore lldPasses - lldReaderWriter - lldX86ELFTarget - lldX86_64ELFTarget - lldAArch64ELFTarget - lldARMELFTarget + lldYAML + LLVMSupport ) include_directories(.) Index: lib/ReaderWriter/ELF/ELFLinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/ELFLinkingContext.cpp +++ lib/ReaderWriter/ELF/ELFLinkingContext.cpp @@ -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 @@ ELFLinkingContext::ELFLinkingContext( llvm::Triple triple, std::unique_ptr 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 @@ } 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 @@ Writer &ELFLinkingContext::writer() const { return *_writer; } -std::unique_ptr -ELFLinkingContext::create(llvm::Triple triple) { - switch (triple.getArch()) { - case llvm::Triple::x86: - return std::unique_ptr( - new lld::elf::X86LinkingContext(triple)); - case llvm::Triple::x86_64: - return std::unique_ptr( - new lld::elf::X86_64LinkingContext(triple)); - case llvm::Triple::hexagon: - return std::unique_ptr( - new lld::elf::HexagonLinkingContext(triple)); - case llvm::Triple::mipsel: - return std::unique_ptr( - new lld::elf::MipsLinkingContext(triple)); - case llvm::Triple::ppc: - return std::unique_ptr( - new lld::elf::PPCLinkingContext(triple)); - case llvm::Triple::aarch64: - return std::unique_ptr( - new lld::elf::AArch64LinkingContext(triple)); - case llvm::Triple::arm: - return std::unique_ptr( - new lld::elf::ARMLinkingContext(triple)); - default: - return nullptr; - } -} - static void buildSearchPath(SmallString<128> &path, StringRef dir, StringRef sysRoot) { if (!dir.startswith("=/")) Index: lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt +++ lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt @@ -4,5 +4,7 @@ HexagonTargetHandler.cpp LINK_LIBS lldCore + lldELF + LLVMObject LLVMSupport ) Index: lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonDynamicLibraryWriter.h @@ -11,7 +11,7 @@ #include "DynamicLibraryWriter.h" #include "HexagonExecutableAtoms.h" -#include "HexagonLinkingContext.h" +#include "lld/ReaderWriter/ELF/HexagonLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonELFFile.h @@ -11,7 +11,7 @@ #define LLD_READER_WRITER_ELF_HEXAGON_ELF_FILE_H #include "ELFReader.h" -#include "HexagonLinkingContext.h" +#include "lld/ReaderWriter/ELF/HexagonLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Hexagon/HexagonELFWriters.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonELFWriters.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonELFWriters.h @@ -10,8 +10,8 @@ #ifndef HEXAGON_ELF_WRITERS_H #define HEXAGON_ELF_WRITERS_H -#include "HexagonLinkingContext.h" #include "OutputELFWriter.h" +#include "lld/ReaderWriter/ELF/HexagonLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h +++ lib/ReaderWriter/ELF/Hexagon/HexagonExecutableWriter.h @@ -12,7 +12,7 @@ #include "ExecutableWriter.h" #include "HexagonELFWriters.h" #include "HexagonExecutableAtoms.h" -#include "HexagonLinkingContext.h" +#include "lld/ReaderWriter/ELF/HexagonLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.h +++ /dev/null @@ -1,69 +0,0 @@ -//===- lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.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_HEXAGON_HEXAGON_LINKING_CONTEXT_H -#define LLD_READER_WRITER_ELF_HEXAGON_HEXAGON_LINKING_CONTEXT_H - -#include "lld/ReaderWriter/ELFLinkingContext.h" -#include "llvm/Object/ELF.h" -#include "llvm/Support/ELF.h" - -namespace lld { -namespace elf { - -typedef llvm::object::ELFType HexagonELFType; - -class HexagonLinkingContext final : public ELFLinkingContext { -public: - HexagonLinkingContext(llvm::Triple triple); - - void addPasses(PassManager &) override; - - bool isDynamicRelocation(const DefinedAtom &, - const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - switch (r.kindValue()) { - case llvm::ELF::R_HEX_RELATIVE: - case llvm::ELF::R_HEX_GLOB_DAT: - return true; - default: - return false; - } - } - - bool isPLTRelocation(const DefinedAtom &, const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - switch (r.kindValue()) { - case llvm::ELF::R_HEX_JMP_SLOT: - return true; - default: - return false; - } - } - - /// \brief Hexagon has only one relative relocation - /// a) for supporting relative relocs - R_HEX_RELATIVE - bool isRelativeReloc(const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - switch (r.kindValue()) { - case llvm::ELF::R_HEX_RELATIVE: - return true; - default: - return false; - } - } -}; - -} // elf -} // lld - -#endif // LLD_READER_WRITER_ELF_HEXAGON_HEXAGON_LINKING_CONTEXT_H Index: lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp +++ lib/ReaderWriter/ELF/Hexagon/HexagonLinkingContext.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "HexagonLinkingContext.h" #include "HexagonTargetHandler.h" +#include "lld/ReaderWriter/ELF/HexagonLinkingContext.h" using namespace lld::elf; Index: lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp +++ lib/ReaderWriter/ELF/Hexagon/HexagonRelocationHandler.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "HexagonTargetHandler.h" -#include "HexagonLinkingContext.h" #include "HexagonRelocationFunctions.h" #include "HexagonRelocationHandler.h" +#include "lld/ReaderWriter/ELF/HexagonLinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonTarget.h +++ /dev/null @@ -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" Index: lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp +++ lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.cpp @@ -9,8 +9,8 @@ #include "HexagonExecutableWriter.h" #include "HexagonDynamicLibraryWriter.h" -#include "HexagonLinkingContext.h" #include "HexagonTargetHandler.h" +#include "lld/ReaderWriter/ELF/HexagonLinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/Makefile =================================================================== --- lib/ReaderWriter/ELF/Makefile +++ lib/ReaderWriter/ELF/Makefile @@ -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 Index: lib/ReaderWriter/ELF/Mips/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/Mips/CMakeLists.txt +++ lib/ReaderWriter/ELF/Mips/CMakeLists.txt @@ -7,5 +7,7 @@ MipsTargetHandler.cpp LINK_LIBS lldCore + lldELF + LLVMObject LLVMSupport ) Index: lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/Mips/MipsDynamicLibraryWriter.h @@ -12,7 +12,7 @@ #include "DynamicLibraryWriter.h" #include "MipsDynamicTable.h" #include "MipsELFWriters.h" -#include "MipsLinkingContext.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Mips/MipsELFFile.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsELFFile.h +++ lib/ReaderWriter/ELF/Mips/MipsELFFile.h @@ -10,8 +10,8 @@ #define LLD_READER_WRITER_ELF_MIPS_MIPS_ELF_FILE_H #include "ELFReader.h" -#include "MipsLinkingContext.h" #include "llvm/Support/Endian.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" namespace llvm { namespace object { Index: lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.h +++ /dev/null @@ -1,35 +0,0 @@ -//===- lib/ReaderWriter/ELF/MipsELFFlagsMerger.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_MIPS_MIPS_ELF_FLAGS_MERGER_H -#define LLD_READER_WRITER_ELF_MIPS_MIPS_ELF_FLAGS_MERGER_H - -#include -#include - -namespace lld { -namespace elf { - -class MipsELFFlagsMerger { -public: - MipsELFFlagsMerger(); - - uint32_t getMergedELFFlags() const; - - /// \brief Merge saved ELF header flags and the new set of flags. - std::error_code merge(uint8_t newClass, uint32_t newFlags); - -private: - std::mutex _mutex; - uint32_t _flags; -}; - -} // namespace elf -} // namespace lld - -#endif Index: lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp +++ lib/ReaderWriter/ELF/Mips/MipsELFFlagsMerger.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "MipsELFFlagsMerger.h" #include "lld/Core/Error.h" +#include "lld/ReaderWriter/ELF/MipsELFFlagsMerger.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/ELF.h" #include "llvm/Support/raw_ostream.h" Index: lib/ReaderWriter/ELF/Mips/MipsELFReader.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsELFReader.h +++ lib/ReaderWriter/ELF/Mips/MipsELFReader.h @@ -11,8 +11,8 @@ #include "ELFReader.h" #include "MipsELFFile.h" -#include "MipsELFFlagsMerger.h" -#include "MipsLinkingContext.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" +#include "lld/ReaderWriter/ELF/MipsELFFlagsMerger.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Mips/MipsELFWriters.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsELFWriters.h +++ lib/ReaderWriter/ELF/Mips/MipsELFWriters.h @@ -9,8 +9,8 @@ #ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_ELF_WRITERS_H #define LLD_READER_WRITER_ELF_MIPS_MIPS_ELF_WRITERS_H -#include "MipsLinkingContext.h" #include "OutputELFWriter.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h +++ lib/ReaderWriter/ELF/Mips/MipsExecutableWriter.h @@ -12,7 +12,7 @@ #include "ExecutableWriter.h" #include "MipsDynamicTable.h" #include "MipsELFWriters.h" -#include "MipsLinkingContext.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsLinkingContext.h +++ /dev/null @@ -1,65 +0,0 @@ -//===- lib/ReaderWriter/ELF/Mips/MipsLinkingContext.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_MIPS_MIPS_LINKING_CONTEXT_H -#define LLD_READER_WRITER_ELF_MIPS_MIPS_LINKING_CONTEXT_H - -#include "MipsELFFlagsMerger.h" -#include "lld/ReaderWriter/ELFLinkingContext.h" - -namespace lld { -namespace elf { - -/// \brief Mips internal references. -enum { - /// \brief Do nothing but mark GOT entry as a global one. - LLD_R_MIPS_GLOBAL_GOT = 1024, - /// \brief Apply high 16 bits of symbol + addend. - LLD_R_MIPS_32_HI16 = 1025, - /// \brief The same as R_MIPS_26 but for global symbols. - LLD_R_MIPS_GLOBAL_26 = 1026, - /// \brief Setup hi 16 bits using the symbol this reference refers to. - LLD_R_MIPS_HI16 = 1027, - /// \brief Setup low 16 bits using the symbol this reference refers to. - LLD_R_MIPS_LO16 = 1028, - /// \brief Represents a reference between PLT and dynamic symbol. - LLD_R_MIPS_STO_PLT = 1029, - /// \brief The same as R_MICROMIPS_26_S1 but for global symbols. - LLD_R_MICROMIPS_GLOBAL_26_S1 = 1030, -}; - -typedef llvm::object::ELFType Mips32ElELFType; - -template class MipsTargetLayout; - -class MipsLinkingContext final : public ELFLinkingContext { -public: - MipsLinkingContext(llvm::Triple triple); - - uint32_t getMergedELFFlags() const; - MipsELFFlagsMerger &getELFFlagsMerger(); - - // ELFLinkingContext - uint64_t getBaseAddress() const override; - StringRef entrySymbolName() const override; - StringRef getDefaultInterpreter() const override; - void addPasses(PassManager &pm) override; - bool isRelaOutputFormat() const override { return false; } - bool isDynamicRelocation(const DefinedAtom &, - const Reference &r) const override; - bool isCopyRelocation(const Reference &r) const override; - bool isPLTRelocation(const DefinedAtom &, const Reference &r) const override; - -private: - MipsELFFlagsMerger _flagsMerger; -}; - -} // elf -} // lld - -#endif Index: lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp +++ lib/ReaderWriter/ELF/Mips/MipsLinkingContext.cpp @@ -9,9 +9,9 @@ #include "Atoms.h" #include "MipsCtorsOrderPass.h" -#include "MipsLinkingContext.h" #include "MipsRelocationPass.h" #include "MipsTargetHandler.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" using namespace lld; using namespace lld::elf; Index: lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h +++ lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.h @@ -9,7 +9,7 @@ #ifndef LLD_READER_WRITER_ELF_MIPS_MIPS_RELOCATION_HANDLER_H #define LLD_READER_WRITER_ELF_MIPS_MIPS_RELOCATION_HANDLER_H -#include "MipsLinkingContext.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp +++ lib/ReaderWriter/ELF/Mips/MipsRelocationHandler.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "MipsTargetHandler.h" -#include "MipsLinkingContext.h" #include "MipsRelocationHandler.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" #include "lld/ReaderWriter/RelocationHelperFunctions.h" using namespace lld; Index: lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp +++ lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp @@ -8,9 +8,9 @@ //===----------------------------------------------------------------------===// #include "MipsELFFile.h" -#include "MipsLinkingContext.h" #include "MipsRelocationPass.h" #include "MipsTargetHandler.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" #include "llvm/ADT/DenseSet.h" using namespace lld; Index: lib/ReaderWriter/ELF/Mips/MipsTarget.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsTarget.h +++ /dev/null @@ -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" Index: lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h +++ lib/ReaderWriter/ELF/Mips/MipsTargetHandler.h @@ -11,10 +11,10 @@ #include "DefaultTargetHandler.h" #include "MipsELFReader.h" -#include "MipsLinkingContext.h" #include "MipsRelocationHandler.h" #include "MipsSectionChunks.h" #include "TargetLayout.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" #include "llvm/ADT/DenseSet.h" namespace lld { Index: lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp +++ lib/ReaderWriter/ELF/Mips/MipsTargetHandler.cpp @@ -10,8 +10,8 @@ #include "ELFFile.h" #include "MipsDynamicLibraryWriter.h" #include "MipsExecutableWriter.h" -#include "MipsLinkingContext.h" #include "MipsTargetHandler.h" +#include "lld/ReaderWriter/ELF/MipsLinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/PPC/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/PPC/CMakeLists.txt +++ lib/ReaderWriter/ELF/PPC/CMakeLists.txt @@ -3,5 +3,7 @@ PPCTargetHandler.cpp LINK_LIBS lldCore + lldELF + LLVMObject LLVMSupport ) Index: lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h =================================================================== --- lib/ReaderWriter/ELF/PPC/PPCLinkingContext.h +++ /dev/null @@ -1,34 +0,0 @@ -//===- lib/ReaderWriter/ELF/PPC/PPCLinkingContext.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_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" - -namespace lld { -namespace elf { - -class PPCLinkingContext final : public ELFLinkingContext { -public: - PPCLinkingContext(llvm::Triple triple) - : ELFLinkingContext(triple, std::unique_ptr( - new PPCTargetHandler(*this))) {} - - /// \brief PPC has no relative relocations defined - bool isRelativeReloc(const Reference &) const override { return false; } -}; - -} // elf -} // lld - -#endif // LLD_READER_WRITER_ELF_PPC_PPC_LINKING_CONTEXT_H Index: lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp +++ lib/ReaderWriter/ELF/PPC/PPCLinkingContext.cpp @@ -7,10 +7,16 @@ // //===----------------------------------------------------------------------===// -#include "PPCLinkingContext.h" +#include "PPCTargetHandler.h" #include "lld/Core/LLVM.h" +#include "lld/ReaderWriter/ELF/PPCLinkingContext.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( + new PPCTargetHandler(*this))) { +} + Index: lib/ReaderWriter/ELF/PPC/PPCTarget.h =================================================================== --- lib/ReaderWriter/ELF/PPC/PPCTarget.h +++ /dev/null @@ -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" Index: lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp +++ lib/ReaderWriter/ELF/PPC/PPCTargetHandler.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "PPCTargetHandler.h" -#include "PPCLinkingContext.h" +#include "lld/ReaderWriter/ELF/PPCLinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/Targets.h =================================================================== --- lib/ReaderWriter/ELF/Targets.h +++ /dev/null @@ -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 Index: lib/ReaderWriter/ELF/X86/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/X86/CMakeLists.txt +++ lib/ReaderWriter/ELF/X86/CMakeLists.txt @@ -4,5 +4,7 @@ X86RelocationHandler.cpp LINK_LIBS lldCore + lldELF + LLVMObject LLVMSupport ) Index: lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/X86/X86DynamicLibraryWriter.h @@ -10,7 +10,7 @@ #define X86_X86_DYNAMIC_LIBRARY_WRITER_H #include "DynamicLibraryWriter.h" -#include "X86LinkingContext.h" +#include "lld/ReaderWriter/ELF/X86LinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/X86/X86ExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86/X86ExecutableWriter.h +++ lib/ReaderWriter/ELF/X86/X86ExecutableWriter.h @@ -10,7 +10,7 @@ #define X86_X86_EXECUTABLE_WRITER_H #include "ExecutableWriter.h" -#include "X86LinkingContext.h" +#include "lld/ReaderWriter/ELF/X86LinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/X86/X86LinkingContext.h =================================================================== --- lib/ReaderWriter/ELF/X86/X86LinkingContext.h +++ /dev/null @@ -1,44 +0,0 @@ -//===- lib/ReaderWriter/ELF/X86/X86LinkingContext.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_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" - -namespace lld { -namespace elf { -class X86LinkingContext final : public ELFLinkingContext { -public: - X86LinkingContext(llvm::Triple triple) - : ELFLinkingContext(triple, std::unique_ptr( - new X86TargetHandler(*this))) {} - - /// \brief X86 has only two relative relocation - /// a) for supporting IFUNC relocs - R_386_IRELATIVE - /// b) for supporting relative relocs - R_386_RELATIVE - bool isRelativeReloc(const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::x86); - switch (r.kindValue()) { - case llvm::ELF::R_386_IRELATIVE: - case llvm::ELF::R_386_RELATIVE: - return true; - default: - return false; - } - } -}; -} // end namespace elf -} // end namespace lld -#endif Index: lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp +++ lib/ReaderWriter/ELF/X86/X86LinkingContext.cpp @@ -7,10 +7,15 @@ // //===----------------------------------------------------------------------===// -#include "X86LinkingContext.h" +#include "X86TargetHandler.h" #include "lld/Core/LLVM.h" +#include "lld/ReaderWriter/ELF/X86LinkingContext.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( + new X86TargetHandler(*this))) { + } Index: lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp +++ lib/ReaderWriter/ELF/X86/X86RelocationHandler.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "X86LinkingContext.h" #include "X86TargetHandler.h" +#include "lld/ReaderWriter/ELF/X86LinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/X86/X86Target.h =================================================================== --- lib/ReaderWriter/ELF/X86/X86Target.h +++ /dev/null @@ -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" Index: lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp +++ lib/ReaderWriter/ELF/X86/X86TargetHandler.cpp @@ -10,8 +10,8 @@ #include "X86TargetHandler.h" #include "X86DynamicLibraryWriter.h" #include "X86ExecutableWriter.h" -#include "X86LinkingContext.h" #include "X86RelocationHandler.h" +#include "lld/ReaderWriter/ELF/X86LinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/X86_64/CMakeLists.txt =================================================================== --- lib/ReaderWriter/ELF/X86_64/CMakeLists.txt +++ lib/ReaderWriter/ELF/X86_64/CMakeLists.txt @@ -5,5 +5,7 @@ X86_64RelocationPass.cpp LINK_LIBS lldCore + lldELF + LLVMObject LLVMSupport ) Index: lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h +++ lib/ReaderWriter/ELF/X86_64/X86_64DynamicLibraryWriter.h @@ -10,7 +10,8 @@ #define X86_64_DYNAMIC_LIBRARY_WRITER_H #include "DynamicLibraryWriter.h" -#include "X86_64LinkingContext.h" +#include "X86_64TargetHandler.h" +#include "lld/ReaderWriter/ELF/X86_64LinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h +++ lib/ReaderWriter/ELF/X86_64/X86_64ExecutableWriter.h @@ -10,7 +10,8 @@ #define X86_64_EXECUTABLE_WRITER_H #include "ExecutableWriter.h" -#include "X86_64LinkingContext.h" +#include "X86_64TargetHandler.h" +#include "lld/ReaderWriter/ELF/X86_64LinkingContext.h" namespace lld { namespace elf { Index: lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.h +++ /dev/null @@ -1,101 +0,0 @@ -//===- lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.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_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" - -namespace lld { -namespace elf { - -/// \brief x86-64 internal references. -enum { - /// \brief The 32 bit index of the relocation in the got this reference refers - /// to. - LLD_R_X86_64_GOTRELINDEX = 1024, -}; - -class X86_64LinkingContext final : public ELFLinkingContext { -public: - X86_64LinkingContext(llvm::Triple triple) - : ELFLinkingContext(triple, std::unique_ptr( - new X86_64TargetHandler(*this))) {} - - void addPasses(PassManager &) override; - - uint64_t getBaseAddress() const override { - if (_baseAddress == 0) - return 0x400000; - return _baseAddress; - } - - bool isDynamicRelocation(const DefinedAtom &, - const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::x86_64); - switch (r.kindValue()) { - case llvm::ELF::R_X86_64_RELATIVE: - case llvm::ELF::R_X86_64_GLOB_DAT: - case llvm::ELF::R_X86_64_COPY: - case llvm::ELF::R_X86_64_DTPMOD64: - case llvm::ELF::R_X86_64_DTPOFF64: - return true; - default: - return false; - } - } - - bool isCopyRelocation(const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::x86_64); - if (r.kindValue() == llvm::ELF::R_X86_64_COPY) - return true; - return false; - } - - virtual bool isPLTRelocation(const DefinedAtom &, - const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::x86_64); - switch (r.kindValue()) { - case llvm::ELF::R_X86_64_JUMP_SLOT: - case llvm::ELF::R_X86_64_IRELATIVE: - return true; - default: - return false; - } - } - - /// \brief X86_64 has two relative relocations - /// a) for supporting IFUNC - R_X86_64_IRELATIVE - /// b) for supporting relative relocs - R_X86_64_RELATIVE - bool isRelativeReloc(const Reference &r) const override { - if (r.kindNamespace() != Reference::KindNamespace::ELF) - return false; - assert(r.kindArch() == Reference::KindArch::x86_64); - switch (r.kindValue()) { - case llvm::ELF::R_X86_64_IRELATIVE: - case llvm::ELF::R_X86_64_RELATIVE: - return true; - default: - return false; - } - } -}; -} // end namespace elf -} // end namespace lld - -#endif Index: lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp +++ lib/ReaderWriter/ELF/X86_64/X86_64LinkingContext.cpp @@ -7,11 +7,17 @@ // //===----------------------------------------------------------------------===// -#include "X86_64LinkingContext.h" #include "X86_64RelocationPass.h" +#include "X86_64TargetHandler.h" +#include "lld/ReaderWriter/ELF/X86_64LinkingContext.h" using namespace lld; +elf::X86_64LinkingContext::X86_64LinkingContext(llvm::Triple triple) + : ELFLinkingContext(triple, std::unique_ptr( + new X86_64TargetHandler(*this))) { +} + void elf::X86_64LinkingContext::addPasses(PassManager &pm) { auto pass = createX86_64RelocationPass(*this); if (pass) Index: lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp +++ lib/ReaderWriter/ELF/X86_64/X86_64RelocationHandler.cpp @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "X86_64LinkingContext.h" #include "X86_64TargetHandler.h" +#include "lld/ReaderWriter/ELF/X86_64LinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp +++ lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp @@ -21,8 +21,8 @@ #include "X86_64RelocationPass.h" #include "Atoms.h" -#include "X86_64LinkingContext.h" #include "lld/Core/Simple.h" +#include "lld/ReaderWriter/ELF/X86_64LinkingContext.h" #include "llvm/ADT/DenseMap.h" using namespace lld; Index: lib/ReaderWriter/ELF/X86_64/X86_64Target.h =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64Target.h +++ /dev/null @@ -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" Index: lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp +++ lib/ReaderWriter/ELF/X86_64/X86_64TargetHandler.cpp @@ -10,8 +10,8 @@ #include "Atoms.h" #include "X86_64DynamicLibraryWriter.h" #include "X86_64ExecutableWriter.h" -#include "X86_64LinkingContext.h" #include "X86_64TargetHandler.h" +#include "lld/ReaderWriter/ELF/X86_64LinkingContext.h" using namespace lld; using namespace elf; Index: lib/ReaderWriter/MachO/CMakeLists.txt =================================================================== --- lib/ReaderWriter/MachO/CMakeLists.txt +++ lib/ReaderWriter/MachO/CMakeLists.txt @@ -16,8 +16,10 @@ StubsPass.cpp WriterMachO.cpp LINK_LIBS - lldReaderWriter + lldCore lldPasses + lldYAML + LLVMObject LLVMSupport ) Index: lib/ReaderWriter/MachO/Makefile =================================================================== --- lib/ReaderWriter/MachO/Makefile +++ lib/ReaderWriter/MachO/Makefile @@ -9,6 +9,6 @@ LLD_LEVEL := ../../.. LIBRARYNAME := lldMachO -USEDLIBS = lldReaderWriter.a lldCore.a +USEDLIBS = lldCore.a include $(LLD_LEVEL)/Makefile Index: lib/ReaderWriter/PECOFF/CMakeLists.txt =================================================================== --- lib/ReaderWriter/PECOFF/CMakeLists.txt +++ lib/ReaderWriter/PECOFF/CMakeLists.txt @@ -10,7 +10,8 @@ WriterImportLibrary.cpp WriterPECOFF.cpp LINK_LIBS - lldReaderWriter + lldCore + lldPasses LLVMObject LLVMSupport ) Index: lib/ReaderWriter/PECOFF/Makefile =================================================================== --- lib/ReaderWriter/PECOFF/Makefile +++ lib/ReaderWriter/PECOFF/Makefile @@ -9,6 +9,6 @@ LLD_LEVEL := ../../.. LIBRARYNAME := lldPECOFF -USEDLIBS = lldReaderWriter.a lldCore.a +USEDLIBS = lldCore.a include $(LLD_LEVEL)/Makefile