[llvm-commits] [llvm] r118805 - in /llvm/trunk: include/llvm/MC/MCContext.h include/llvm/MC/MCSectionELF.h include/llvm/Support/ELF.h lib/MC/ELFObjectWriter.cpp lib/MC/MCContext.cpp lib/MC/MCParser/ELFAsmParser.cpp test/MC/ELF/comdat.s test/MC/ELF/section.s

Rafael Espindola rafael.espindola at gmail.com
Thu Nov 11 10:13:52 PST 2010


Author: rafael
Date: Thu Nov 11 12:13:52 2010
New Revision: 118805

URL: http://llvm.org/viewvc/llvm-project?rev=118805&view=rev
Log:
Initial comdat implementation.

Added:
    llvm/trunk/test/MC/ELF/comdat.s
Modified:
    llvm/trunk/include/llvm/MC/MCContext.h
    llvm/trunk/include/llvm/MC/MCSectionELF.h
    llvm/trunk/include/llvm/Support/ELF.h
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/lib/MC/MCContext.cpp
    llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
    llvm/trunk/test/MC/ELF/section.s

Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=118805&r1=118804&r2=118805&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Thu Nov 11 12:13:52 2010
@@ -138,10 +138,15 @@
                                           SectionKind K) {
       return getMachOSection(Segment, Section, TypeAndAttributes, 0, K);
     }
-    
+
+    const MCSectionELF *getELFSection(StringRef Section, unsigned Type,
+                                      unsigned Flags, SectionKind Kind);
+
     const MCSectionELF *getELFSection(StringRef Section, unsigned Type,
                                       unsigned Flags, SectionKind Kind,
-                                      unsigned EntrySize = 0);
+                                      unsigned EntrySize, StringRef Group);
+
+    const MCSectionELF *CreateELFGroupSection();
 
     const MCSection *getCOFFSection(StringRef Section, unsigned Characteristics,
                                     int Selection, SectionKind Kind);

Modified: llvm/trunk/include/llvm/MC/MCSectionELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSectionELF.h?rev=118805&r1=118804&r2=118805&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSectionELF.h (original)
+++ llvm/trunk/include/llvm/MC/MCSectionELF.h Thu Nov 11 12:13:52 2010
@@ -18,6 +18,8 @@
 
 namespace llvm {
 
+class MCSymbol;
+
 /// MCSectionELF - This represents a section on linux, lots of unix variants
 /// and some bare metal systems.
 class MCSectionELF : public MCSection {
@@ -37,12 +39,14 @@
   /// section does not contain fixed-sized entries 'EntrySize' will be 0.
   unsigned EntrySize;
 
+  const MCSymbol *Group;
+
 private:
   friend class MCContext;
   MCSectionELF(StringRef Section, unsigned type, unsigned flags,
-               SectionKind K, unsigned entrySize)
+               SectionKind K, unsigned entrySize, const MCSymbol *group)
     : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags),
-      EntrySize(entrySize) {}
+      EntrySize(entrySize), Group(group) {}
   ~MCSectionELF();
 public:
 
@@ -179,6 +183,7 @@
   unsigned getType() const { return Type; }
   unsigned getFlags() const { return Flags; }
   unsigned getEntrySize() const { return EntrySize; }
+  const MCSymbol *getGroup() const { return Group; }
 
   void PrintSwitchToSection(const MCAsmInfo &MAI,
                             raw_ostream &OS) const;

Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=118805&r1=118804&r2=118805&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Thu Nov 11 12:13:52 2010
@@ -348,6 +348,13 @@
   SHF_MASKPROC  = 0xf0000000 // Bits indicating processor-specific flags.
 };
 
