aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-01-13 20:06:04 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-01-13 20:06:04 +0000
commitb289257c7f3ed78b7d3971c596d7c60a9050c705 (patch)
treed6b57e29a5a86347a020d6f0cae76cc2d0f3bf8d /lib
parentfba2c04f31e119eacf142fcbbaabd5a9e63a39ed (diff)
downloadsrc-b289257c7f3ed78b7d3971c596d7c60a9050c705.tar.gz
src-b289257c7f3ed78b7d3971c596d7c60a9050c705.zip
Vendor import of lld trunk r257626:vendor/lld/lld-trunk-r257626
Notes
Notes: svn path=/vendor/lld/dist/; revision=293846 svn path=/vendor/lld/lld-trunk-r257626/; revision=293847; tag=vendor/lld/lld-trunk-r257626
Diffstat (limited to 'lib')
-rw-r--r--lib/Config/CMakeLists.txt6
-rw-r--r--lib/Core/CMakeLists.txt6
-rw-r--r--lib/Driver/CMakeLists.txt7
-rw-r--r--lib/Driver/GnuLdDriver.cpp1
-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
31 files changed, 76 insertions, 455 deletions
diff --git a/lib/Config/CMakeLists.txt b/lib/Config/CMakeLists.txt
index f7ea0423b2c9..e971b0b7aa62 100644
--- a/lib/Config/CMakeLists.txt
+++ b/lib/Config/CMakeLists.txt
@@ -1,5 +1,9 @@
-add_llvm_library(lldConfig
+add_lld_library(lldConfig
Version.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${LLD_INCLUDE_DIR}/lld/Config
+
LINK_LIBS
LLVMSupport
)
diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt
index 009b50a38335..41e0e7661b9c 100644
--- a/lib/Core/CMakeLists.txt
+++ b/lib/Core/CMakeLists.txt
@@ -1,4 +1,4 @@
-add_llvm_library(lldCore
+add_lld_library(lldCore
DefinedAtom.cpp
Error.cpp
File.cpp
@@ -7,6 +7,10 @@ add_llvm_library(lldCore
Resolver.cpp
SymbolTable.cpp
Writer.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${LLD_INCLUDE_DIR}/lld/Core
+
LINK_LIBS
LLVMSupport
)
diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt
index 64498ccf78ba..840ccce50ab3 100644
--- a/lib/Driver/CMakeLists.txt
+++ b/lib/Driver/CMakeLists.txt
@@ -8,12 +8,16 @@ set(LLVM_TARGET_DEFINITIONS DarwinLdOptions.td)
tablegen(LLVM DarwinLdOptions.inc -gen-opt-parser-defs)
add_public_tablegen_target(DriverOptionsTableGen)
-add_llvm_library(lldDriver
+add_lld_library(lldDriver
CoreDriver.cpp
DarwinLdDriver.cpp
Driver.cpp
GnuLdDriver.cpp
UniversalDriver.cpp
+
+ ADDITIONAL_HEADER_DIRS
+ ${LLD_INCLUDE_DIR}/lld/Driver
+
LINK_LIBS
lldConfig
lldMachO
@@ -21,7 +25,6 @@ add_llvm_library(lldDriver
lldELF
lldELF2
lldAArch64ELFTarget
- lldAMDGPUELFTarget
lldARMELFTarget
lldHexagonELFTarget
lldMipsELFTarget
diff --git a/lib/Driver/GnuLdDriver.cpp b/lib/Driver/GnuLdDriver.cpp
index 8c75126d6d41..1cff481dd8d7 100644
--- a/lib/Driver/GnuLdDriver.cpp
+++ b/lib/Driver/GnuLdDriver.cpp
@@ -325,7 +325,6 @@ std::unique_ptr<ELFLinkingContext>
GnuLdDriver::createELFLinkingContext(llvm::Triple triple) {
std::unique_ptr<ELFLinkingContext> p;
if ((p = elf::createAArch64LinkingContext(triple))) return p;
- if ((p = elf::createAMDGPULinkingContext(triple))) return p;
if ((p = elf::createARMLinkingContext(triple))) return p;
if ((p = elf::createExampleLinkingContext(triple))) return p;
if ((p = elf::createHexagonLinkingContext(triple))) return p;
diff --git a/lib/ReaderWriter/CMakeLists.txt b/lib/ReaderWriter/CMakeLists.txt
index 588f0d85a586..2bb5655b9e35 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 2347dda9adb0..aae6420008a4 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 89efeb23d6f8..000000000000
--- 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 accc00b8a054..000000000000
--- 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 b1e83641fa82..000000000000
--- 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 1cc7a3c7694f..000000000000
--- 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 ca5a77db9177..000000000000
--- 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 90d37274aebf..000000000000
--- 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 0824974d4602..000000000000
--- 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 41c3be5cb38f..000000000000
--- 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 ff4b600158bd..000000000000
--- 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 8d0f70b6e7f7..000000000000
--- 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 9c9cc10fe397..000000000000
--- 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 2ccf9eb6266d..c8cd6533d902 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 e3e4a02b2810..3bc338507db6 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 2904c7b0dae0..70d6d618207d 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 6928f43c5459..e5c5cb77f38c 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 434e310640bd..fd52a08ad2d8 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 191f7ab3d61d..5e3fe64dc15d 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 36ea839aa674..61f4b4b524e8 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 d13c98008e55..700b2550b119 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 0ba590cc6422..778f6f4add74 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 7ce782af6f99..a389ca51ddfd 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 613c1b2f251a..1226860b021e 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 e830db9fcc7b..575bc1a2b3a9 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 1c4bb1d4f6a3..f9499b603214 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 b955baa94202..5c25444e5dbc 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