1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Handle strings in section names the same way as gas:

* If the name is a single string, we remove the quotes
* If the name starts without a quote, we include any quotes in the name

llvm-svn: 124127
This commit is contained in:
Rafael Espindola 2011-01-24 18:02:54 +00:00
parent 308677c046
commit ead58a5259
2 changed files with 21 additions and 3 deletions

View File

@ -168,6 +168,12 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
SMLoc FirstLoc = getLexer().getLoc();
unsigned Size = 0;
if (getLexer().is(AsmToken::String)) {
SectionName = getTok().getIdentifier();
Lex();
return false;
}
for (;;) {
StringRef Tmp;
unsigned CurSize;
@ -176,10 +182,15 @@ bool ELFAsmParser::ParseSectionName(StringRef &SectionName) {
if (getLexer().is(AsmToken::Minus)) {
CurSize = 1;
Lex(); // Consume the "-".
} else if (!getParser().ParseIdentifier(Tmp))
CurSize = Tmp.size();
else
} else if (getLexer().is(AsmToken::String)) {
CurSize = getTok().getIdentifier().size() + 2;
Lex();
} else if (getLexer().is(AsmToken::Identifier)) {
CurSize = getTok().getIdentifier().size();
Lex();
} else {
break;
}
Size += CurSize;
SectionName = StringRef(FirstLoc.getPointer(), Size);

View File

@ -101,3 +101,10 @@ bar:
// CHECK-NEXT: ('sh_addralign', 0x00000001)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK-NEXT: ),
// Test that we handle the strings like gas
.section bar-"foo"
.section "foo"
// CHECK: ('sh_name', 0x0000008a) # 'bar-"foo"'
// CHECK: ('sh_name', 0x00000094) # 'foo'