+// Section Group Flags
+enum {
+  GRP_COMDAT = 0x1,
+  GRP_MASKOS = 0x0ff00000,
+  GRP_MASKPROC = 0xf0000000
+};
+
 // Symbol table entries for ELF32.
 struct Elf32_Sym {
   Elf32_Word    st_name;  // Symbol name (index into string table)

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=118805&r1=118804&r2=118805&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Nov 11 12:13:52 2010
@@ -326,6 +326,11 @@
     void CreateMetadataSections(MCAssembler &Asm, MCAsmLayout &Layout,
                                 const SectionIndexMapTy &SectionIndexMap);
 
+    // Map from a group section to the signature symbol
+    typedef DenseMap<const MCSectionELF*, const MCSymbol*> GroupMapTy;
+    void CreateGroupSections(MCAssembler &Asm, MCAsmLayout &Layout,
+                             GroupMapTy &GroupMap);
+
     void ExecutePostLayoutBinding(MCAssembler &Asm);
 
     void WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags,
@@ -344,6 +349,7 @@
     void WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout);
     void WriteSection(MCAssembler &Asm,
                       const SectionIndexMapTy &SectionIndexMap,
+                      uint32_t GroupSymbolIndex,
                       uint64_t Offset, uint64_t Size, uint64_t Alignment,
                       const MCSectionELF &Section);
   };
@@ -939,6 +945,17 @@
          ie = Asm.end(); it != ie; ++it) {
     const MCSectionELF &Section =
       static_cast<const MCSectionELF &>(it->getSection());
+    if (Section.getType() != ELF::SHT_GROUP)
+      continue;
+    SectionIndexMap[&Section] = Index++;
+  }
+
+  for (MCAssembler::iterator it = Asm.begin(),
+         ie = Asm.end(); it != ie; ++it) {
+    const MCSectionELF &Section =
+      static_cast<const MCSectionELF &>(it->getSection());
+    if (Section.getType() == ELF::SHT_GROUP)
+      continue;
     SectionIndexMap[&Section] = Index++;
   }
 }
@@ -1062,7 +1079,7 @@
     RelaSection = Ctx.getELFSection(RelaSectionName, HasRelocationAddend ?
                                     ELF::SHT_RELA : ELF::SHT_REL, 0,
                                     SectionKind::getReadOnly(),
-                                    EntrySize);
+                                    EntrySize, "");
 
     MCSectionData &RelaSD = Asm.getOrCreateSectionData(*RelaSection);
     RelaSD.setAlignment(Is64Bit ? 8 : 4);
@@ -1148,7 +1165,7 @@
   const MCSectionELF *SymtabSection =
     Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0,
                       SectionKind::getReadOnly(),
-                      EntrySize);
+                      EntrySize, "");
   MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection);
   SymtabSD.setAlignment(Is64Bit ? 8 : 4);
   SymbolTableIndex = Asm.size();
@@ -1158,7 +1175,7 @@
   if (NeedsSymtabShndx) {
     const MCSectionELF *SymtabShndxSection =
       Ctx.getELFSection(".symtab_shndx", ELF::SHT_SYMTAB_SHNDX, 0,
-                        SectionKind::getReadOnly(), 4);
+                        SectionKind::getReadOnly(), 4, "");
     SymtabShndxSD = &Asm.getOrCreateSectionData(*SymtabShndxSection);
     SymtabShndxSD->setAlignment(4);
   }
@@ -1195,18 +1212,25 @@
   uint64_t Index = 1;
   F->getContents() += '\x00';
 
+  StringMap<uint64_t> SecStringMap;
   for (MCAssembler::const_iterator it = Asm.begin(),
          ie = Asm.end(); it != ie; ++it) {
     const MCSectionELF &Section =
       static_cast<const MCSectionELF&>(it->getSection());
     // FIXME: We could merge suffixes like in .text and .rela.text.
 
+    StringRef Name = Section.getSectionName();
+    if (SecStringMap.count(Name)) {
+      SectionStringTableIndex[&Section] =  SecStringMap[Name];
+      continue;
+    }
     // Remember the index into the string table so we can write it
     // into the sh_name field of the section header table.
-    SectionStringTableIndex[&it->getSection()] = Index;
+    SectionStringTableIndex[&Section] = Index;
+    SecStringMap[Name] = Index;
 
-    Index += Section.getSectionName().size() + 1;
-    F->getContents() += Section.getSectionName();
+    Index += Name.size() + 1;
+    F->getContents() += Name;
     F->getContents() += '\x00';
   }
 
