this is (unfortunately) several changes mixed together:

1. Spell SectionFlags::Writeable as "Writable".
2. Add predicates for deriving SectionFlags from SectionKinds.
3. Sink ELF-specific getSectionPrefixForUniqueGlobal impl into
   ELFTargetAsmInfo.
4. Fix SectionFlagsForGlobal to know that BSS/ThreadBSS has the
   BSS bit set (the real fix for PR4619).
5. Fix isSuitableForBSS to not put globals with explicit sections
   set in BSS (which was the reason #4 wasn't fixed earlier).
6. Remove my previous hack for PR4619.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77085 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/ELFTargetAsmInfo.cpp b/lib/Target/ELFTargetAsmInfo.cpp
index 9dd339e..ea07836 100644
--- a/lib/Target/ELFTargetAsmInfo.cpp
+++ b/lib/Target/ELFTargetAsmInfo.cpp
@@ -29,20 +29,20 @@
   : TargetAsmInfo(TM) {
 
   BSSSection_  = getUnnamedSection("\t.bss",
-                                   SectionFlags::Writeable | SectionFlags::BSS);
+                                   SectionFlags::Writable | SectionFlags::BSS);
   ReadOnlySection = getNamedSection("\t.rodata", SectionFlags::None);
   TLSDataSection = getNamedSection("\t.tdata",
-                                   SectionFlags::Writeable | SectionFlags::TLS);
+                                   SectionFlags::Writable | SectionFlags::TLS);
   TLSBSSSection = getNamedSection("\t.tbss",
-                SectionFlags::Writeable | SectionFlags::TLS | SectionFlags::BSS);
+                SectionFlags::Writable | SectionFlags::TLS | SectionFlags::BSS);
 
-  DataRelSection = getNamedSection("\t.data.rel", SectionFlags::Writeable);
+  DataRelSection = getNamedSection("\t.data.rel", SectionFlags::Writable);
   DataRelLocalSection = getNamedSection("\t.data.rel.local",
-                                        SectionFlags::Writeable);
+                                        SectionFlags::Writable);
   DataRelROSection = getNamedSection("\t.data.rel.ro",
-                                     SectionFlags::Writeable);
+                                     SectionFlags::Writable);
   DataRelROLocalSection = getNamedSection("\t.data.rel.ro.local",
-                                          SectionFlags::Writeable);
+                                          SectionFlags::Writable);
 }
 
 
@@ -145,6 +145,28 @@
 }
 
 
+
+const char *
+ELFTargetAsmInfo::getSectionPrefixForUniqueGlobal(SectionKind::Kind Kind) const{
+  switch (Kind) {
+  default: llvm_unreachable("Unknown section kind");
+  case SectionKind::Text:             return ".gnu.linkonce.t.";
+  case SectionKind::Data:             return ".gnu.linkonce.d.";
+  case SectionKind::DataRel:          return ".gnu.linkonce.d.rel.";
+  case SectionKind::DataRelLocal:     return ".gnu.linkonce.d.rel.local.";
+  case SectionKind::DataRelRO:        return ".gnu.linkonce.d.rel.ro.";
+  case SectionKind::DataRelROLocal:   return ".gnu.linkonce.d.rel.ro.local.";
+  case SectionKind::BSS:              return ".gnu.linkonce.b.";
+  case SectionKind::ROData:
+  case SectionKind::RODataMergeConst:
+  case SectionKind::RODataMergeStr:   return ".gnu.linkonce.r.";
+  case SectionKind::ThreadData:       return ".gnu.linkonce.td.";
+  case SectionKind::ThreadBSS:        return ".gnu.linkonce.tb.";
+  }
+}
+
+
+
 const Section*
 ELFTargetAsmInfo::MergeableStringSection(const GlobalVariable *GV) const {
   const TargetData *TD = TM.getTargetData();
@@ -177,7 +199,7 @@
     Flags += 'a';
   if (flags & SectionFlags::Code)
     Flags += 'x';
-  if (flags & SectionFlags::Writeable)
+  if (flags & SectionFlags::Writable)
     Flags += 'w';
   if (flags & SectionFlags::Mergeable)
     Flags += 'M';