Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -207,6 +207,19 @@ } template +static typename ELFT::uint dispatchAssignment(SectionsCommand &Cmd, + typename ELFT::uint Dot) { + uint64_t Val = evalExpr(Cmd.Expr, Dot); + if (Cmd.Name == ".") { + Dot = Val; + } else { + auto *D = cast>(Symtab::X->find(Cmd.Name)); + D->Value = Val; + } + return Dot; +} + +template void LinkerScript::assignAddresses( ArrayRef *> Sections) { // Orphan sections are sections present in the input files which @@ -226,22 +239,15 @@ uintX_t ThreadBssOffset = 0; for (SectionsCommand &Cmd : Opt.Commands) { - if (Cmd.Kind == AssignmentKind) { - uint64_t Val = evalExpr(Cmd.Expr, Dot); + if (Cmd.Kind == AssignmentKind) + Dot = dispatchAssignment(Cmd, Dot); - if (Cmd.Name == ".") { - Dot = Val; - } else { - auto *D = cast>(Symtab::X->find(Cmd.Name)); - D->Value = Val; - } + if (Cmd.Kind != SectionKind) continue; - } // Find all the sections with required name. There can be more than // one section with such name, if the alignment, flags or type // attribute differs. - assert(Cmd.Kind == SectionKind); for (OutputSectionBase *Sec : Sections) { if (Sec->getName() != Cmd.Name) continue;