@@ -497,14 +497,9 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
497
497
SmallVector<InputSectionBase *, 0 > ret;
498
498
DenseSet<InputSectionBase *> spills;
499
499
500
- // Returns whether an input section was already assigned to an earlier input
501
- // section description in this output section or section class.
502
- const auto alreadyAssignedToOutCmd =
503
- [&outCmd](InputSectionBase *sec) { return sec->parent == &outCmd; };
504
-
505
500
// Returns whether an input section's flags match the input section
506
501
// description's specifiers.
507
- const auto flagsMatch = [cmd](InputSectionBase *sec) {
502
+ auto flagsMatch = [cmd](InputSectionBase *sec) {
508
503
return (sec->flags & cmd->withFlags ) == cmd->withFlags &&
509
504
(sec->flags & cmd->withoutFlags ) == 0 ;
510
505
};
@@ -547,7 +542,7 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
547
542
continue ;
548
543
549
544
if (!cmd->matchesFile (sec->file ) || pat.excludesFile (sec->file ) ||
550
- alreadyAssignedToOutCmd ( sec) || !flagsMatch (sec))
545
+ sec-> parent == &outCmd || !flagsMatch (sec))
551
546
continue ;
552
547
553
548
if (sec->parent ) {
@@ -597,33 +592,35 @@ LinkerScript::computeInputSections(const InputSectionDescription *cmd,
597
592
} else {
598
593
SectionClassDesc *scd = script->sectionClasses .lookup (cmd->classRef );
599
594
if (!scd) {
600
- error (" undefined section class '" + cmd->classRef + " '" );
595
+ errorOrWarn (" undefined section class '" + cmd->classRef + " '" );
601
596
return ret;
602
597
}
603
598
if (!scd->sc .assigned ) {
604
- error (" section class '" + cmd->classRef + " ' referenced by '" +
605
- outCmd.name + " ' before class definition" );
599
+ errorOrWarn (" section class '" + cmd->classRef + " ' referenced by '" +
600
+ outCmd.name + " ' before class definition" );
606
601
return ret;
607
602
}
608
603
609
604
for (InputSectionDescription *isd : scd->sc .commands ) {
610
605
for (InputSectionBase *sec : isd->sectionBases ) {
611
- if (alreadyAssignedToOutCmd ( sec) || !flagsMatch (sec))
606
+ if (sec-> parent == &outCmd || !flagsMatch (sec))
612
607
continue ;
613
608
bool isSpill = sec->parent && isa<OutputSection>(sec->parent );
614
- if (!sec->parent || (isSpill && outCmd.name == " /DISCARD/" ))
615
- error (" section '" + sec->name + " ' cannot spill from/to /DISCARD/" );
609
+ if (!sec->parent || (isSpill && outCmd.name == " /DISCARD/" )) {
610
+ errorOrWarn (" section '" + sec->name + " ' cannot spill from/to /DISCARD/" );
611
+ continue ;
612
+ }
616
613
if (isSpill)
617
614
spills.insert (sec);
618
615
ret.push_back (sec);
619
616
}
620
617
}
621
618
}
622
619
623
- // The flag --enable-non-contiguous-regions may cause sections to match an
624
- // InputSectionDescription in more than one OutputSection. Matches after the
625
- // first were collected in the spills set, so replace these with potential
626
- // spill sections.
620
+ // The flag --enable-non-contiguous-regions or the section CLASS syntax may
621
+ // cause sections to match an InputSectionDescription in more than one
622
+ // OutputSection. Matches after the first were collected in the spills set, so
623
+ // replace these with potential spill sections.
627
624
if (!spills.empty ()) {
628
625
for (InputSectionBase *&sec : ret) {
629
626
if (!spills.contains (sec))
@@ -790,8 +787,9 @@ void LinkerScript::processSectionCommands() {
790
787
for (InputSectionBase *isec : isd->sectionBases )
791
788
if (isa<PotentialSpillSection>(isec) ||
792
789
potentialSpillLists.contains (isec))
793
- error (" section '" + isec->name +
794
- " ' cannot spill from/to INSERT section '" + os->name + " '" );
790
+ errorOrWarn (" section '" + isec->name +
791
+ " ' cannot spill from/to INSERT section '" + os->name +
792
+ " '" );
795
793
}
796
794
}
797
795
}
@@ -809,8 +807,9 @@ void LinkerScript::processSectionCommands() {
809
807
for (InputSectionDescription *isd : sc->sc .commands )
810
808
for (InputSectionBase *sec : isd->sectionBases )
811
809
if (sec->parent && isa<SectionClass>(sec->parent ))
812
- error (" section '" + sec->name + " ' assigned to class '" +
813
- sec->parent ->name + " ' but unreferenced by any output section" );
810
+ errorOrWarn (" section '" + sec->name + " ' assigned to class '" +
811
+ sec->parent ->name +
812
+ " ' but unreferenced by any output section" );
814
813
}
815
814
816
815
void LinkerScript::processSymbolAssignments () {
0 commit comments