summaryrefslogtreecommitdiff
path: root/gnu/llvm/lld
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2020-08-03 14:32:30 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2020-08-03 14:32:30 +0000
commite0fcd2e117b9fa0cba33d1b3ea597b2a4e2b4928 (patch)
tree8c02b9a4a05fe54cc17c4b44dfa27312b3571d78 /gnu/llvm/lld
parentbf6d7a195d16eec6ec7f3a7eb8546a41d3cc2958 (diff)
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom tested by plenty
Diffstat (limited to 'gnu/llvm/lld')
-rw-r--r--gnu/llvm/lld/ELF/SyntheticSections.h135
1 files changed, 38 insertions, 97 deletions
diff --git a/gnu/llvm/lld/ELF/SyntheticSections.h b/gnu/llvm/lld/ELF/SyntheticSections.h
index bc24922598f..5f59178fb54 100644
--- a/gnu/llvm/lld/ELF/SyntheticSections.h
+++ b/gnu/llvm/lld/ELF/SyntheticSections.h
@@ -23,7 +23,6 @@
#include "DWARF.h"
#include "EhFrame.h"
#include "InputSection.h"
-#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/MC/StringTableBuilder.h"
#include "llvm/Support/Endian.h"
@@ -89,8 +88,6 @@ public:
std::vector<FdeData> getFdeData() const;
ArrayRef<CieRecord *> getCieRecords() const { return cieRecords; }
- template <class ELFT>
- void iterateFDEWithLSDA(llvm::function_ref<void(InputSection &)> fn);
private:
// This is used only when parsing EhInputSection. We keep it here to avoid
@@ -101,17 +98,14 @@ private:
template <class ELFT, class RelTy>
void addRecords(EhInputSection *s, llvm::ArrayRef<RelTy> rels);
- template <class ELFT> void addSectionAux(EhInputSection *s);
- template <class ELFT, class RelTy>
- void iterateFDEWithLSDAAux(EhInputSection &sec, ArrayRef<RelTy> rels,
- llvm::DenseSet<size_t> &ciesWithLSDA,
- llvm::function_ref<void(InputSection &)> fn);
+ template <class ELFT>
+ void addSectionAux(EhInputSection *s);
template <class ELFT, class RelTy>
CieRecord *addCie(EhSectionPiece &piece, ArrayRef<RelTy> rels);
template <class ELFT, class RelTy>
- Defined *isFdeLive(EhSectionPiece &piece, ArrayRef<RelTy> rels);
+ bool isFdeLive(EhSectionPiece &piece, ArrayRef<RelTy> rels);
uint64_t getFdePc(uint8_t *buf, size_t off, uint8_t enc) const;
@@ -370,7 +364,7 @@ private:
// Try to merge two GOTs. In case of success the `Dst` contains
// result of merging and the function returns true. In case of
- // overflow the `Dst` is unchanged and the function returns false.
+ // ovwerflow the `Dst` is unchanged and the function returns false.
bool tryMergeGots(FileGot & dst, FileGot & src, bool isPrimary);
};
@@ -425,73 +419,48 @@ private:
class DynamicReloc {
public:
- enum Kind {
- /// The resulting dynamic relocation does not reference a symbol (#sym must
- /// be nullptr) and uses #addend as the result of computeAddend().
- AddendOnly,
- /// The resulting dynamic relocation will not reference a symbol: #sym is
- /// only used to compute the addend with InputSection::getRelocTargetVA().
- /// Useful for various relative and TLS relocations (e.g. R_X86_64_TPOFF64).
- AddendOnlyWithTargetVA,
- /// The resulting dynamic relocation references symbol #sym from the dynamic
- /// symbol table and uses #addend as the value of computeAddend().
- AgainstSymbol,
- /// The resulting dynamic relocation references symbol #sym from the dynamic
- /// symbol table and uses InputSection::getRelocTargetVA() + #addend for the
- /// final addend. It can be used for relocations that write the symbol VA as
- // the addend (e.g. R_MIPS_TLS_TPREL64) but still reference the symbol.
- AgainstSymbolWithTargetVA,
- /// This is used by the MIPS multi-GOT implementation. It relocates
- /// addresses of 64kb pages that lie inside the output section.
- MipsMultiGotPage,
- };
- /// This constructor records a relocation against a symbol.
DynamicReloc(RelType type, const InputSectionBase *inputSec,
- uint64_t offsetInSec, Kind kind, Symbol &sym, int64_t addend,
- RelExpr expr)
- : type(type), sym(&sym), inputSec(inputSec), offsetInSec(offsetInSec),
- kind(kind), expr(expr), addend(addend) {}
- /// This constructor records a relative relocation with no symbol.
- DynamicReloc(RelType type, const InputSectionBase *inputSec,
- uint64_t offsetInSec, int64_t addend = 0)
- : type(type), sym(nullptr), inputSec(inputSec), offsetInSec(offsetInSec),
- kind(AddendOnly), expr(R_ADDEND), addend(addend) {}
- /// This constructor records dynamic relocation settings used by the MIPS
- /// multi-GOT implementation.
+ uint64_t offsetInSec, bool useSymVA, Symbol *sym, int64_t addend)
+ : type(type), sym(sym), inputSec(inputSec), offsetInSec(offsetInSec),
+ useSymVA(useSymVA), addend(addend), outputSec(nullptr) {}
+ // This constructor records dynamic relocation settings used by MIPS
+ // multi-GOT implementation. It's to relocate addresses of 64kb pages
+ // lie inside the output section.
DynamicReloc(RelType type, const InputSectionBase *inputSec,
uint64_t offsetInSec, const OutputSection *outputSec,
int64_t addend)
: type(type), sym(nullptr), inputSec(inputSec), offsetInSec(offsetInSec),
- kind(MipsMultiGotPage), expr(R_ADDEND), addend(addend),
- outputSec(outputSec) {}
+ useSymVA(false), addend(addend), outputSec(outputSec) {}
uint64_t getOffset() const;
uint32_t getSymIndex(SymbolTableBaseSection *symTab) const;
- bool needsDynSymIndex() const {
- return kind == AgainstSymbol || kind == AgainstSymbolWithTargetVA;
- }
- /// Computes the addend of the dynamic relocation. Note that this is not the
- /// same as the #addend member variable as it may also include the symbol
- /// address/the address of the corresponding GOT entry/etc.
+ // Computes the addend of the dynamic relocation. Note that this is not the
+ // same as the addend member variable as it also includes the symbol address
+ // if useSymVA is true.
int64_t computeAddend() const;
RelType type;
+
Symbol *sym;
- const InputSectionBase *inputSec;
+ const InputSectionBase *inputSec = nullptr;
uint64_t offsetInSec;
-
-private:
- Kind kind;
- // The kind of expression used to calculate the added (required e.g. for
- // relative GOT relocations).
- RelExpr expr;
+ // If this member is true, the dynamic relocation will not be against the
+ // symbol but will instead be a relative relocation that simply adds the
+ // load address. This means we need to write the symbol virtual address
+ // plus the original addend as the final relocation addend.
+ bool useSymVA;
int64_t addend;
- const OutputSection *outputSec = nullptr;
+ const OutputSection *outputSec;
};
template <class ELFT> class DynamicSection final : public SyntheticSection {
- LLVM_ELF_IMPORT_TYPES_ELFT(ELFT)
+ using Elf_Dyn = typename ELFT::Dyn;
+ using Elf_Rel = typename ELFT::Rel;
+ using Elf_Rela = typename ELFT::Rela;
+ using Elf_Relr = typename ELFT::Relr;
+ using Elf_Shdr = typename ELFT::Shdr;
+ using Elf_Sym = typename ELFT::Sym;
// finalizeContents() fills this vector with the section contents.
std::vector<std::pair<int32_t, std::function<uint64_t()>>> entries;
@@ -518,37 +487,18 @@ class RelocationBaseSection : public SyntheticSection {
public:
RelocationBaseSection(StringRef name, uint32_t type, int32_t dynamicTag,
int32_t sizeDynamicTag);
- /// Add a dynamic relocation without writing an addend to the output section.
- /// This overload can be used if the addends are written directly instead of
- /// using relocations on the input section (e.g. MipsGotSection::writeTo()).
+ void addReloc(RelType dynType, InputSectionBase *isec, uint64_t offsetInSec,
+ Symbol *sym);
+ // Add a dynamic relocation that might need an addend. This takes care of
+ // writing the addend to the output section if needed.
+ void addReloc(RelType dynType, InputSectionBase *inputSec,
+ uint64_t offsetInSec, Symbol *sym, int64_t addend, RelExpr expr,
+ RelType type);
void addReloc(const DynamicReloc &reloc);
- /// Add a dynamic relocation against \p sym with an optional addend.
- void addSymbolReloc(RelType dynType, InputSectionBase *isec,
- uint64_t offsetInSec, Symbol &sym, int64_t addend = 0,
- llvm::Optional<RelType> addendRelType = llvm::None);
- /// Add a relative dynamic relocation that uses the target address of \p sym
- /// (i.e. InputSection::getRelocTargetVA()) + \p addend as the addend.
- void addRelativeReloc(RelType dynType, InputSectionBase *isec,
- uint64_t offsetInSec, Symbol &sym, int64_t addend,
- RelType addendRelType, RelExpr expr);
- /// Add a dynamic relocation using the target address of \p sym as the addend
- /// if \p sym is non-preemptible. Otherwise add a relocation against \p sym.
- void addAddendOnlyRelocIfNonPreemptible(RelType dynType,
- InputSectionBase *isec,
- uint64_t offsetInSec, Symbol &sym,
- RelType addendRelType);
- void addReloc(DynamicReloc::Kind kind, RelType dynType,
- InputSectionBase *inputSec, uint64_t offsetInSec, Symbol &sym,
- int64_t addend, RelExpr expr, RelType addendRelType);
bool isNeeded() const override { return !relocs.empty(); }
size_t getSize() const override { return relocs.size() * this->entsize; }
size_t getRelativeRelocCount() const { return numRelativeRelocs; }
void finalizeContents() override;
- static bool classof(const SectionBase *d) {
- return SyntheticSection::classof(d) &&
- (d->type == llvm::ELF::SHT_RELA || d->type == llvm::ELF::SHT_REL ||
- d->type == llvm::ELF::SHT_RELR);
- }
int32_t dynamicTag, sizeDynamicTag;
std::vector<DynamicReloc> relocs;
@@ -734,6 +684,7 @@ public:
size_t getNumEntries() const { return entries.size(); }
size_t headerSize;
+ size_t footerSize = 0;
std::vector<const Symbol *> entries;
};
@@ -754,16 +705,6 @@ public:
void addEntry(Symbol &sym);
};
-class PPC32GlinkSection : public PltSection {
-public:
- PPC32GlinkSection();
- void writeTo(uint8_t *buf) override;
- size_t getSize() const override;
-
- std::vector<const Symbol *> canonical_plts;
- static constexpr size_t footerSize = 64;
-};
-
// This is x86-only.
class IBTPltSection : public SyntheticSection {
public:
@@ -1096,7 +1037,7 @@ public:
std::vector<InputSection *> exidxSections;
private:
- size_t size = 0;
+ size_t size;
// Instead of storing pointers to the .ARM.exidx InputSections from
// InputObjects, we store pointers to the executable sections that need
@@ -1244,7 +1185,7 @@ inline Partition &SectionBase::getPartition() const {
// Linker generated sections which can be used as inputs and are not specific to
// a partition.
struct InStruct {
- InputSection *attributes;
+ InputSection *armAttributes;
BssSection *bss;
BssSection *bssRelRo;
GotSection *got;