summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCSectionELF.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-11-13 14:01:59 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-11-13 14:01:59 +0000
commitfdc88137f4882850a3b31b686ca9b63cb2ab6a48 (patch)
tree49c99b1b49ef8beaad90746ba2cfc70e12a8bd04 /llvm/lib/MC/MCSectionELF.cpp
parent156227ac2bcac239f9dfd0a8314b6efcae9021b0 (diff)
downloadbcm5719-llvm-fdc88137f4882850a3b31b686ca9b63cb2ab6a48.tar.gz
bcm5719-llvm-fdc88137f4882850a3b31b686ca9b63cb2ab6a48.zip
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. llvm-svn: 194575
Diffstat (limited to 'llvm/lib/MC/MCSectionELF.cpp')
-rw-r--r--llvm/lib/MC/MCSectionELF.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index ff9c4d351a1..09eb3e78295 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -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)
OpenPOWER on IntegriCloud