[PATCH] D30163: [ELF] - Postpone evaluation of LMA offset.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 22 01:50:31 PST 2017
grimar added inline comments.
================
Comment at: lld/trunk/ELF/LinkerScript.cpp:568
if (Cmd->LMAExpr)
- LMAOffset = Cmd->LMAExpr(Dot) - Dot;
+ CurLMA = {Cmd->LMAExpr, Dot};
OutputSectionBase *Sec = findSection<ELFT>(Cmd->Name, *OutputSections);
----------------
ruiu wrote:
> If you change this to
>
> LMAOffset = [=] { return Cmd->LMAExpr(Dot) - Dot; }
>
> I generally don't like to overuse std::pair because its member names (first and second) sometimes hurts code readability.
That would work if I do something like:
```
if (Cmd->LMAExpr) {
uintX_t D = Dot;
LMAOffset = [=] { return Cmd->LMAExpr(D) - D; };
}
```
Because you can't capture member Dot by value.
Does it look fine for you ?
================
Comment at: lld/trunk/ELF/LinkerScript.h:301
uintX_t Dot;
- uintX_t LMAOffset = 0;
+ std::pair<Expr, uintX_t> CurLMA;
OutputSectionBase *CurOutSec = nullptr;
----------------
ruiu wrote:
> This can be just `Expr LMAOffset`, right?
>
I would use std::function<uint64_t()> then. Expr assumes Dot argument which is unused.
And would complicate the initialization to:
```
LMAOffset = {[=](uint64_t) { return Cmd->LMAExpr(D) - D; }};
```
Repository:
rL LLVM
https://reviews.llvm.org/D30163
More information about the llvm-commits
mailing list