Move broken HasCommonSymbols to ELFWriter.cpp.
authorRafael Espindola <rafael.espindola@gmail.com>
Mon, 14 Feb 2011 16:51:08 +0000 (16:51 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Mon, 14 Feb 2011 16:51:08 +0000 (16:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@125490 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCSectionELF.h
lib/CodeGen/ELFWriter.cpp
lib/MC/MCSectionELF.cpp

index 64b5b941ef2fcac8f2f4422a6f0ccfd5a0c26dd3..c82de71282028d7eeeb43c575e15b98726590cc9 100644 (file)
@@ -55,11 +55,6 @@ public:
   /// should be printed before the section name
   bool ShouldOmitSectionDirective(StringRef Name, const MCAsmInfo &MAI) const;
 
-  /// HasCommonSymbols - True if this section holds common symbols, this is
-  /// indicated on the ELF object file by a symbol with SHN_COMMON section
-  /// header index.
-  bool HasCommonSymbols() const;
-
   StringRef getSectionName() const { return SectionName; }
   unsigned getType() const { return Type; }
   unsigned getFlags() const { return Flags; }
index 2da62449320df0e84b8ced4b289054ea73a603cb..0fd1e8e83bd7a772cc8a3ae6777b1fae04708f57 100644 (file)
@@ -328,6 +328,18 @@ void ELFWriter::AddToSymbolList(ELFSym *GblSym) {
   }
 }
 
+/// HasCommonSymbols - True if this section holds common symbols, this is
+/// indicated on the ELF object file by a symbol with SHN_COMMON section
+/// header index.
+static bool HasCommonSymbols(const MCSectionELF &S) {
+  // FIXME: this is wrong, a common symbol can be in .data for example.
+  if (StringRef(S.getSectionName()).startswith(".gnu.linkonce."))
+    return true;
+
+  return false;
+}
+
+
 // EmitGlobal - Choose the right section for global and emit it
 void ELFWriter::EmitGlobal(const GlobalValue *GV) {
 
@@ -364,7 +376,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
     unsigned Size = TD->getTypeAllocSize(GVar->getInitializer()->getType());
     GblSym->Size = Size;
 
-    if (S->HasCommonSymbols()) { // Symbol must go to a common section
+    if (HasCommonSymbols(*S)) { // Symbol must go to a common section
       GblSym->SectionIdx = ELF::SHN_COMMON;
 
       // A new linkonce section is created for each global in the
index da54106a19f0997547fc2a20e65b2a5021722181..56138cbc304bf1b222084bf3d970559877fe7d34 100644 (file)
@@ -115,17 +115,6 @@ bool MCSectionELF::isVirtualSection() const {
   return getType() == ELF::SHT_NOBITS;
 }
 
-// HasCommonSymbols - True if this section holds common symbols, this is
-// indicated on the ELF object file by a symbol with SHN_COMMON section 
-// header index.
-bool MCSectionELF::HasCommonSymbols() const {
-  
-  if (StringRef(SectionName).startswith(".gnu.linkonce."))
-    return true;
-
-  return false;
-}
-
 unsigned MCSectionELF::DetermineEntrySize(SectionKind Kind) {
   if (Kind.isMergeable1ByteCString()) return 1;
   if (Kind.isMergeable2ByteCString()) return 2;