-
Notifications
You must be signed in to change notification settings - Fork 40
Add source assignment in symbol nodes #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -222,6 +222,9 @@ bool Assignment::assign(Module &CurModule, const ELFSection *Section) { | |
| ThisSymbol->setScriptValueDefined(); | ||
| } | ||
|
|
||
| auto &Backend = CurModule.getBackend(); | ||
| Backend.updateLatestAssignment(Name, this); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wont this cause issues if the symbol assignment is PROVIDE ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, this does not change how PROVIDE assignments are evaluated. Why do you think it would cause issues with PROVIDE? |
||
|
|
||
| if (CurModule.getPrinter()->traceAssignments()) | ||
| trace(llvm::outs()); | ||
| return true; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| #include "eld/Core/LinkerScript.h" | ||
| #include "eld/Core/Module.h" | ||
| #include "eld/Readers/ELFSection.h" | ||
| #include "eld/Script/Assignment.h" | ||
| #include "eld/Script/ScriptFile.h" | ||
| #include "eld/Support/MsgHandling.h" | ||
| #include "eld/Support/Utils.h" | ||
|
|
@@ -133,10 +134,17 @@ bool Symbol::hasDot() const { | |
| } | ||
|
|
||
| eld::Expected<uint64_t> Symbol::evalImpl() { | ||
|
|
||
| if (!ThisSymbol) | ||
| ThisSymbol = ThisModule.getNamePool().findSymbol(Name); | ||
|
|
||
| if (!SourceAssignment && ThisSymbol->resolveInfo()->isAbsolute()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be isScriptDefined() ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use assembly using .set |
||
| auto &Backend = ThisModule.getBackend(); | ||
| const auto *A = Backend.getLatestAssignment(Name); | ||
| if (!A) | ||
| A = ThisModule.getAssignmentForSymbol(Name); | ||
| SourceAssignment = A; | ||
| } | ||
|
|
||
| if (!ThisSymbol || ThisSymbol->resolveInfo()->isUndef() || | ||
| ThisSymbol->resolveInfo()->isBitCode()) | ||
| return std::make_unique<plugin::DiagnosticEntry>( | ||
|
|
@@ -152,6 +160,10 @@ eld::Expected<uint64_t> Symbol::evalImpl() { | |
| "using a symbol that points to a non allocatable section!"); | ||
| return Section->addr() + FragRef->getOutputOffset(ThisModule); | ||
| } | ||
| if (hasDot()) | ||
| return ThisSymbol->value(); | ||
| if (SourceAssignment) | ||
| return SourceAssignment->value(); | ||
| return ThisSymbol->value(); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3100,6 +3100,7 @@ bool GNULDBackend::layout() { | |
| return false; | ||
| } | ||
|
|
||
| // FIXME: Adding more symbols this late can cause layout issues. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. magic symbols are defined before layout, why would this cause issue ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are defining these symbols after the layout is performed, right? The layout is performed above this, at line 3079, in the |
||
| { | ||
| eld::RegisterTimer T("Define Magic Symbols", "Establish Layout", | ||
| m_Module.getConfig().options().printTimingStats()); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why backend ? can we store this in LinkerScript ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are used during the layout computation. Currently, the entire logic for layout computation is in GNULDBackend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest assignment would then become PROVIDE which will not be provided because of the preceding assignment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assignment::assignfor a PROVIDE assignment is only called if the assignment is indeed provided.