forked from OSchip/llvm-project
parent
c080ff64dc
commit
43ee36040d
|
@ -1147,18 +1147,19 @@ static void removeUnusedSyntheticSections() {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
OutputSectionCommand *Cmd = Script->getCmd(OS);
|
OutputSectionCommand *Cmd = Script->getCmd(OS);
|
||||||
BaseCommand **Empty = nullptr;
|
std::vector<BaseCommand *>::iterator Empty = Cmd->Commands.end();
|
||||||
for (BaseCommand *&B : Cmd->Commands) {
|
for (auto I = Cmd->Commands.begin(), E = Cmd->Commands.end(); I != E; ++I) {
|
||||||
|
BaseCommand *B = *I;
|
||||||
if (auto *ISD = dyn_cast<InputSectionDescription>(B)) {
|
if (auto *ISD = dyn_cast<InputSectionDescription>(B)) {
|
||||||
auto I = std::find(ISD->Sections.begin(), ISD->Sections.end(), SS);
|
auto P = std::find(ISD->Sections.begin(), ISD->Sections.end(), SS);
|
||||||
if (I != ISD->Sections.end())
|
if (P != ISD->Sections.end())
|
||||||
ISD->Sections.erase(I);
|
ISD->Sections.erase(P);
|
||||||
if (ISD->Sections.empty())
|
if (ISD->Sections.empty())
|
||||||
Empty = &B;
|
Empty = I;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Empty)
|
if (Empty != Cmd->Commands.end())
|
||||||
Cmd->Commands.erase(std::vector<BaseCommand *>::iterator(Empty));
|
Cmd->Commands.erase(Empty);
|
||||||
|
|
||||||
// If there are no other sections in the output section, remove it from the
|
// If there are no other sections in the output section, remove it from the
|
||||||
// output.
|
// output.
|
||||||
|
|
Loading…
Reference in New Issue