forked from OSchip/llvm-project
parent
90573e49c9
commit
bd12e2a0ce
|
@ -434,7 +434,8 @@ template <class ELFT> void LinkerScript<ELFT>::output(InputSection *S) {
|
|||
}
|
||||
|
||||
template <class ELFT> void LinkerScript<ELFT>::flush() {
|
||||
if (!CurOutSec || !AlreadyOutputOS.insert(CurOutSec).second)
|
||||
assert(CurOutSec);
|
||||
if (!AlreadyOutputOS.insert(CurOutSec).second)
|
||||
return;
|
||||
for (InputSection *I : CurOutSec->Sections)
|
||||
output(I);
|
||||
|
@ -446,7 +447,6 @@ template <class ELFT> void LinkerScript<ELFT>::switchTo(OutputSection *Sec) {
|
|||
if (AlreadyOutputOS.count(Sec))
|
||||
return;
|
||||
|
||||
flush();
|
||||
CurOutSec = Sec;
|
||||
|
||||
Dot = alignTo(Dot, CurOutSec->Addralign);
|
||||
|
@ -484,23 +484,19 @@ template <class ELFT> void LinkerScript<ELFT>::process(BaseCommand &Base) {
|
|||
// calculates and assigns the offsets for each section and also
|
||||
// updates the output section size.
|
||||
auto &ICmd = cast<InputSectionDescription>(Base);
|
||||
for (InputSectionBase *ID : ICmd.Sections) {
|
||||
for (InputSectionBase *IB : ICmd.Sections) {
|
||||
// We tentatively added all synthetic sections at the beginning and removed
|
||||
// empty ones afterwards (because there is no way to know whether they were
|
||||
// going be empty or not other than actually running linker scripts.)
|
||||
// We need to ignore remains of empty sections.
|
||||
if (auto *Sec = dyn_cast<SyntheticSection>(ID))
|
||||
if (auto *Sec = dyn_cast<SyntheticSection>(IB))
|
||||
if (Sec->empty())
|
||||
continue;
|
||||
|
||||
auto *IB = static_cast<InputSectionBase *>(ID);
|
||||
if (!IB->Live)
|
||||
continue;
|
||||
switchTo(IB->OutSec);
|
||||
if (auto *I = dyn_cast<InputSection>(IB))
|
||||
output(I);
|
||||
else
|
||||
flush();
|
||||
output(cast<InputSection>(IB));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue