aboutsummaryrefslogtreecommitdiffstats
path: root/ELF/OutputSections.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:32 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:32 +0000
commitf1e1c239e31b467e17f1648b1f524fc9ab5b431a (patch)
treea855e7a2a8808555da60e6aa9601d6867eb23bac /ELF/OutputSections.h
parent7d6988fdd2aee0e033034e147f16fe05594a60e4 (diff)
downloadsrc-f1e1c239e31b467e17f1648b1f524fc9ab5b431a.tar.gz
src-f1e1c239e31b467e17f1648b1f524fc9ab5b431a.zip
Vendor import of stripped lld trunk r366426 (just before the release_90vendor/lld/lld-trunk-r366426
Notes
Notes: svn path=/vendor/lld/dist/; revision=351288 svn path=/vendor/lld/lld-trunk-r366426/; revision=351289; tag=vendor/lld/lld-trunk-r366426
Diffstat (limited to 'ELF/OutputSections.h')
-rw-r--r--ELF/OutputSections.h122
1 files changed, 58 insertions, 64 deletions
diff --git a/ELF/OutputSections.h b/ELF/OutputSections.h
index 113bf6836926..fff8327ea376 100644
--- a/ELF/OutputSections.h
+++ b/ELF/OutputSections.h
@@ -1,9 +1,8 @@
//===- OutputSections.h -----------------------------------------*- C++ -*-===//
//
-// The LLVM Linker
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,17 +22,8 @@ namespace lld {
namespace elf {
struct PhdrEntry;
-class Symbol;
-struct EhSectionPiece;
-class EhInputSection;
class InputSection;
class InputSectionBase;
-class MergeInputSection;
-class OutputSection;
-template <class ELFT> class ObjFile;
-template <class ELFT> class SharedFile;
-class SharedSymbol;
-class Defined;
// This represents a section in an output file.
// It is composed of multiple InputSections.
@@ -41,19 +31,19 @@ class Defined;
// non-overlapping file offsets and VAs.
class OutputSection final : public BaseCommand, public SectionBase {
public:
- OutputSection(StringRef Name, uint32_t Type, uint64_t Flags);
+ OutputSection(StringRef name, uint32_t type, uint64_t flags);
- static bool classof(const SectionBase *S) {
- return S->kind() == SectionBase::Output;
+ static bool classof(const SectionBase *s) {
+ return s->kind() == SectionBase::Output;
}
- static bool classof(const BaseCommand *C);
+ static bool classof(const BaseCommand *c);
- uint64_t getLMA() const { return PtLoad ? Addr + PtLoad->LMAOffset : Addr; }
- template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *SHdr);
+ uint64_t getLMA() const { return ptLoad ? addr + ptLoad->lmaOffset : addr; }
+ template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *sHdr);
- uint32_t SectionIndex = UINT32_MAX;
- unsigned SortRank;
+ uint32_t sectionIndex = UINT32_MAX;
+ unsigned sortRank;
uint32_t getPhdrFlags() const;
@@ -64,78 +54,82 @@ public:
// section offset we use the following formula: Off = Off_first + VA -
// VA_first, where Off_first and VA_first is file offset and VA of first
// section in PT_LOAD.
- PhdrEntry *PtLoad = nullptr;
+ PhdrEntry *ptLoad = nullptr;
// Pointer to a relocation section for this section. Usually nullptr because
// we consume relocations, but if --emit-relocs is specified (which is rare),
// it may have a non-null value.
- OutputSection *RelocationSection = nullptr;
+ OutputSection *relocationSection = nullptr;
// Initially this field is the number of InputSections that have been added to
// the OutputSection so far. Later on, after a call to assignAddresses, it
// corresponds to the Elf_Shdr member.
- uint64_t Size = 0;
+ uint64_t size = 0;
// The following fields correspond to Elf_Shdr members.
- uint64_t Offset = 0;
- uint64_t Addr = 0;
- uint32_t ShName = 0;
-
- void addSection(InputSection *IS);
+ uint64_t offset = 0;
+ uint64_t addr = 0;
+ uint32_t shName = 0;
- // Location in the output buffer.
- uint8_t *Loc = nullptr;
+ void addSection(InputSection *isec);
// The following members are normally only used in linker scripts.
- MemoryRegion *MemRegion = nullptr;
- MemoryRegion *LMARegion = nullptr;
- Expr AddrExpr;
- Expr AlignExpr;
- Expr LMAExpr;
- Expr SubalignExpr;
- std::vector<BaseCommand *> SectionCommands;
- std::vector<StringRef> Phdrs;
- llvm::Optional<std::array<uint8_t, 4>> Filler;
- ConstraintKind Constraint = ConstraintKind::NoConstraint;
- std::string Location;
- std::string MemoryRegionName;
- std::string LMARegionName;
- bool NonAlloc = false;
- bool Noload = false;
- bool ExpressionsUseSymbols = false;
- bool InOverlay = false;
-
- template <class ELFT> void finalize();
- template <class ELFT> void writeTo(uint8_t *Buf);
+ MemoryRegion *memRegion = nullptr;
+ MemoryRegion *lmaRegion = nullptr;
+ Expr addrExpr;
+ Expr alignExpr;
+ Expr lmaExpr;
+ Expr subalignExpr;
+ std::vector<BaseCommand *> sectionCommands;
+ std::vector<StringRef> phdrs;
+ llvm::Optional<std::array<uint8_t, 4>> filler;
+ ConstraintKind constraint = ConstraintKind::NoConstraint;
+ std::string location;
+ std::string memoryRegionName;
+ std::string lmaRegionName;
+ bool nonAlloc = false;
+ bool noload = false;
+ bool expressionsUseSymbols = false;
+ bool usedInExpression = false;
+ bool inOverlay = false;
+
+ // Tracks whether the section has ever had an input section added to it, even
+ // if the section was later removed (e.g. because it is a synthetic section
+ // that wasn't needed). This is needed for orphan placement.
+ bool hasInputSections = false;
+
+ void finalize();
+ template <class ELFT> void writeTo(uint8_t *buf);
template <class ELFT> void maybeCompress();
- void sort(llvm::function_ref<int(InputSectionBase *S)> Order);
+ void sort(llvm::function_ref<int(InputSectionBase *s)> order);
void sortInitFini();
void sortCtorsDtors();
private:
// Used for implementation of --compress-debug-sections option.
- std::vector<uint8_t> ZDebugHeader;
- llvm::SmallVector<char, 1> CompressedData;
+ std::vector<uint8_t> zDebugHeader;
+ llvm::SmallVector<char, 1> compressedData;
std::array<uint8_t, 4> getFiller();
};
-int getPriority(StringRef S);
+int getPriority(StringRef s);
-std::vector<InputSection *> getInputSections(OutputSection* OS);
+std::vector<InputSection *> getInputSections(OutputSection* os);
// All output sections that are handled by the linker specially are
// globally accessible. Writer initializes them, so don't use them
// until Writer is initialized.
struct Out {
- static uint8_t First;
- static PhdrEntry *TlsPhdr;
- static OutputSection *ElfHeader;
- static OutputSection *ProgramHeaders;
- static OutputSection *PreinitArray;
- static OutputSection *InitArray;
- static OutputSection *FiniArray;
+ static uint8_t *bufferStart;
+ static uint8_t first;
+ static PhdrEntry *tlsPhdr;
+ static OutputSection *elfHeader;
+ static OutputSection *programHeaders;
+ static OutputSection *preinitArray;
+ static OutputSection *initArray;
+ static OutputSection *finiArray;
};
} // namespace elf
@@ -146,7 +140,7 @@ namespace elf {
uint64_t getHeaderSize();
-extern std::vector<OutputSection *> OutputSections;
+extern std::vector<OutputSection *> outputSections;
} // namespace elf
} // namespace lld