#include "InputSection.h"
#include "Config.h"
#include "InputFiles.h"
#include "OutputSections.h"
#include "Relocations.h"
#include "SymbolTable.h"
#include "Symbols.h"
#include "SyntheticSections.h"
#include "Target.h"
#include "lld/Common/CommonLinkerContext.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/xxhash.h"
#include <algorithm>
#include <mutex>
#include <optional>
#include <vector>
usingnamespacellvm;
usingnamespacellvm::ELF;
usingnamespacellvm::object;
usingnamespacellvm::support;
usingnamespacellvm::support::endian;
usingnamespacellvm::sys;
usingnamespacelld;
usingnamespacelld::elf;
std::string lld::toString(const InputSectionBase *sec) { … }
template <class ELFT>
static ArrayRef<uint8_t> getSectionContents(ObjFile<ELFT> &file,
const typename ELFT::Shdr &hdr) { … }
InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
uint32_t type, uint64_t entsize,
uint32_t link, uint32_t info,
uint32_t addralign, ArrayRef<uint8_t> data,
StringRef name, Kind sectionKind)
: … { … }
static uint64_t getFlags(Ctx &ctx, uint64_t flags) { … }
template <class ELFT>
InputSectionBase::InputSectionBase(ObjFile<ELFT> &file,
const typename ELFT::Shdr &hdr,
StringRef name, Kind sectionKind)
: InputSectionBase(&file, getFlags(file.ctx, hdr.sh_flags), hdr.sh_type,
hdr.sh_entsize, hdr.sh_link, hdr.sh_info,
hdr.sh_addralign, getSectionContents(file, hdr), name,
sectionKind) { … }
size_t InputSectionBase::getSize() const { … }
template <class ELFT>
static void decompressAux(const InputSectionBase &sec, uint8_t *out,
size_t size) { … }
void InputSectionBase::decompress() const { … }
template <class ELFT>
RelsOrRelas<ELFT> InputSectionBase::relsOrRelas(bool supportsCrel) const { … }
Ctx &SectionBase::getCtx() const { … }
uint64_t SectionBase::getOffset(uint64_t offset) const { … }
uint64_t SectionBase::getVA(uint64_t offset) const { … }
OutputSection *SectionBase::getOutputSection() { … }
template <typename ELFT> void InputSectionBase::parseCompressedHeader() { … }
InputSection *InputSectionBase::getLinkOrderDep() const { … }
Defined *InputSectionBase::getEnclosingSymbol(uint64_t offset,
uint8_t type) const { … }
std::string InputSectionBase::getLocation(uint64_t offset) const { … }
std::string InputSectionBase::getSrcMsg(const Symbol &sym,
uint64_t offset) const { … }
std::string InputSectionBase::getObjMsg(uint64_t off) const { … }
PotentialSpillSection::PotentialSpillSection(const InputSectionBase &source,
InputSectionDescription &isd)
: … { … }
InputSection InputSection::discarded(nullptr, 0, 0, 0, ArrayRef<uint8_t>(), "");
InputSection::InputSection(InputFile *f, uint64_t flags, uint32_t type,
uint32_t addralign, ArrayRef<uint8_t> data,
StringRef name, Kind k)
: … { … }
template <class ELFT>
InputSection::InputSection(ObjFile<ELFT> &f, const typename ELFT::Shdr &header,
StringRef name)
: InputSectionBase(f, header, name, InputSectionBase::Regular) { … }
template <class ELFT> void InputSection::copyShtGroup(uint8_t *buf) { … }
InputSectionBase *InputSection::getRelocatedSection() const { … }
template <class ELFT, class RelTy>
void InputSection::copyRelocations(uint8_t *buf) { … }
template <class ELFT, class RelTy, class RelIt>
void InputSection::copyRelocations(uint8_t *buf,
llvm::iterator_range<RelIt> rels) { … }
static uint32_t getARMUndefinedRelativeWeakVA(RelType type, uint32_t a,
uint32_t p) { … }
static uint64_t getAArch64UndefinedRelativeWeakVA(uint64_t type, uint64_t p) { … }
static uint64_t getRISCVUndefinedRelativeWeakVA(uint64_t type, uint64_t p) { … }
static uint64_t getARMStaticBase(const Symbol &sym) { … }
static Relocation *getRISCVPCRelHi20(const InputSectionBase *loSec,
const Relocation &loReloc) { … }
static int64_t getTlsTpOffset(Ctx &ctx, const Symbol &s) { … }
uint64_t InputSectionBase::getRelocTargetVA(Ctx &ctx, const Relocation &r,
uint64_t p) const { … }
template <class ELFT, class RelTy>
void InputSection::relocateNonAlloc(uint8_t *buf, Relocs<RelTy> rels) { … }
template <class ELFT>
void InputSectionBase::relocate(uint8_t *buf, uint8_t *bufEnd) { … }
static void switchMorestackCallsToMorestackNonSplit(
DenseSet<Defined *> &prologues,
SmallVector<Relocation *, 0> &morestackCalls) { … }
static bool enclosingPrologueAttempted(uint64_t offset,
const DenseSet<Defined *> &prologues) { … }
template <class ELFT>
void InputSectionBase::adjustSplitStackFunctionPrologues(uint8_t *buf,
uint8_t *end) { … }
template <class ELFT> void InputSection::writeTo(uint8_t *buf) { … }
void InputSection::replace(InputSection *other) { … }
template <class ELFT>
EhInputSection::EhInputSection(ObjFile<ELFT> &f,
const typename ELFT::Shdr &header,
StringRef name)
: InputSectionBase(f, header, name, InputSectionBase::EHFrame) { … }
SyntheticSection *EhInputSection::getParent() const { … }
template <class ELFT> void EhInputSection::split() { … }
template <class ELFT, class RelTy>
void EhInputSection::split(ArrayRef<RelTy> rels) { … }
uint64_t EhInputSection::getParentOffset(uint64_t offset) const { … }
static size_t findNull(StringRef s, size_t entSize) { … }
void MergeInputSection::splitStrings(StringRef s, size_t entSize) { … }
void MergeInputSection::splitNonStrings(ArrayRef<uint8_t> data,
size_t entSize) { … }
template <class ELFT>
MergeInputSection::MergeInputSection(ObjFile<ELFT> &f,
const typename ELFT::Shdr &header,
StringRef name)
: InputSectionBase(f, header, name, InputSectionBase::Merge) { … }
MergeInputSection::MergeInputSection(uint64_t flags, uint32_t type,
uint64_t entsize, ArrayRef<uint8_t> data,
StringRef name)
: … { … }
void MergeInputSection::splitIntoPieces() { … }
SectionPiece &MergeInputSection::getSectionPiece(uint64_t offset) { … }
uint64_t MergeInputSection::getParentOffset(uint64_t offset) const { … }
template InputSection::InputSection(ObjFile<ELF32LE> &, const ELF32LE::Shdr &,
StringRef);
template InputSection::InputSection(ObjFile<ELF32BE> &, const ELF32BE::Shdr &,
StringRef);
template InputSection::InputSection(ObjFile<ELF64LE> &, const ELF64LE::Shdr &,
StringRef);
template InputSection::InputSection(ObjFile<ELF64BE> &, const ELF64BE::Shdr &,
StringRef);
template void InputSection::writeTo<ELF32LE>(uint8_t *);
template void InputSection::writeTo<ELF32BE>(uint8_t *);
template void InputSection::writeTo<ELF64LE>(uint8_t *);
template void InputSection::writeTo<ELF64BE>(uint8_t *);
template RelsOrRelas<ELF32LE>
InputSectionBase::relsOrRelas<ELF32LE>(bool) const;
template RelsOrRelas<ELF32BE>
InputSectionBase::relsOrRelas<ELF32BE>(bool) const;
template RelsOrRelas<ELF64LE>
InputSectionBase::relsOrRelas<ELF64LE>(bool) const;
template RelsOrRelas<ELF64BE>
InputSectionBase::relsOrRelas<ELF64BE>(bool) const;
template MergeInputSection::MergeInputSection(ObjFile<ELF32LE> &,
const ELF32LE::Shdr &, StringRef);
template MergeInputSection::MergeInputSection(ObjFile<ELF32BE> &,
const ELF32BE::Shdr &, StringRef);
template MergeInputSection::MergeInputSection(ObjFile<ELF64LE> &,
const ELF64LE::Shdr &, StringRef);
template MergeInputSection::MergeInputSection(ObjFile<ELF64BE> &,
const ELF64BE::Shdr &, StringRef);
template EhInputSection::EhInputSection(ObjFile<ELF32LE> &,
const ELF32LE::Shdr &, StringRef);
template EhInputSection::EhInputSection(ObjFile<ELF32BE> &,
const ELF32BE::Shdr &, StringRef);
template EhInputSection::EhInputSection(ObjFile<ELF64LE> &,
const ELF64LE::Shdr &, StringRef);
template EhInputSection::EhInputSection(ObjFile<ELF64BE> &,
const ELF64BE::Shdr &, StringRef);
template void EhInputSection::split<ELF32LE>();
template void EhInputSection::split<ELF32BE>();
template void EhInputSection::split<ELF64LE>();
template void EhInputSection::split<ELF64BE>();