Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/eld/Object/OutputSectionEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BranchIsland *>
getBranchIslandsForSymbol(ResolveInfo *PSym) const {
Expand Down Expand Up @@ -219,6 +222,7 @@ class OutputSectionEntry {
llvm::SmallVector<MergeableString *, 0> AllStrings;
uint64_t Hash = 0;
llvm::StringMap<uint64_t> TrampolineNameToCountMap;
uint64_t PAddr = 0;
};

} // namespace eld
Expand Down
13 changes: 5 additions & 8 deletions include/eld/Readers/ELFSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(); }

Expand Down Expand Up @@ -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);

Expand All @@ -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; }

Expand Down Expand Up @@ -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.
Expand Down
15 changes: 14 additions & 1 deletion lib/Readers/ELFSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//

#include "eld/Readers/ELFSection.h"
#include "eld/Object/OutputSectionEntry.h"
#include "llvm/ADT/StringRef.h"

using namespace eld;
Expand Down Expand Up @@ -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 {
Expand Down
Loading