@@ -1247,8 +1271,59 @@
   return !SectionB && BaseSection == SectionA;
 }
 
+void ELFObjectWriterImpl::CreateGroupSections(MCAssembler &Asm,
+                                              MCAsmLayout &Layout,
+                                              GroupMapTy &GroupMap) {
+  typedef DenseMap<const MCSymbol*, const MCSectionELF*> RevGroupMapTy;
+  // Build the groups
+  RevGroupMapTy Groups;
+  for (MCAssembler::const_iterator it = Asm.begin(), ie = Asm.end();
+       it != ie; ++it) {
+    const MCSectionELF &Section =
+      static_cast<const MCSectionELF&>(it->getSection());
+    if (!(Section.getFlags() & MCSectionELF::SHF_GROUP))
+      continue;
+
+    const MCSymbol *SignatureSymbol = Section.getGroup();
+    Asm.getOrCreateSymbolData(*SignatureSymbol);
+    const MCSectionELF *&Group = Groups[SignatureSymbol];
+    if (!Group) {
+      Group = Asm.getContext().CreateELFGroupSection();
+      MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
+      Data.setAlignment(4);
+      MCDataFragment *F = new MCDataFragment(&Data);
+      String32(*F, ELF::GRP_COMDAT);
+    }
+    GroupMap[Group] = SignatureSymbol;
+  }
+
+  // Add sections to the groups
+  unsigned Index = 1;
+  unsigned NumGroups = Groups.size();
+  for (MCAssembler::const_iterator it = Asm.begin(), ie = Asm.end();
+       it != ie; ++it, ++Index) {
+    const MCSectionELF &Section =
+      static_cast<const MCSectionELF&>(it->getSection());
+    if (!(Section.getFlags() & MCSectionELF::SHF_GROUP))
+      continue;
+    const MCSectionELF *Group = Groups[Section.getGroup()];
+    MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
+    // FIXME: we could use the previous fragment
+    MCDataFragment *F = new MCDataFragment(&Data);
+    String32(*F, NumGroups + Index);
+  }
+
+  for (RevGroupMapTy::const_iterator i = Groups.begin(), e = Groups.end();
+       i != e; ++i) {
+    const MCSectionELF *Group = i->second;
+    MCSectionData &Data = Asm.getOrCreateSectionData(*Group);
+    Asm.AddSectionToTheEnd(*Writer, Data, Layout);
+  }
+}
+
 void ELFObjectWriterImpl::WriteSection(MCAssembler &Asm,
                                        const SectionIndexMapTy &SectionIndexMap,
+                                       uint32_t GroupSymbolIndex,
                                        uint64_t Offset, uint64_t Size,
                                        uint64_t Alignment,
                                        const MCSectionELF &Section) {
@@ -1300,6 +1375,12 @@
     // Nothing to do.
     break;
 
+  case ELF::SHT_GROUP: {
+    sh_link = SymbolTableIndex;
+    sh_info = GroupSymbolIndex;
+    break;
+  }
+
   default:
     assert(0 && "FIXME: sh_type value not supported!");
     break;
@@ -1312,6 +1393,10 @@
 
 void ELFObjectWriterImpl::WriteObject(MCAssembler &Asm,
                                       const MCAsmLayout &Layout) {
+
+  GroupMapTy GroupMap;
+  CreateGroupSections(Asm, const_cast<MCAsmLayout&>(Layout), GroupMap);
+
   SectionIndexMapTy SectionIndexMap;
 
   ComputeIndexMap(Asm, SectionIndexMap);
@@ -1332,9 +1417,18 @@
   uint64_t HeaderSize = Is64Bit ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr);
   uint64_t FileOff = HeaderSize;
 
-  for (MCAssembler::const_iterator it = Asm.begin(),
-         ie = Asm.end(); it != ie; ++it) {
-    const MCSectionData &SD = *it;
+  std::vector<const MCSectionELF*> Sections;
+  Sections.resize(NumSections);
+
+  for (SectionIndexMapTy::const_iterator i=
+         SectionIndexMap.begin(), e = SectionIndexMap.end(); i != e; ++i) {
+    const std::pair<const MCSectionELF*, uint32_t> &p = *i;
+    Sections[p.second] = p.first;
+  }
+
+  for (unsigned i = 1; i < NumSections; ++i) {
+    const MCSectionELF &Section = *Sections[i];
+    const MCSectionData &SD = Asm.getOrCreateSectionData(Section);
 
     FileOff = RoundUpToAlignment(FileOff, SD.getAlignment());
 
@@ -1354,20 +1448,20 @@
   // ... then all of the sections ...
   DenseMap<const MCSection*, uint64_t> SectionOffsetMap;
 
-  for (MCAssembler::const_iterator it = Asm.begin(),
-         ie = Asm.end(); it != ie; ++it) {
-    const MCSectionData &SD = *it;
+  for (unsigned i = 1; i < NumSections; ++i) {
+    const MCSectionELF &Section = *Sections[i];
+    const MCSectionData &SD = Asm.getOrCreateSectionData(Section);
 
     uint64_t Padding = OffsetToAlignment(FileOff, SD.getAlignment());
     WriteZeros(Padding);
     FileOff += Padding;
 
     // Remember the offset into the file for this section.
-    SectionOffsetMap[&it->getSection()] = FileOff;
+    SectionOffsetMap[&Section] = FileOff;
 
     FileOff += Layout.getSectionFileSize(&SD);
 
-    Asm.WriteSectionData(it, Layout, Writer);
+    Asm.WriteSectionData(&SD, Layout, Writer);
   }
 
   uint64_t Padding = OffsetToAlignment(FileOff, NaturalAlignment);
@@ -1384,14 +1478,17 @@
     ShstrtabIndex >= ELF::SHN_LORESERVE ? ShstrtabIndex : 0;
   WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, FirstSectionLink, 0, 0, 0);
 
-  for (MCAssembler::const_iterator it = Asm.begin(),
-         ie = Asm.end(); it != ie; ++it) {
-    const MCSectionData &SD = *it;
-    const MCSectionELF &Section =
-      static_cast<const MCSectionELF&>(SD.getSection());
+  for (unsigned i = 1; i < NumSections; ++i) {
+    const MCSectionELF &Section = *Sections[i];
+    const MCSectionData &SD = Asm.getOrCreateSectionData(Section);
+    uint32_t GroupSymbolIndex;
+    if (Section.getType() != ELF::SHT_GROUP)
+      GroupSymbolIndex = 0;
+    else
+      GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm, GroupMap[&Section]);
 
-    WriteSection(Asm, SectionIndexMap, SectionOffsetMap[&Section],
-                 Layout.getSectionSize(&SD),
+    WriteSection(Asm, SectionIndexMap, GroupSymbolIndex,
+                 SectionOffsetMap[&Section], Layout.getSectionSize(&SD),
                  SD.getAlignment(), Section);
   }
 }

Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=118805&r1=118804&r2=118805&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Thu Nov 11 12:13:52 2010
@@ -150,7 +150,13 @@
 
 const MCSectionELF *MCContext::
 getELFSection(StringRef Section, unsigned Type, unsigned Flags,
-              SectionKind Kind, unsigned EntrySize) {
+              SectionKind Kind) {
+  return getELFSection(Section, Type, Flags, Kind, 0, "");
+}
+
+const MCSectionELF *MCContext::
+getELFSection(StringRef Section, unsigned Type, unsigned Flags,
+              SectionKind Kind, unsigned EntrySize, StringRef Group) {
   if (ELFUniquingMap == 0)
     ELFUniquingMap = new ELFUniqueMapTy();
   ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
@@ -163,12 +169,24 @@
   if (!EntrySize) {
     EntrySize = MCSectionELF::DetermineEntrySize(Kind);
   }
+
+  MCSymbol *GroupSym = NULL;
+  if (!Group.empty())
+    GroupSym = GetOrCreateSymbol(Group);
+
   MCSectionELF *Result = new (*this) MCSectionELF(Entry.getKey(), Type, Flags,
-                                                  Kind, EntrySize);
+                                                  Kind, EntrySize, GroupSym);
   Entry.setValue(Result);
   return Result;
 }
 
+const MCSectionELF *MCContext::CreateELFGroupSection() {
+  MCSectionELF *Result =
+    new (*this) MCSectionELF(".group", MCSectionELF::SHT_GROUP, 0,
+                             SectionKind::getReadOnly(), 4, NULL);
+  return Result;
+}
+
 const MCSection *MCContext::getCOFFSection(StringRef Section,
                                            unsigned Characteristics,
                                            int Selection,

Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=118805&r1=118804&r2=118805&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Thu Nov 11 12:13:52 2010
@@ -203,6 +203,7 @@
   StringRef FlagsStr;
   StringRef TypeName;
   int64_t Size = 0;
+  StringRef GroupName;
   if (getLexer().is(AsmToken::Comma)) {
     Lex();
 
@@ -249,7 +250,6 @@
         if (getLexer().isNot(AsmToken::Comma))
           return TokError("expected group name");
         Lex();
-        StringRef GroupName;
         if (getParser().ParseIdentifier(GroupName))
           return true;
         if (getLexer().is(AsmToken::Comma)) {
@@ -257,8 +257,8 @@
           StringRef Linkage;
           if (getParser().ParseIdentifier(Linkage))
             return true;
-          if (Linkage != "comdat" && Linkage != ".gnu.linkonce")
-            return TokError("Linkage must be 'comdat' or '.gnu.linkonce'");
+          if (Linkage != "comdat")
+            return TokError("Linkage must be 'comdat'");
         }
       }
     }
@@ -306,6 +306,7 @@
       Flags |= MCSectionELF::XCORE_SHF_DP_SECTION;
       break;
     case 'G':
+      Flags |= MCSectionELF::SHF_GROUP;
       break;
     default:
       return TokError("unknown flag");
@@ -331,7 +332,8 @@
                      ? SectionKind::getText()
                      : SectionKind::getDataRel();
   getStreamer().SwitchSection(getContext().getELFSection(SectionName, Type,
-                                                         Flags, Kind, Size));
+                                                         Flags, Kind, Size,
+                                                         GroupName));
   return false;
 }
 
