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
1 change: 1 addition & 0 deletions include/eld/Readers/Relocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class Relocation {
Type type() const { return m_Type; }

/// symValue - S value - the symbol address
Address symValue(Module &M, bool &Uncertain) const;
Address symValue(Module &M) const;

/// symOffset - Offset of the symbol
Expand Down
218 changes: 172 additions & 46 deletions include/eld/Script/Expression.h

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions include/eld/SymbolResolver/LDSymbol.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,13 @@ class LDSymbol {

bool scriptValueDefined() const { return ThisSymbolHasScriptValue; }

void setScriptValueDefined(bool Value = true) {
ThisSymbolHasScriptValue = Value;
void setScriptValueDefined(bool Uncertain) {
ThisSymbolHasScriptValue = true;
ThisSymbolHasUncertainValue = Uncertain;
}

bool isUncertain() const { return ThisSymbolHasUncertainValue; }

const FragmentRef *fragRef() const { return ThisFragRef; }

FragmentRef *fragRef() { return ThisFragRef; }
Expand Down Expand Up @@ -166,6 +169,7 @@ class LDSymbol {
uint32_t ThisSymIdx;
bool ThisSymbolsIsScriptDefined;
bool ThisSymbolHasScriptValue;
bool ThisSymbolHasUncertainValue;
// used for ignore garbage collected Common symbols
bool ThisSymbolGarbageCollected;
};
Expand Down
1 change: 1 addition & 0 deletions include/eld/Target/Relocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class Relocator {
bool doDeMangle() const;

// Get the address for a relocation
Relocation::Address getSymValue(Relocation *R, bool &Uncertain);
Relocation::Address getSymValue(Relocation *R);

private:
Expand Down
16 changes: 13 additions & 3 deletions lib/Readers/Relocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Relocation::Address Relocation::place(Module &M) const {
return sect_addr + m_TargetAddress->getOutputOffset(M);
}

Relocation::Address Relocation::symValue(Module &M) const {
Relocation::Address Relocation::symValue(Module &M, bool &Uncertain) const {
const ELFSection *section = nullptr;
const FragmentRef *fragRef = nullptr;
ResolveInfo *info = m_pSymInfo;
Expand All @@ -99,16 +99,26 @@ Relocation::Address Relocation::symValue(Module &M) const {
bool isAllocSection = section ? section->isAlloc() : false;

// If allocatable section, value => (address + offset)
if (isAllocSection)
if (isAllocSection) {
Uncertain = false;
return section->addr() + fragRef->getOutputOffset(M);
}

// If non allocatable section, value => (offset)
if (section && !isAllocSection)
if (section) {
Uncertain = false;
return fragRef->getOutputOffset(M);
}

Uncertain = info->outSymbol()->isUncertain();
return info->outSymbol()->value();
}

Relocation::Address Relocation::symValue(Module &M) const {
bool Ignored;
return symValue(M, Ignored);
}

Relocation::Address Relocation::symOffset(Module &M) const {
const ELFSection *section = nullptr;
const FragmentRef *fragRef = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions lib/Script/Assignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ bool Assignment::assign(Module &CurModule, const ELFSection *Section) {
}

// evaluate, commit, then get the result of the expression
auto Result = ExpressionToEvaluate->evaluateAndRaiseError();
auto Result = ExpressionToEvaluate->evaluateUncertainAndRaiseError();
if (!Result)
return false;
ExpressionValue = *Result;
ExpressionValue = Result->value();

if (!checkLinkerScript(CurModule))
return false;
Expand All @@ -223,7 +223,7 @@ bool Assignment::assign(Module &CurModule, const ELFSection *Section) {
if (Sym != nullptr) {
ThisSymbol = Sym;
ThisSymbol->setValue(ExpressionValue);
ThisSymbol->setScriptValueDefined();
ThisSymbol->setScriptValueDefined(Result->isUncertain());
}

if (CurModule.getPrinter()->traceAssignments())
Expand Down
Loading
Loading