summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJoerg Sonnenberger <joerg@bec.de>2011-03-04 20:03:14 +0000
committerJoerg Sonnenberger <joerg@bec.de>2011-03-04 20:03:14 +0000
commit62f759791a015c1ffaebfb18f42b7d77eee0ebbe (patch)
tree5441fa0afc9f310b2ff7d80ea3661c66a027563a /llvm/lib
parentf8198e431160e7ca713b88dcf90715ae1b03e6ed (diff)
downloadbcm5719-llvm-62f759791a015c1ffaebfb18f42b7d77eee0ebbe.tar.gz
bcm5719-llvm-62f759791a015c1ffaebfb18f42b7d77eee0ebbe.zip
Be nice to Xcore and the XMOS assembler and avoid quoting section names
that contain only letters, digits and the characters "_" and ".". llvm-svn: 127028
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/MCSectionELF.cpp30
1 files changed, 18 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index b908a745b26..dfd77c3fe81 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -40,20 +40,26 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
}
StringRef name = getSectionName();
- 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;
+ 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 << '"';
// Handle the weird solaris syntax if desired.
if (MAI.usesSunStyleELFSectionSwitchSyntax() &&
OpenPOWER on IntegriCloud