@@ -405,7 +407,7 @@
                                MCSectionELF::SHF_MERGE |
                                MCSectionELF::SHF_STRINGS,
                                SectionKind::getReadOnly(),
-                               1);
+                               1, "");
 
   static bool First = true;
 

Added: llvm/trunk/test/MC/ELF/comdat.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/comdat.s?rev=118805&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/comdat.s (added)
+++ llvm/trunk/test/MC/ELF/comdat.s Thu Nov 11 12:13:52 2010
@@ -0,0 +1,39 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump   | FileCheck %s
+
+// Test that we produce the two group sections and that they are a the beginning
+// of the file.
+
+// CHECK:       # Section 0x00000001
+// CHECK-NEXT:  (('sh_name', 0x00000021) # '.group'
+// CHECK-NEXT:   ('sh_type', 0x00000011)
+// CHECK-NEXT:   ('sh_flags', 0x00000000)
+// CHECK-NEXT:   ('sh_addr', 0x00000000)
+// CHECK-NEXT:   ('sh_offset', 0x00000040)
+// CHECK-NEXT:   ('sh_size', 0x0000000c)
+// CHECK-NEXT:   ('sh_link', 0x0000000a)
+// CHECK-NEXT:   ('sh_info', 0x00000001)
+// CHECK-NEXT:   ('sh_addralign', 0x00000004)
+// CHECK-NEXT:   ('sh_entsize', 0x00000004)
+// CHECK-NEXT:  ),
+// CHECK-NEXT:  # Section 0x00000002
+// CHECK-NEXT:  (('sh_name', 0x00000021) # '.group'
+// CHECK-NEXT:   ('sh_type', 0x00000011)
+// CHECK-NEXT:   ('sh_flags', 0x00000000)
+// CHECK-NEXT:   ('sh_addr', 0x00000000)
+// CHECK-NEXT:   ('sh_offset', 0x0000004c)
+// CHECK-NEXT:   ('sh_size', 0x00000008)
+// CHECK-NEXT:   ('sh_link', 0x0000000a)
+// CHECK-NEXT:   ('sh_info', 0x00000002)
+// CHECK-NEXT:   ('sh_addralign', 0x00000004)
+// CHECK-NEXT:   ('sh_entsize', 0x00000004)
+
+	.section	.foo,"axG", at progbits,g1,comdat
+g1:
+        nop
+
+        .section	.bar,"axG", at progbits,g1,comdat
+        nop
+
+        .section	.zed,"axG", at progbits,g2,comdat
+g2:
+        nop

