@@ -93,12 +93,12 @@ class ScriptParser final : ScriptLexer {
93
93
void readSectionAddressType (OutputSection *cmd);
94
94
OutputSection *readOverlaySectionDescription ();
95
95
OutputSection *readOutputSectionDescription (StringRef outSec);
96
- std::vector <SectionCommand *> readOverlay ();
96
+ SmallVector <SectionCommand *, 0 > readOverlay ();
97
97
SmallVector<StringRef, 0 > readOutputSectionPhdrs ();
98
98
std::pair<uint64_t , uint64_t > readInputSectionFlags ();
99
99
InputSectionDescription *readInputSectionDescription (StringRef tok);
100
100
StringMatcher readFilePatterns ();
101
- std::vector <SectionPattern> readInputSectionsList ();
101
+ SmallVector <SectionPattern, 0 > readInputSectionsList ();
102
102
InputSectionDescription *readInputSectionRules (StringRef filePattern,
103
103
uint64_t withFlags,
104
104
uint64_t withoutFlags);
@@ -125,11 +125,11 @@ class ScriptParser final : ScriptLexer {
125
125
Expr readParenExpr ();
126
126
127
127
// For parsing version script.
128
- std::vector <SymbolVersion> readVersionExtern ();
128
+ SmallVector <SymbolVersion, 0 > readVersionExtern ();
129
129
void readAnonymousDeclaration ();
130
130
void readVersionDeclaration (StringRef verStr);
131
131
132
- std::pair<std::vector <SymbolVersion>, std::vector <SymbolVersion>>
132
+ std::pair<SmallVector <SymbolVersion, 0 >, SmallVector <SymbolVersion, 0 >>
133
133
readSymbols ();
134
134
135
135
// True if a script being read is in the --sysroot directory.
@@ -181,8 +181,8 @@ static ExprValue bitOr(ExprValue a, ExprValue b) {
181
181
182
182
void ScriptParser::readDynamicList () {
183
183
expect (" {" );
184
- std::vector <SymbolVersion> locals;
185
- std::vector <SymbolVersion> globals;
184
+ SmallVector <SymbolVersion, 0 > locals;
185
+ SmallVector <SymbolVersion, 0 > globals;
186
186
std::tie (locals, globals) = readSymbols ();
187
187
expect (" ;" );
188
188
@@ -519,7 +519,7 @@ void ScriptParser::readSearchDir() {
519
519
// sections that use the same virtual memory range and normally would trigger
520
520
// linker's sections sanity check failures.
521
521
// https://sourceware.org/binutils/docs/ld/Overlay-Description.html#Overlay-Description
522
- std::vector <SectionCommand *> ScriptParser::readOverlay () {
522
+ SmallVector <SectionCommand *, 0 > ScriptParser::readOverlay () {
523
523
// VA and LMA expressions are optional, though for simplicity of
524
524
// implementation we assume they are not. That is what OVERLAY was designed
525
525
// for first of all: to allow sections with overlapping VAs at different LMAs.
@@ -529,7 +529,7 @@ std::vector<SectionCommand *> ScriptParser::readOverlay() {
529
529
Expr lmaExpr = readParenExpr ();
530
530
expect (" {" );
531
531
532
- std::vector <SectionCommand *> v;
532
+ SmallVector <SectionCommand *, 0 > v;
533
533
OutputSection *prev = nullptr ;
534
534
while (!errorCount () && !consume (" }" )) {
535
535
// VA is the same for all sections. The LMAs are consecutive in memory
@@ -566,7 +566,7 @@ void ScriptParser::readOverwriteSections() {
566
566
567
567
void ScriptParser::readSections () {
568
568
expect (" {" );
569
- std::vector <SectionCommand *> v;
569
+ SmallVector <SectionCommand *, 0 > v;
570
570
while (!errorCount () && !consume (" }" )) {
571
571
StringRef tok = next ();
572
572
if (tok == " OVERLAY" ) {
@@ -672,8 +672,8 @@ SortSectionPolicy ScriptParser::readSortKind() {
672
672
// is parsed as ".foo", ".bar" with "a.o", and ".baz" with "b.o".
673
673
// The semantics of that is section .foo in any file, section .bar in
674
674
// any file but a.o, and section .baz in any file but b.o.
675
- std::vector <SectionPattern> ScriptParser::readInputSectionsList () {
676
- std::vector <SectionPattern> ret;
675
+ SmallVector <SectionPattern, 0 > ScriptParser::readInputSectionsList () {
676
+ SmallVector <SectionPattern, 0 > ret;
677
677
while (!errorCount () && peek () != " )" ) {
678
678
StringMatcher excludeFilePat;
679
679
if (consume (" EXCLUDE_FILE" )) {
@@ -718,7 +718,7 @@ ScriptParser::readInputSectionRules(StringRef filePattern, uint64_t withFlags,
718
718
while (!errorCount () && !consume (" )" )) {
719
719
SortSectionPolicy outer = readSortKind ();
720
720
SortSectionPolicy inner = SortSectionPolicy::Default;
721
- std::vector <SectionPattern> v;
721
+ SmallVector <SectionPattern, 0 > v;
722
722
if (outer != SortSectionPolicy::Default) {
723
723
expect (" (" );
724
724
inner = readSortKind ();
@@ -1494,8 +1494,8 @@ unsigned ScriptParser::readPhdrType() {
1494
1494
1495
1495
// Reads an anonymous version declaration.
1496
1496
void ScriptParser::readAnonymousDeclaration () {
1497
- std::vector <SymbolVersion> locals;
1498
- std::vector <SymbolVersion> globals;
1497
+ SmallVector <SymbolVersion, 0 > locals;
1498
+ SmallVector <SymbolVersion, 0 > globals;
1499
1499
std::tie (locals, globals) = readSymbols ();
1500
1500
for (const SymbolVersion &pat : locals)
1501
1501
config->versionDefinitions [VER_NDX_LOCAL].localPatterns .push_back (pat);
@@ -1509,8 +1509,8 @@ void ScriptParser::readAnonymousDeclaration() {
1509
1509
// e.g. "VerStr { global: foo; bar; local: *; };".
1510
1510
void ScriptParser::readVersionDeclaration (StringRef verStr) {
1511
1511
// Read a symbol list.
1512
- std::vector <SymbolVersion> locals;
1513
- std::vector <SymbolVersion> globals;
1512
+ SmallVector <SymbolVersion, 0 > locals;
1513
+ SmallVector <SymbolVersion, 0 > globals;
1514
1514
std::tie (locals, globals) = readSymbols ();
1515
1515
1516
1516
// Create a new version definition and add that to the global symbols.
@@ -1535,11 +1535,11 @@ bool elf::hasWildcard(StringRef s) {
1535
1535
}
1536
1536
1537
1537
// Reads a list of symbols, e.g. "{ global: foo; bar; local: *; };".
1538
- std::pair<std::vector <SymbolVersion>, std::vector <SymbolVersion>>
1538
+ std::pair<SmallVector <SymbolVersion, 0 >, SmallVector <SymbolVersion, 0 >>
1539
1539
ScriptParser::readSymbols () {
1540
- std::vector <SymbolVersion> locals;
1541
- std::vector <SymbolVersion> globals;
1542
- std::vector <SymbolVersion> *v = &globals;
1540
+ SmallVector <SymbolVersion, 0 > locals;
1541
+ SmallVector <SymbolVersion, 0 > globals;
1542
+ SmallVector <SymbolVersion, 0 > *v = &globals;
1543
1543
1544
1544
while (!errorCount ()) {
1545
1545
if (consume (" }" ))
@@ -1554,7 +1554,7 @@ ScriptParser::readSymbols() {
1554
1554
}
1555
1555
1556
1556
if (consume (" extern" )) {
1557
- std::vector <SymbolVersion> ext = readVersionExtern ();
1557
+ SmallVector <SymbolVersion, 0 > ext = readVersionExtern ();
1558
1558
v->insert (v->end (), ext.begin (), ext.end ());
1559
1559
} else {
1560
1560
StringRef tok = next ();
@@ -1570,14 +1570,14 @@ ScriptParser::readSymbols() {
1570
1570
//
1571
1571
// The last semicolon is optional. E.g. this is OK:
1572
1572
// "extern "C++" { ns::*; "f(int, double)" };"
1573
- std::vector <SymbolVersion> ScriptParser::readVersionExtern () {
1573
+ SmallVector <SymbolVersion, 0 > ScriptParser::readVersionExtern () {
1574
1574
StringRef tok = next ();
1575
1575
bool isCXX = tok == " \" C++\" " ;
1576
1576
if (!isCXX && tok != " \" C\" " )
1577
1577
setError (" Unknown language" );
1578
1578
expect (" {" );
1579
1579
1580
- std::vector <SymbolVersion> ret;
1580
+ SmallVector <SymbolVersion, 0 > ret;
1581
1581
while (!errorCount () && peek () != " }" ) {
1582
1582
StringRef tok = next ();
1583
1583
ret.push_back (
0 commit comments