003 File Manager
Current Path:
/usr/src/contrib/llvm-project/lld/ELF
usr
/
src
/
contrib
/
llvm-project
/
lld
/
ELF
/
📁
..
📄
AArch64ErrataFix.cpp
(25.49 KB)
📄
AArch64ErrataFix.h
(1.35 KB)
📄
ARMErrataFix.cpp
(21.67 KB)
📄
ARMErrataFix.h
(1.38 KB)
📁
Arch
📄
CallGraphSort.cpp
(8.81 KB)
📄
CallGraphSort.h
(652 B)
📄
Config.h
(10.49 KB)
📄
DWARF.cpp
(5.75 KB)
📄
DWARF.h
(2.97 KB)
📄
Driver.cpp
(80.51 KB)
📄
Driver.h
(2.1 KB)
📄
DriverUtils.cpp
(8.74 KB)
📄
EhFrame.cpp
(5.42 KB)
📄
EhFrame.h
(680 B)
📄
ICF.cpp
(19.74 KB)
📄
ICF.h
(531 B)
📄
InputFiles.cpp
(63.74 KB)
📄
InputFiles.h
(12.88 KB)
📄
InputSection.cpp
(54.78 KB)
📄
InputSection.h
(14 KB)
📄
LTO.cpp
(12.64 KB)
📄
LTO.h
(1.65 KB)
📄
LinkerScript.cpp
(44.6 KB)
📄
LinkerScript.h
(10.59 KB)
📄
MapFile.cpp
(9.1 KB)
📄
MapFile.h
(581 B)
📄
MarkLive.cpp
(14.18 KB)
📄
MarkLive.h
(566 B)
📄
Options.td
(27.47 KB)
📄
OutputSections.cpp
(19.23 KB)
📄
OutputSections.h
(4.73 KB)
📄
README.md
(20 B)
📄
Relocations.cpp
(81.61 KB)
📄
Relocations.h
(5.89 KB)
📄
ScriptLexer.cpp
(8.99 KB)
📄
ScriptLexer.h
(1.31 KB)
📄
ScriptParser.cpp
(48.05 KB)
📄
ScriptParser.h
(961 B)
📄
SymbolTable.cpp
(9.72 KB)
📄
SymbolTable.h
(3.62 KB)
📄
Symbols.cpp
(23.27 KB)
📄
Symbols.h
(20.34 KB)
📄
SyntheticSections.cpp
(134.95 KB)
📄
SyntheticSections.h
(40.28 KB)
📄
Target.cpp
(5.79 KB)
📄
Target.h
(10.89 KB)
📄
Thunks.cpp
(35.71 KB)
📄
Thunks.h
(2.69 KB)
📄
Writer.cpp
(108.98 KB)
📄
Writer.h
(1.79 KB)
Editing: OutputSections.h
//===- OutputSections.h -----------------------------------------*- C++ -*-===// // // 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 // //===----------------------------------------------------------------------===// #ifndef LLD_ELF_OUTPUT_SECTIONS_H #define LLD_ELF_OUTPUT_SECTIONS_H #include "Config.h" #include "InputSection.h" #include "LinkerScript.h" #include "Relocations.h" #include "lld/Common/LLVM.h" #include "llvm/MC/StringTableBuilder.h" #include "llvm/Object/ELF.h" #include <array> namespace lld { namespace elf { struct PhdrEntry; class InputSection; class InputSectionBase; // This represents a section in an output file. // It is composed of multiple InputSections. // The writer creates multiple OutputSections and assign them unique, // non-overlapping file offsets and VAs. class OutputSection final : public BaseCommand, public SectionBase { public: OutputSection(StringRef name, uint32_t type, uint64_t flags); static bool classof(const SectionBase *s) { return s->kind() == SectionBase::Output; } 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); uint32_t sectionIndex = UINT32_MAX; unsigned sortRank; uint32_t getPhdrFlags() const; // Pointer to the PT_LOAD segment, which this section resides in. This field // is used to correctly compute file offset of a section. When two sections // share the same load segment, difference between their file offsets should // be equal to difference between their virtual addresses. To compute some // 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; // 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; // 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; // The following fields correspond to Elf_Shdr members. uint64_t offset = 0; uint64_t addr = 0; uint32_t shName = 0; void recordSection(InputSectionBase *isec); void commitSection(InputSection *isec); void finalizeInputSections(); // 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 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 sortInitFini(); void sortCtorsDtors(); private: // Used for implementation of --compress-debug-sections option. std::vector<uint8_t> zDebugHeader; llvm::SmallVector<char, 1> compressedData; std::array<uint8_t, 4> getFiller(); }; int getPriority(StringRef s); InputSection *getFirstInputSection(const OutputSection *os); std::vector<InputSection *> getInputSections(const 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 *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 } // namespace lld namespace lld { namespace elf { uint64_t getHeaderSize(); extern std::vector<OutputSection *> outputSections; } // namespace elf } // namespace lld #endif
Upload File
Create Folder