This fixes PR36367 which is about segfault when --emit-relocs is
used together with .eh_frame sections which happens because
of reordering of regular and .rel[a] sections.
Path changes loop that iterates over input sections to create
relocation target sections first.
It turns out that we can do this with just one loop.
The requirement that we have is that relocated sections are added before the corresponding section. We can implement that with
+ if ((IS->Type == SHT_REL || IS->Type == SHT_RELA) && !isa<SyntheticSection>(IS))
+ if (auto *Rel = cast<InputSection>(IS)->getRelocatedSection())
+ if (auto *RelIS = dyn_cast_or_null<InputSectionBase>(Rel->Parent))
+ Add(RelIS);
+ Add(IS);