@@ -405,22 +405,21 @@ void ScriptParser::readGroup() {
405
405
}
406
406
407
407
void ScriptParser::readInclude () {
408
- StringRef tok = unquote (next ());
409
-
410
- if (!seen.insert (tok).second ) {
408
+ StringRef name = readName ();
409
+ if (!seen.insert (name).second ) {
411
410
setError (" there is a cycle in linker script INCLUDEs" );
412
411
return ;
413
412
}
414
413
415
- if (std::optional<std::string> path = searchScript (tok )) {
414
+ if (std::optional<std::string> path = searchScript (name )) {
416
415
if (std::optional<MemoryBufferRef> mb = readFile (*path)) {
417
416
buffers.push_back (curBuf);
418
417
curBuf = Buffer (*mb);
419
418
mbs.push_back (*mb);
420
419
}
421
420
return ;
422
421
}
423
- setError (" cannot find linker script " + tok );
422
+ setError (" cannot find linker script " + name );
424
423
}
425
424
426
425
void ScriptParser::readInput () {
@@ -488,14 +487,14 @@ static std::pair<ELFKind, uint16_t> parseBfdName(StringRef s) {
488
487
void ScriptParser::readOutputFormat () {
489
488
expect (" (" );
490
489
491
- StringRef s = unquote ( next () );
490
+ StringRef s = readName ( );
492
491
if (!consume (" )" )) {
493
492
expect (" ," );
494
- StringRef tmp = unquote ( next () );
493
+ StringRef tmp = readName ( );
495
494
if (config->optEB )
496
495
s = tmp;
497
496
expect (" ," );
498
- tmp = unquote ( next () );
497
+ tmp = readName ( );
499
498
if (config->optEL )
500
499
s = tmp;
501
500
consume (" )" );
@@ -548,7 +547,7 @@ void ScriptParser::readPhdrs() {
548
547
549
548
void ScriptParser::readRegionAlias () {
550
549
expect (" (" );
551
- StringRef alias = unquote ( next () );
550
+ StringRef alias = readName ( );
552
551
expect (" ," );
553
552
StringRef name = next ();
554
553
expect (" )" );
@@ -562,9 +561,9 @@ void ScriptParser::readRegionAlias() {
562
561
563
562
void ScriptParser::readSearchDir () {
564
563
expect (" (" );
565
- StringRef tok = next ();
564
+ StringRef name = readName ();
566
565
if (!config->nostdlib )
567
- config->searchPaths .push_back (unquote (tok) );
566
+ config->searchPaths .push_back (name );
568
567
expect (" )" );
569
568
}
570
569
@@ -680,7 +679,7 @@ void ScriptParser::readTarget() {
680
679
// for --format. We recognize only /^elf/ and "binary" in the linker
681
680
// script as well.
682
681
expect (" (" );
683
- StringRef tok = unquote ( next () );
682
+ StringRef tok = readName ( );
684
683
expect (" )" );
685
684
686
685
if (tok.starts_with (" elf" ))
@@ -766,7 +765,7 @@ SmallVector<SectionPattern, 0> ScriptParser::readInputSectionsList() {
766
765
setError (" section pattern is expected" );
767
766
break ;
768
767
}
769
- SectionMatcher.addPattern (unquote ( next () ));
768
+ SectionMatcher.addPattern (readName ( ));
770
769
}
771
770
772
771
if (!SectionMatcher.empty ())
@@ -860,7 +859,7 @@ Expr ScriptParser::readAssert() {
860
859
expect (" (" );
861
860
Expr e = readExpr ();
862
861
expect (" ," );
863
- StringRef msg = unquote ( next () );
862
+ StringRef msg = readName ( );
864
863
expect (" )" );
865
864
866
865
return [=] {
@@ -1392,11 +1391,11 @@ static std::optional<uint64_t> parseFlag(StringRef tok) {
1392
1391
// Example: SHF_EXECINSTR & !SHF_WRITE means with flag SHF_EXECINSTR and
1393
1392
// without flag SHF_WRITE.
1394
1393
std::pair<uint64_t , uint64_t > ScriptParser::readInputSectionFlags () {
1395
- uint64_t withFlags = 0 ;
1396
- uint64_t withoutFlags = 0 ;
1397
- expect (" (" );
1398
- while (!errorCount ()) {
1399
- StringRef tok = unquote ( next () );
1394
+ uint64_t withFlags = 0 ;
1395
+ uint64_t withoutFlags = 0 ;
1396
+ expect (" (" );
1397
+ while (!errorCount ()) {
1398
+ StringRef tok = readName ( );
1400
1399
bool without = tok.consume_front (" !" );
1401
1400
if (std::optional<uint64_t > flag = parseFlag (tok)) {
1402
1401
if (without)
0 commit comments