[ELF] - Cleanup of LinkerScript<ELFT>::assignAddresses()

LinkerScript<ELFT>::assignAddresses is becoming larger and looks 
it can be good time for splitting. I expect to can more SectionsCommand's there, 
and dispatching some of them separatelly can help to keep method smaller either.

Differential revision: https://reviews.llvm.org/D22506

llvm-svn: 276300
This commit is contained in:
George Rimar
2016-07-21 16:07:40 +00:00
parent aa76a0cf91
commit 10e576e109
2 changed files with 13 additions and 8 deletions

View File

@@ -276,6 +276,17 @@ LinkerScript<ELFT>::createSections(OutputSectionFactory<ELFT> &Factory) {
return Result;
}
template <class ELFT>
void LinkerScript<ELFT>::dispatchAssignment(SymbolAssignment *Cmd) {
uint64_t Val = evalExpr(Cmd->Expr, Dot);
if (Cmd->Name == ".") {
Dot = Val;
} else {
auto *D = cast<DefinedRegular<ELFT>>(Symtab<ELFT>::X->find(Cmd->Name));
D->Value = Val;
}
}
template <class ELFT>
void LinkerScript<ELFT>::assignAddresses(
ArrayRef<OutputSectionBase<ELFT> *> Sections) {
@@ -297,14 +308,7 @@ void LinkerScript<ELFT>::assignAddresses(
for (const std::unique_ptr<BaseCommand> &Base : Opt.Commands) {
if (auto *Cmd = dyn_cast<SymbolAssignment>(Base.get())) {
uint64_t Val = evalExpr(Cmd->Expr, Dot);
if (Cmd->Name == ".") {
Dot = Val;
} else {
auto *D = cast<DefinedRegular<ELFT>>(Symtab<ELFT>::X->find(Cmd->Name));
D->Value = Val;
}
dispatchAssignment(Cmd);
continue;
}