diff --git a/include/eld/Object/OutputSectionEntry.h b/include/eld/Object/OutputSectionEntry.h index ba4f485b6..6844123dc 100644 --- a/include/eld/Object/OutputSectionEntry.h +++ b/include/eld/Object/OutputSectionEntry.h @@ -154,6 +154,9 @@ class OutputSectionEntry { std::string getSectionTypeStr() const; + uint64_t pAddr() const { return PAddr; } + void setPaddr(uint64_t A) { PAddr = A; } + // ----------------------Reuse trampolines optimization--------------- std::vector getBranchIslandsForSymbol(ResolveInfo *PSym) const { @@ -219,6 +222,7 @@ class OutputSectionEntry { llvm::SmallVector AllStrings; uint64_t Hash = 0; llvm::StringMap TrampolineNameToCountMap; + uint64_t PAddr = 0; }; } // namespace eld diff --git a/include/eld/Readers/ELFSection.h b/include/eld/Readers/ELFSection.h index a3fbdbdb2..2690d887c 100644 --- a/include/eld/Readers/ELFSection.h +++ b/include/eld/Readers/ELFSection.h @@ -127,8 +127,7 @@ class ELFSection : public ELFSectionBase { ELFSectionBase *Link, uint32_t SectionSize, uint64_t PAddr) : ELFSectionBase(Section::ELF, ELFSectionKind, Name, Flags, EntSize, - AddrAlign, Type, Info, Link, SectionSize), - PAddr(PAddr) {} + AddrAlign, Type, Info, Link, SectionSize) {} explicit ELFSection(Section::Kind SectionKind, LDFileFormat::Kind ELFSectionKind, @@ -137,8 +136,7 @@ class ELFSection : public ELFSectionBase { ELFSectionBase *Link, uint32_t SectionSize, uint64_t PAddr) : ELFSectionBase(SectionKind, ELFSectionKind, Name, Flags, EntSize, - AddrAlign, Type, Info, Link, SectionSize), - PAddr(PAddr) {} + AddrAlign, Type, Info, Link, SectionSize) {} static bool classof(const Section *S) { return S->isELF(); } @@ -177,7 +175,7 @@ class ELFSection : public ELFSectionBase { bool hasVMA() const { return Addr != InvalidAddr; } - uint64_t pAddr() const { return PAddr; } + uint64_t pAddr() const; void setOffsetAndAddr(uint64_t Off); @@ -195,7 +193,7 @@ class ELFSection : public ELFSectionBase { return !isDiscard() && !isIgnore() && WantedInOutput; } - void setPaddr(size_t A) { PAddr = A; } + void setPaddr(size_t A); void setSymbol(LDSymbol *S) { Symbol = S; } @@ -300,8 +298,7 @@ class ELFSection : public ELFSectionBase { /// FIXME: This has different meanings for Input/Output sections. uint64_t Offset = ~uint64_t(0); uint64_t Addr = InvalidAddr; - /// FIXME: only relevant for output sections. - uint64_t PAddr; + LDSymbol *Symbol = nullptr; /// FIXME: Only relevant for LTO. This should be moved out. diff --git a/lib/Readers/ELFSection.cpp b/lib/Readers/ELFSection.cpp index a6f3ecc95..17af8b255 100644 --- a/lib/Readers/ELFSection.cpp +++ b/lib/Readers/ELFSection.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "eld/Readers/ELFSection.h" +#include "eld/Object/OutputSectionEntry.h" #include "llvm/ADT/StringRef.h" using namespace eld; @@ -160,13 +161,25 @@ Fragment *ELFSection::getFirstFragmentInRule() const { return nullptr; } +uint64_t ELFSection::pAddr() const { + OutputSectionEntry *OE = getOutputSection(); + if (!OE) + return 0; + return OE->pAddr(); +} + +void ELFSection::setPaddr(size_t A) { + OutputSectionEntry *OE = getOutputSection(); + ASSERT(OE, "expected output section"); + OE->setPaddr(A); +} + void ELFSection::setOffsetAndAddr(uint64_t Off) { Offset = Off; OutputSectionEntry *OE = getOutputSection(); if (!OE) return; Addr = Offset + OE->getSection()->addr(); - PAddr = Offset + OE->getSection()->pAddr(); } std::string ELFSection::getDecoratedName(const GeneralOptions &options) const {