Modified: llvm/trunk/test/MC/ELF/section.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/section.s?rev=118805&r1=118804&r2=118805&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/section.s (original)
+++ llvm/trunk/test/MC/ELF/section.s Thu Nov 11 12:13:52 2010
@@ -20,31 +20,31 @@
 // CHECK-NEXT:  ('sh_type', 0x00000001)
 // CHECK-NEXT:  ('sh_flags', 0x00000006)
 // CHECK-NEXT:  ('sh_addr', 0x00000000)
-// CHECK-NEXT:  ('sh_offset', 0x00000040)
+// CHECK-NEXT:  ('sh_offset', 0x00000050)
 // CHECK-NEXT:  ('sh_size', 0x00000000)
 // CHECK-NEXT:  ('sh_link', 0x00000000)
 // CHECK-NEXT:  ('sh_info', 0x00000000)
 // CHECK-NEXT:  ('sh_addralign', 0x00000001)
 // CHECK-NEXT:  ('sh_entsize', 0x00000000)
 // CHECK-NEXT: ),
-// CHECK-NEXT: # Section 0x00000008
+// CHECK-NEXT: # Section 0x0000000a
 // CHECK-NEXT: (('sh_name', 0x0000003e) # '.fini'
 // CHECK-NEXT:  ('sh_type', 0x00000001)
 // CHECK-NEXT:  ('sh_flags', 0x00000006)
 // CHECK-NEXT:  ('sh_addr', 0x00000000)
