X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FMC%2FMCSectionELF.cpp;h=09eb3e7829582daf1b1749b492a9f87c8c430144;hb=70d641fbecf2ce54fd3578890c94888fad254238;hp=bf1a984a9bf6cf5ed888e2225b70ed3244be56f5;hpb=df39be6cb4eb44011db3d3e86f8fe463f81ce127;p=oota-llvm.git diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp index bf1a984a9bf..09eb3e78295 100644 --- a/lib/MC/MCSectionELF.cpp +++ b/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() && @@ -75,6 +79,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << ",#execinstr"; if (Flags & ELF::SHF_WRITE) OS << ",#write"; + if (Flags & ELF::SHF_EXCLUDE) + OS << ",#exclude"; if (Flags & ELF::SHF_TLS) OS << ",#tls"; OS << '\n'; @@ -84,6 +90,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, OS << ",\""; if (Flags & ELF::SHF_ALLOC) OS << 'a'; + if (Flags & ELF::SHF_EXCLUDE) + OS << 'e'; if (Flags & ELF::SHF_EXECINSTR) OS << 'x'; if (Flags & ELF::SHF_GROUP) @@ -131,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)