mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 21:24:00 +00:00
Remove AllowQuotesInName and friends from MCAsmInfo.
Accepting quotes is a property of an assembler, not of an object file. For example, ELF can support any names for sections and symbols, but the gnu assembler only accepts quotes in some contexts and llvm-mc in a few more. LLVM should not produce different symbols based on a guess about which assembler will be reading the code it is printing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194575 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -32,6 +32,29 @@ bool MCSectionELF::ShouldOmitSectionDirective(StringRef Name,
|
||||
return false;
|
||||
}
|
||||
|
||||
static void printName(raw_ostream &OS, StringRef Name) {
|
||||
if (Name.find_first_not_of("0123456789_."
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ") == Name.npos) {
|
||||
OS << Name;
|
||||
return;
|
||||
}
|
||||
OS << '"';
|
||||
for (const char *B = Name.begin(), *E = Name.end(); B < E; ++B) {
|
||||
if (*B == '"') // Unquoted "
|
||||
OS << "\\\"";
|
||||
else if (*B != '\\') // Neither " or backslash
|
||||
OS << *B;
|
||||
else if (B + 1 == E) // Trailing backslash
|
||||
OS << "\\\\";
|
||||
else {
|
||||
OS << B[0] << B[1]; // Quoted character
|
||||
++B;
|
||||
}
|
||||
}
|
||||
OS << '"';
|
||||
}
|
||||
|
||||
void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||
raw_ostream &OS,
|
||||
const MCExpr *Subsection) const {
|
||||
@ -44,27 +67,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||
return;
|
||||
}
|
||||
|
||||
StringRef name = getSectionName();
|
||||
if (name.find_first_not_of("0123456789_."
|
||||
"abcdefghijklmnopqrstuvwxyz"
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ") == name.npos) {
|
||||
OS << "\t.section\t" << name;
|
||||
} else {
|
||||
OS << "\t.section\t\"";
|
||||
for (const char *b = name.begin(), *e = name.end(); b < e; ++b) {
|
||||
if (*b == '"') // Unquoted "
|
||||
OS << "\\\"";
|
||||
else if (*b != '\\') // Neither " or backslash
|
||||
OS << *b;
|
||||
else if (b + 1 == e) // Trailing backslash
|
||||
OS << "\\\\";
|
||||
else {
|
||||
OS << b[0] << b[1]; // Quoted character
|
||||
++b;
|
||||
}
|
||||
}
|
||||
OS << '"';
|
||||
}
|
||||
OS << "\t.section\t";
|
||||
printName(OS, getSectionName());
|
||||
|
||||
// Handle the weird solaris syntax if desired.
|
||||
if (MAI.usesSunStyleELFSectionSwitchSyntax() &&
|
||||
@ -135,8 +139,11 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||
OS << "," << EntrySize;
|
||||
}
|
||||
|
||||
if (Flags & ELF::SHF_GROUP)
|
||||
OS << "," << Group->getName() << ",comdat";
|
||||
if (Flags & ELF::SHF_GROUP) {
|
||||
OS << ",";
|
||||
printName(OS, Group->getName());
|
||||
OS << ",comdat";
|
||||
}
|
||||
OS << '\n';
|
||||
|
||||
if (Subsection)
|
||||
|
Reference in New Issue
Block a user