summaryrefslogtreecommitdiff
path: root/lib/ReaderWriter
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ReaderWriter')
-rw-r--r--lib/ReaderWriter/CMakeLists.txt6
-rw-r--r--lib/ReaderWriter/ELF/AArch64/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.cpp34
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.h41
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.cpp41
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.h36
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.cpp19
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.h31
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.cpp32
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.h32
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp65
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.h80
-rw-r--r--lib/ReaderWriter/ELF/AMDGPU/CMakeLists.txt13
-rw-r--r--lib/ReaderWriter/ELF/ARM/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/ELF/CMakeLists.txt3
-rw-r--r--lib/ReaderWriter/ELF/ELFLinkingContext.cpp2
-rw-r--r--lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/ELF/Mips/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/ELF/X86/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/ELF/X86_64/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/MachO/ArchHandler_arm64.cpp16
-rw-r--r--lib/ReaderWriter/MachO/CMakeLists.txt2
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h3
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp33
-rw-r--r--lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp6
-rw-r--r--lib/ReaderWriter/YAML/CMakeLists.txt2
27 files changed, 61 insertions, 450 deletions
diff --git a/lib/ReaderWriter/CMakeLists.txt b/lib/ReaderWriter/CMakeLists.txt
index 588f0d85a5868..2bb5655b9e357 100644
--- a/lib/ReaderWriter/CMakeLists.txt
+++ b/lib/ReaderWriter/CMakeLists.txt
@@ -6,10 +6,14 @@ if (MSVC)
add_definitions(-wd4062) # Suppress 'warning C4062: Enumerator has no associated handler in a switch statement.'
endif()
-add_llvm_library(lldReaderWriter
+add_lld_library(lldReaderWriter
CoreLinkingContext.cpp
FileArchive.cpp
LinkerScript.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${LLD_INCLUDE_DIR}/lld/ReaderWriter
+
LINK_LIBS
lldCore
lldYAML
diff --git a/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt b/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt
index 2347dda9adb09..aae6420008a4b 100644
--- a/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/AArch64/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldAArch64ELFTarget
+add_lld_library(lldAArch64ELFTarget
AArch64LinkingContext.cpp
AArch64TargetHandler.cpp
AArch64RelocationHandler.cpp
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.cpp b/lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.cpp
deleted file mode 100644
index 89efeb23d6f88..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.cpp -------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "AMDGPUExecutableWriter.h"
-
-using namespace lld;
-using namespace lld::elf;
-
-AMDGPUExecutableWriter::AMDGPUExecutableWriter(AMDGPULinkingContext &ctx,
- AMDGPUTargetLayout &layout)
- : ExecutableWriter(ctx, layout), _ctx(ctx) {}
-
-void AMDGPUExecutableWriter::createImplicitFiles(
- std::vector<std::unique_ptr<File>> &Result) {
- // ExecutableWriter::createImplicitFiles() adds C runtime symbols that we
- // don't need, so we use the OutputELFWriter implementation instead.
- OutputELFWriter<ELF64LE>::createImplicitFiles(Result);
-}
-
-void AMDGPUExecutableWriter::finalizeDefaultAtomValues() {
-
- // ExecutableWriter::finalizeDefaultAtomValues() assumes the presence of
- // C runtime symbols. However, since we skip the call to
- // ExecutableWriter::createImplicitFiles(), these symbols are never added
- // and ExectuableWriter::finalizeDefaultAtomValues() will crash if we call
- // it.
- OutputELFWriter<ELF64LE>::finalizeDefaultAtomValues();
-}
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.h b/lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.h
deleted file mode 100644
index accc00b8a0548..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.h
+++ /dev/null
@@ -1,41 +0,0 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUExecutableWriter.h ---------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef AMDGPU_EXECUTABLE_WRITER_H
-#define AMDGPU_EXECUTABLE_WRITER_H
-
-#include "ExecutableWriter.h"
-#include "AMDGPULinkingContext.h"
-#include "AMDGPUSymbolTable.h"
-#include "AMDGPUTargetHandler.h"
-
-namespace lld {
-namespace elf {
-
-class AMDGPUTargetLayout;
-
-class AMDGPUExecutableWriter : public ExecutableWriter<ELF64LE> {
-public:
- AMDGPUExecutableWriter(AMDGPULinkingContext &ctx, AMDGPUTargetLayout &layout);
-
- unique_bump_ptr<SymbolTable<ELF64LE>> createSymbolTable() override {
- return unique_bump_ptr<SymbolTable<ELF64LE>>(new (this->_alloc)
- AMDGPUSymbolTable(_ctx));
- }
-
- void createImplicitFiles(std::vector<std::unique_ptr<File>> &Result) override;
- void finalizeDefaultAtomValues() override;
-
-private:
- AMDGPULinkingContext &_ctx;
-};
-
-} // namespace elf
-} // namespace lld
-
-#endif // AMDGPU_EXECUTABLE_WRITER_H
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.cpp b/lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.cpp
deleted file mode 100644
index b1e83641fa82b..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.cpp ---------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===------------------------------------------------------------------------===//
-
-#include "AMDGPULinkingContext.h"
-#include "AMDGPUTargetHandler.h"
-
-namespace lld {
-namespace elf {
-
-std::unique_ptr<ELFLinkingContext>
-createAMDGPULinkingContext(llvm::Triple triple) {
- if (triple.getArch() == llvm::Triple::amdgcn)
- return llvm::make_unique<AMDGPULinkingContext>(triple);
- return nullptr;
-}
-
-AMDGPULinkingContext::AMDGPULinkingContext(llvm::Triple triple)
- : ELFLinkingContext(triple, llvm::make_unique<AMDGPUTargetHandler>(*this)) {
-}
-
-static const Registry::KindStrings kindStrings[] = {LLD_KIND_STRING_END};
-
-void AMDGPULinkingContext::registerRelocationNames(Registry &registry) {
- registry.addKindTable(Reference::KindNamespace::ELF,
- Reference::KindArch::AMDGPU, kindStrings);
-}
-
-void setAMDGPUELFHeader(ELFHeader<ELF64LE> &elfHeader) {
- elfHeader.e_ident(llvm::ELF::EI_OSABI, ELFOSABI_AMDGPU_HSA);
-}
-
-StringRef AMDGPULinkingContext::entrySymbolName() const { return ""; }
-
-} // namespace elf
-} // namespace lld
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.h b/lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.h
deleted file mode 100644
index 1cc7a3c7694fb..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.h
+++ /dev/null
@@ -1,36 +0,0 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPULinkingContext.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_AMDGPU_AMDGPU_LINKING_CONTEXT_H
-#define LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_LINKING_CONTEXT_H
-
-#include "OutputELFWriter.h"
-#include "lld/ReaderWriter/ELFLinkingContext.h"
-#include "llvm/Object/ELF.h"
-#include "llvm/Support/ELF.h"
-
-namespace lld {
-namespace elf {
-
-class AMDGPULinkingContext final : public ELFLinkingContext {
-public:
- AMDGPULinkingContext(llvm::Triple triple);
- int getMachineType() const override { return llvm::ELF::EM_AMDGPU; }
-
- void registerRelocationNames(Registry &r) override;
-
- StringRef entrySymbolName() const override;
-};
-
-void setAMDGPUELFHeader(ELFHeader<ELF64LE> &elfHeader);
-
-} // elf
-} // lld
-
-#endif // LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_LINKING_CONTEXT_H
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.cpp b/lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.cpp
deleted file mode 100644
index ca5a77db91776..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.cpp
+++ /dev/null
@@ -1,19 +0,0 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.cpp -----------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "AMDGPURelocationHandler.h"
-
-using namespace lld;
-using namespace lld::elf;
-
-std::error_code AMDGPUTargetRelocationHandler::applyRelocation(
- ELFWriter &writer, llvm::FileOutputBuffer &buf, const AtomLayout &atom,
- const Reference &ref) const {
- return std::error_code();
-}
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.h b/lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.h
deleted file mode 100644
index 90d37274aebfd..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.h
+++ /dev/null
@@ -1,31 +0,0 @@
-//===- lld/ReaderWriter/ELF/AMDGPU/AMDGPURelocationHandler.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_AMDGPU_AMDGPU_RELOCATION_HANDLER_H
-#define LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_RELOCATION_HANDLER_H
-
-#include "lld/ReaderWriter/ELFLinkingContext.h"
-#include <system_error>
-
-namespace lld {
-namespace elf {
-class AMDGPUTargetHandler;
-class AMDGPUTargetLayout;
-
-class AMDGPUTargetRelocationHandler final : public TargetRelocationHandler {
-public:
- AMDGPUTargetRelocationHandler(AMDGPUTargetLayout &layout) { }
-
- std::error_code applyRelocation(ELFWriter &, llvm::FileOutputBuffer &,
- const AtomLayout &,
- const Reference &) const override;
-
-};
-} // elf
-} // lld
-#endif
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.cpp b/lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.cpp
deleted file mode 100644
index 0824974d46022..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===--------- lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.cpp ----------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "AMDGPUSymbolTable.h"
-#include "ELFFile.h"
-#include "Atoms.h"
-#include "SectionChunks.h"
-
-using namespace lld;
-using namespace lld::elf;
-
-AMDGPUSymbolTable::AMDGPUSymbolTable(const ELFLinkingContext &ctx)
- : SymbolTable(ctx, ".symtab", TargetLayout<ELF64LE>::ORDER_SYMBOL_TABLE) {}
-
-void AMDGPUSymbolTable::addDefinedAtom(Elf_Sym &sym, const DefinedAtom *da,
- int64_t addr) {
- SymbolTable::addDefinedAtom(sym, da, addr);
-
- // FIXME: Only do this for kernel functions.
- sym.setType(STT_AMDGPU_HSA_KERNEL);
-
- // Make st_value section relative.
- // FIXME: This is hack to give kernel symbols a section relative offset.
- // Because of this hack only on kernel can be included in a binary file.
- sym.st_value = 0;
-}
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.h b/lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.h
deleted file mode 100644
index 41c3be5cb38fe..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//===--------- lib/ReaderWriter/ELF/AMDGPU/AMDGPUSymbolTable.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_AMDGPU_AMDGPU_SYMBOL_TABLE_H
-#define LLD_READER_WRITER_ELF_AMDGPU_AMDGPU_SYMBOL_TABLE_H
-
-#include "TargetLayout.h"
-
-namespace lld {
-namespace elf {
-
-/// \brief The SymbolTable class represents the symbol table in a ELF file
-class AMDGPUSymbolTable : public SymbolTable<ELF64LE> {
-public:
- typedef llvm::object::Elf_Sym_Impl<ELF64LE> Elf_Sym;
-
- AMDGPUSymbolTable(const ELFLinkingContext &ctx);
-
- void addDefinedAtom(Elf_Sym &sym, const DefinedAtom *da,
- int64_t addr) override;
-};
-
-} // elf
-} // lld
-
-#endif
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp b/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp
deleted file mode 100644
index ff4b600158bd4..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp -------*- C++ -*-===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "TargetLayout.h"
-#include "AMDGPUExecutableWriter.h"
-#include "AMDGPULinkingContext.h"
-#include "AMDGPUTargetHandler.h"
-#include "llvm/Support/ELF.h"
-
-namespace lld {
-namespace elf {
-
-AMDGPUTargetHandler::AMDGPUTargetHandler(AMDGPULinkingContext &ctx)
- : _ctx(ctx), _targetLayout(new AMDGPUTargetLayout(ctx)),
- _relocationHandler(new AMDGPUTargetRelocationHandler(*_targetLayout)) {}
-
-std::unique_ptr<Writer> AMDGPUTargetHandler::getWriter() {
- switch (_ctx.getOutputELFType()) {
- case llvm::ELF::ET_EXEC:
- return llvm::make_unique<AMDGPUExecutableWriter>(_ctx, *_targetLayout);
- case llvm::ELF::ET_DYN:
- llvm_unreachable("TODO: support dynamic libraries");
- case llvm::ELF::ET_REL:
- llvm_unreachable("TODO: support -r mode");
- default:
- llvm_unreachable("unsupported output type");
- }
-}
-
-HSATextSection::HSATextSection(const ELFLinkingContext &ctx)
- : AtomSection(ctx, ".hsatext", DefinedAtom::typeCode, 0, 0) {
- _type = SHT_PROGBITS;
- _flags = SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR | SHF_AMDGPU_HSA_AGENT |
- SHF_AMDGPU_HSA_CODE;
-
- // FIXME: What alignment should we use here?
- _alignment = 4096;
-}
-
-void AMDGPUTargetLayout::assignSectionsToSegments() {
-
- TargetLayout::assignSectionsToSegments();
- for (OutputSection<ELF64LE> *osi : _outputSections) {
- for (Section<ELF64LE> *section : osi->sections()) {
- StringRef InputSectionName = section->inputSectionName();
- if (InputSectionName != ".hsatext")
- continue;
-
- auto *segment = new (_allocator) Segment<ELF64LE>(
- _ctx, "PT_AMDGPU_HSA_LOAD_CODE_AGENT", PT_AMDGPU_HSA_LOAD_CODE_AGENT);
- _segments.push_back(segment);
- assert(segment);
- segment->append(section);
- }
- }
-}
-
-} // namespace elf
-} // namespace lld
diff --git a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.h b/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.h
deleted file mode 100644
index 8d0f70b6e7f7b..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.h
+++ /dev/null
@@ -1,80 +0,0 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.h ------------------===//
-//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef AMDGPU_TARGET_HANDLER_H
-#define AMDGPU_TARGET_HANDLER_H
-
-#include "ELFFile.h"
-#include "ELFReader.h"
-#include "AMDGPURelocationHandler.h"
-#include "TargetLayout.h"
-
-namespace lld {
-namespace elf {
-class AMDGPULinkingContext;
-
-class HSATextSection : public AtomSection<ELF64LE> {
-public:
- HSATextSection(const ELFLinkingContext &ctx);
-};
-
-/// \brief TargetLayout for AMDGPU
-class AMDGPUTargetLayout final : public TargetLayout<ELF64LE> {
-public:
- AMDGPUTargetLayout(AMDGPULinkingContext &ctx) : TargetLayout(ctx) {}
-
- void assignSectionsToSegments() override;
-
- /// \brief Gets or creates a section.
- AtomSection<ELF64LE> *
- createSection(StringRef name, int32_t contentType,
- DefinedAtom::ContentPermissions contentPermissions,
- TargetLayout::SectionOrder sectionOrder) override {
- if (name == ".hsatext")
- return new (_allocator) HSATextSection(_ctx);
-
- if (name == ".note")
- contentType = DefinedAtom::typeRONote;
-
- return TargetLayout::createSection(name, contentType, contentPermissions,
- sectionOrder);
- }
-};
-
-/// \brief TargetHandler for AMDGPU
-class AMDGPUTargetHandler final : public TargetHandler {
-public:
- AMDGPUTargetHandler(AMDGPULinkingContext &targetInfo);
-
- const TargetRelocationHandler &getRelocationHandler() const override {
- return *_relocationHandler;
- }
-
- std::unique_ptr<Reader> getObjReader() override {
- return llvm::make_unique<ELFReader<ELFFile<ELF64LE>>>(_ctx);
- }
-
- std::unique_ptr<Reader> getDSOReader() override {
- return llvm::make_unique<ELFReader<DynamicFile<ELF64LE>>>(_ctx);
- }
-
- std::unique_ptr<Writer> getWriter() override;
-
-private:
- AMDGPULinkingContext &_ctx;
- std::unique_ptr<AMDGPUTargetLayout> _targetLayout;
- std::unique_ptr<AMDGPUTargetRelocationHandler> _relocationHandler;
-};
-
-void finalizeAMDGPURuntimeAtomValues(AMDGPUTargetLayout &layout);
-
-} // end namespace elf
-} // end namespace lld
-
-#endif
diff --git a/lib/ReaderWriter/ELF/AMDGPU/CMakeLists.txt b/lib/ReaderWriter/ELF/AMDGPU/CMakeLists.txt
deleted file mode 100644
index 9c9cc10fe3972..0000000000000
--- a/lib/ReaderWriter/ELF/AMDGPU/CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-add_llvm_library(lldAMDGPUELFTarget
- AMDGPUExecutableWriter.cpp
- AMDGPULinkingContext.cpp
- AMDGPURelocationHandler.cpp
- AMDGPUSymbolTable.cpp
- AMDGPUTargetHandler.cpp
- LINK_LIBS
- lldELF
- lldReaderWriter
- lldCore
- LLVMObject
- LLVMSupport
- )
diff --git a/lib/ReaderWriter/ELF/ARM/CMakeLists.txt b/lib/ReaderWriter/ELF/ARM/CMakeLists.txt
index 2ccf9eb6266db..c8cd6533d902f 100644
--- a/lib/ReaderWriter/ELF/ARM/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/ARM/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldARMELFTarget
+add_lld_library(lldARMELFTarget
ARMLinkingContext.cpp
ARMTargetHandler.cpp
ARMRelocationHandler.cpp
diff --git a/lib/ReaderWriter/ELF/CMakeLists.txt b/lib/ReaderWriter/ELF/CMakeLists.txt
index e3e4a02b28106..3bc338507db6b 100644
--- a/lib/ReaderWriter/ELF/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldELF
+add_lld_library(lldELF
Atoms.cpp
DynamicFile.cpp
ELFFile.cpp
@@ -27,4 +27,3 @@ add_subdirectory(Mips)
add_subdirectory(Hexagon)
add_subdirectory(AArch64)
add_subdirectory(ARM)
-add_subdirectory(AMDGPU)
diff --git a/lib/ReaderWriter/ELF/ELFLinkingContext.cpp b/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
index 2904c7b0dae08..70d6d618207d2 100644
--- a/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
+++ b/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
@@ -61,8 +61,6 @@ uint16_t ELFLinkingContext::getOutputMachine() const {
return llvm::ELF::EM_AARCH64;
case llvm::Triple::arm:
return llvm::ELF::EM_ARM;
- case llvm::Triple::amdgcn:
- return llvm::ELF::EM_AMDGPU;
default:
llvm_unreachable("Unhandled arch");
}
diff --git a/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt b/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt
index 6928f43c54592..e5c5cb77f38c6 100644
--- a/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/Hexagon/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldHexagonELFTarget
+add_lld_library(lldHexagonELFTarget
HexagonLinkingContext.cpp
HexagonRelocationHandler.cpp
HexagonTargetHandler.cpp
diff --git a/lib/ReaderWriter/ELF/Mips/CMakeLists.txt b/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
index 434e310640bd0..fd52a08ad2d8d 100644
--- a/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/Mips/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldMipsELFTarget
+add_lld_library(lldMipsELFTarget
MipsAbiInfoHandler.cpp
MipsCtorsOrderPass.cpp
MipsELFFile.cpp
diff --git a/lib/ReaderWriter/ELF/X86/CMakeLists.txt b/lib/ReaderWriter/ELF/X86/CMakeLists.txt
index 191f7ab3d61dc..5e3fe64dc15d1 100644
--- a/lib/ReaderWriter/ELF/X86/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/X86/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldX86ELFTarget
+add_lld_library(lldX86ELFTarget
X86LinkingContext.cpp
X86TargetHandler.cpp
X86RelocationHandler.cpp
diff --git a/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt b/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt
index 36ea839aa6743..61f4b4b524e82 100644
--- a/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/X86_64/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldX86_64ELFTarget
+add_lld_library(lldX86_64ELFTarget
X86_64LinkingContext.cpp
X86_64TargetHandler.cpp
X86_64RelocationHandler.cpp
diff --git a/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt b/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt
index d13c98008e55f..700b2550b1193 100644
--- a/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt
+++ b/lib/ReaderWriter/ELF/X86_64/ExampleSubTarget/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldExampleSubTarget
+add_lld_library(lldExampleSubTarget
ExampleLinkingContext.cpp
ExampleTargetHandler.cpp
LINK_LIBS
diff --git a/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp b/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
index 0ba590cc64223..778f6f4add74b 100644
--- a/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
+++ b/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
@@ -687,17 +687,28 @@ void ArchHandler_arm64::applyFixupRelocatable(const Reference &ref,
case delta64:
*loc64 = ref.addend() + inAtomAddress - fixupAddress;
return;
+ case unwindFDEToFunction:
+ // We don't emit unwindFDEToFunction in -r mode as they are implicitly
+ // generated from the data in the __eh_frame section. So here we need
+ // to use the targetAddress so that we can generate the full relocation
+ // when we parse again later.
+ *loc64 = targetAddress - fixupAddress;
+ return;
case delta32:
*loc32 = ref.addend() + inAtomAddress - fixupAddress;
return;
case negDelta32:
+ // We don't emit negDelta32 in -r mode as they are implicitly
+ // generated from the data in the __eh_frame section. So here we need
+ // to use the targetAddress so that we can generate the full relocation
+ // when we parse again later.
*loc32 = fixupAddress - targetAddress + ref.addend();
return;
case pointer64ToGOT:
*loc64 = 0;
return;
case delta32ToGOT:
- *loc32 = -fixupAddress;
+ *loc32 = inAtomAddress - fixupAddress;
return;
case addOffset12:
llvm_unreachable("lazy reference kind implies GOT pass was run");
@@ -709,9 +720,6 @@ void ArchHandler_arm64::applyFixupRelocatable(const Reference &ref,
case unwindInfoToEhFrame:
llvm_unreachable("fixup implies __unwind_info");
return;
- case unwindFDEToFunction:
- // Do nothing for now
- return;
case invalid:
// Fall into llvm_unreachable().
break;
diff --git a/lib/ReaderWriter/MachO/CMakeLists.txt b/lib/ReaderWriter/MachO/CMakeLists.txt
index 7ce782af6f998..a389ca51ddfdc 100644
--- a/lib/ReaderWriter/MachO/CMakeLists.txt
+++ b/lib/ReaderWriter/MachO/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldMachO
+add_lld_library(lldMachO
ArchHandler.cpp
ArchHandler_arm.cpp
ArchHandler_arm64.cpp
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
index 613c1b2f251ab..1226860b021e0 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
@@ -168,7 +168,8 @@ void relocatableSectionInfoForContentType(DefinedAtom::ContentType atomType,
StringRef &segmentName,
StringRef &sectionName,
SectionType &sectionType,
- SectionAttr &sectionAttrs);
+ SectionAttr &sectionAttrs,
+ bool &relocsToDefinedCanBeImplicit);
} // namespace normalized
} // namespace mach_o
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index e830db9fcc7bd..575bc1a2b3a9d 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -50,7 +50,8 @@ struct AtomInfo {
struct SectionInfo {
SectionInfo(StringRef seg, StringRef sect, SectionType type,
- const MachOLinkingContext &ctxt, uint32_t attr=0);
+ const MachOLinkingContext &ctxt, uint32_t attr,
+ bool relocsToDefinedCanBeImplicit);
StringRef segmentName;
StringRef sectionName;
@@ -59,15 +60,25 @@ struct SectionInfo {
uint64_t address;
uint64_t size;
uint16_t alignment;
+
+ /// If this is set, the any relocs in this section which point to defined
+ /// addresses can be implicitly generated. This is the case for the
+ /// __eh_frame section where references to the function can be implicit if the
+ /// function is defined.
+ bool relocsToDefinedCanBeImplicit;
+
+
std::vector<AtomInfo> atomsAndOffsets;
uint32_t normalizedSectionIndex;
uint32_t finalSectionIndex;
};
SectionInfo::SectionInfo(StringRef sg, StringRef sct, SectionType t,
- const MachOLinkingContext &ctxt, uint32_t attrs)
+ const MachOLinkingContext &ctxt, uint32_t attrs,
+ bool relocsToDefinedCanBeImplicit)
: segmentName(sg), sectionName(sct), type(t), attributes(attrs),
address(0), size(0), alignment(1),
+ relocsToDefinedCanBeImplicit(relocsToDefinedCanBeImplicit),
normalizedSectionIndex(0), finalSectionIndex(0) {
uint16_t align = 1;
if (ctxt.sectionAligned(segmentName, sectionName, align)) {
@@ -193,10 +204,12 @@ SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) {
StringRef sectionName;
SectionType sectionType;
SectionAttr sectionAttrs;
+ bool relocsToDefinedCanBeImplicit;
// Use same table used by when parsing .o files.
relocatableSectionInfoForContentType(type, segmentName, sectionName,
- sectionType, sectionAttrs);
+ sectionType, sectionAttrs,
+ relocsToDefinedCanBeImplicit);
// If we already have a SectionInfo with this name, re-use it.
// This can happen if two ContentType map to the same mach-o section.
for (auto sect : _sectionMap) {
@@ -207,7 +220,8 @@ SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) {
}
// Otherwise allocate new SectionInfo object.
auto *sect = new (_allocator)
- SectionInfo(segmentName, sectionName, sectionType, _ctx, sectionAttrs);
+ SectionInfo(segmentName, sectionName, sectionType, _ctx, sectionAttrs,
+ relocsToDefinedCanBeImplicit);
_sectionInfos.push_back(sect);
_sectionMap[type] = sect;
return sect;
@@ -287,7 +301,8 @@ SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) {
}
// Otherwise allocate new SectionInfo object.
auto *sect = new (_allocator) SectionInfo(
- p.segmentName, p.sectionName, p.sectionType, _ctx, sectionAttrs);
+ p.segmentName, p.sectionName, p.sectionType, _ctx, sectionAttrs,
+ /* relocsToDefinedCanBeImplicit */ false);
_sectionInfos.push_back(sect);
_sectionMap[atomType] = sect;
return sect;
@@ -320,7 +335,8 @@ SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) {
StringRef segName = customName.slice(0, seperatorIndex);
StringRef sectName = customName.drop_front(seperatorIndex + 1);
auto *sect =
- new (_allocator) SectionInfo(segName, sectName, S_REGULAR, _ctx);
+ new (_allocator) SectionInfo(segName, sectName, S_REGULAR, _ctx,
+ 0, /* relocsToDefinedCanBeImplicit */ false);
_customSections.push_back(sect);
_sectionInfos.push_back(sect);
return sect;
@@ -1024,6 +1040,11 @@ void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) {
for (const AtomInfo &info : si->atomsAndOffsets) {
const DefinedAtom *atom = info.atom;
for (const Reference *ref : *atom) {
+ // Skip emitting relocs for sections which are always able to be
+ // implicitly regenerated and where the relocation targets an address
+ // which is defined.
+ if (si->relocsToDefinedCanBeImplicit && isa<DefinedAtom>(ref->target()))
+ continue;
_archHandler.appendSectionRelocations(*atom, info.offsetInSection, *ref,
symIndexForAtom,
sectIndexForAtom,
diff --git a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 1c4bb1d4f6a33..f9499b6032140 100644
--- a/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -1034,7 +1034,8 @@ void relocatableSectionInfoForContentType(DefinedAtom::ContentType atomType,
StringRef &segmentName,
StringRef &sectionName,
SectionType &sectionType,
- SectionAttr &sectionAttrs) {
+ SectionAttr &sectionAttrs,
+ bool &relocsToDefinedCanBeImplicit) {
for (const MachORelocatableSectionToAtomType *p = sectsToAtomType ;
p->atomType != DefinedAtom::typeUnknown; ++p) {
@@ -1047,8 +1048,11 @@ void relocatableSectionInfoForContentType(DefinedAtom::ContentType atomType,
sectionName = p->sectionName;
sectionType = p->sectionType;
sectionAttrs = 0;
+ relocsToDefinedCanBeImplicit = false;
if (atomType == DefinedAtom::typeCode)
sectionAttrs = S_ATTR_PURE_INSTRUCTIONS;
+ if (atomType == DefinedAtom::typeCFI)
+ relocsToDefinedCanBeImplicit = true;
return;
}
llvm_unreachable("content type not yet supported");
diff --git a/lib/ReaderWriter/YAML/CMakeLists.txt b/lib/ReaderWriter/YAML/CMakeLists.txt
index b955baa94202a..5c25444e5dbc4 100644
--- a/lib/ReaderWriter/YAML/CMakeLists.txt
+++ b/lib/ReaderWriter/YAML/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldYAML
+add_lld_library(lldYAML
ReaderWriterYAML.cpp
LINK_LIBS
lldCore