forked from OSchip/llvm-project
[ELF] - Refactoring of LMA offset handling code. NFC.
Thanks to Rui Ueyama for suggestion. llvm-svn: 295943
This commit is contained in:
parent
b7f39b08f4
commit
2146787609
|
@ -463,9 +463,8 @@ void LinkerScript<ELFT>::switchTo(OutputSectionBase *Sec) {
|
|||
// will set the LMA such that the difference between VMA and LMA for the
|
||||
// section is the same as the preceding output section in the same region
|
||||
// https://sourceware.org/binutils/docs-2.20/ld/Output-Section-LMA.html
|
||||
Expr LMAExpr = CurLMA.first;
|
||||
if (LMAExpr)
|
||||
CurOutSec->setLMAOffset(LMAExpr(CurLMA.second) - CurLMA.second);
|
||||
if (LMAOffset)
|
||||
CurOutSec->setLMAOffset(LMAOffset());
|
||||
}
|
||||
|
||||
template <class ELFT> void LinkerScript<ELFT>::process(BaseCommand &Base) {
|
||||
|
@ -565,8 +564,10 @@ MemoryRegion *LinkerScript<ELFT>::findMemoryRegion(OutputSectionCommand *Cmd,
|
|||
// for a single sections command (e.g. ".text { *(.text); }").
|
||||
template <class ELFT>
|
||||
void LinkerScript<ELFT>::assignOffsets(OutputSectionCommand *Cmd) {
|
||||
if (Cmd->LMAExpr)
|
||||
CurLMA = {Cmd->LMAExpr, Dot};
|
||||
if (Cmd->LMAExpr) {
|
||||
uintX_t D = Dot;
|
||||
LMAOffset = [=] { return Cmd->LMAExpr(D) - D; };
|
||||
}
|
||||
OutputSectionBase *Sec = findSection<ELFT>(Cmd->Name, *OutputSections);
|
||||
if (!Sec)
|
||||
return;
|
||||
|
|
|
@ -298,7 +298,7 @@ private:
|
|||
OutputSectionBase *Sec);
|
||||
|
||||
uintX_t Dot;
|
||||
std::pair<Expr, uintX_t> CurLMA;
|
||||
std::function<uint64_t()> LMAOffset;
|
||||
OutputSectionBase *CurOutSec = nullptr;
|
||||
MemoryRegion *CurMemRegion = nullptr;
|
||||
uintX_t ThreadBssOffset = 0;
|
||||
|
|
Loading…
Reference in New Issue