-// CHECK-NEXT:  ('sh_offset', 0x00000040)
+// CHECK-NEXT:  ('sh_offset', 0x00000050)
 // CHECK-NEXT:  ('sh_size', 0x00000000)
 // CHECK-NEXT:  ('sh_link', 0x00000000)
 // CHECK-NEXT:  ('sh_info', 0x00000000)
 // CHECK-NEXT:  ('sh_addralign', 0x00000001)
 // CHECK-NEXT:  ('sh_entsize', 0x00000000)
 // CHECK-NEXT: ),
-// CHECK-NEXT: # Section 0x00000009
+// CHECK-NEXT: # Section 0x0000000b
 // CHECK-NEXT: (('sh_name', 0x00000044) # '.rodata'
 // CHECK-NEXT:  ('sh_type', 0x00000001)
 // CHECK-NEXT:  ('sh_flags', 0x00000002)
 // CHECK-NEXT:  ('sh_addr', 0x00000000)
-// CHECK-NEXT:  ('sh_offset', 0x00000040)
+// CHECK-NEXT:  ('sh_offset', 0x00000050)
 // CHECK-NEXT:  ('sh_size', 0x00000000)
 // CHECK-NEXT:  ('sh_link', 0x00000000)
 // CHECK-NEXT:  ('sh_info', 0x00000000)
@@ -53,5 +53,7 @@
 // CHECK-NEXT: ),
 
 // Test that we can parse these
+foo:
+bar:
 .section        .text.foo,"axG", at progbits,foo,comdat
-.section        .text.bar,"axMG", at progbits,42,bar,.gnu.linkonce
+.section        .text.bar,"axMG", at progbits,42,bar,comdat





More information about the llvm-commits mailing list