diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2011-03-04 20:03:14 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2011-03-04 20:03:14 +0000 |
commit | 89e0f386f3c8bafbbae05d7d32695ce571617397 (patch) | |
tree | 48a913bd301ef70a058a001df5b2b00889afa66d /lib/MC | |
parent | ca8a2aa921ec8966b1f0708d77e4dc0a6f1a32f8 (diff) |
Be nice to Xcore and the XMOS assembler and avoid quoting section names
that contain only letters, digits and the characters "_" and ".".
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCSectionELF.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp index b908a745b2..dfd77c3fe8 100644 --- a/lib/MC/MCSectionELF.cpp +++ b/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() && |