diff options
author | Joerg Sonnenberger <joerg@bec.de> | 2011-03-03 22:31:08 +0000 |
---|---|---|
committer | Joerg Sonnenberger <joerg@bec.de> | 2011-03-03 22:31:08 +0000 |
commit | 852ab890b53887312e05c410670f8c678d1bfdbe (patch) | |
tree | 102d8e670615493a3aa3cb4de9b34fc031a62e49 /llvm/lib/MC/MCSectionELF.cpp | |
parent | 63b3e76370d77e5998b62858c2bfa86c5385e762 (diff) | |
download | bcm5719-llvm-852ab890b53887312e05c410670f8c678d1bfdbe.tar.gz bcm5719-llvm-852ab890b53887312e05c410670f8c678d1bfdbe.zip |
Bug#9033: For the ELF assembler output, always quote the section name.
llvm-svn: 126963
Diffstat (limited to 'llvm/lib/MC/MCSectionELF.cpp')
-rw-r--r-- | llvm/lib/MC/MCSectionELF.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp index d32aea144e6..b908a745b26 100644 --- a/llvm/lib/MC/MCSectionELF.cpp +++ b/llvm/lib/MC/MCSectionELF.cpp @@ -39,8 +39,22 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, return; } - OS << "\t.section\t" << getSectionName(); - + 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; + } + } + OS << '"'; + // Handle the weird solaris syntax if desired. if (MAI.usesSunStyleELFSectionSwitchSyntax() && !(Flags & ELF::SHF_MERGE)) { |