diff options
| author | George Rimar <grimar@accesssoftek.com> | 2017-02-23 07:57:55 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2017-02-23 07:57:55 +0000 |
| commit | 21467876096fa366f95f2058b4cbbdaa339769de (patch) | |
| tree | 804d7b180037199355215ade062f4bbc7a6be1aa | |
| parent | b7f39b08f4f46551bcabcb2f936f6cc8f41965de (diff) | |
| download | bcm5719-llvm-21467876096fa366f95f2058b4cbbdaa339769de.tar.gz bcm5719-llvm-21467876096fa366f95f2058b4cbbdaa339769de.zip | |
[ELF] - Refactoring of LMA offset handling code. NFC.
Thanks to Rui Ueyama for suggestion.
llvm-svn: 295943
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 11 | ||||
| -rw-r--r-- | lld/ELF/LinkerScript.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 143324dc1dc..eccbb76d4ba 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -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; diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 6893ad628bf..66bf1d6b3e3 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -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; |

