Update the section index map after we add the medatada sections.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 10 Nov 2010 22:34:07 +0000 (22:34 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 10 Nov 2010 22:34:07 +0000 (22:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118728 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/ELFObjectWriter.cpp

index cd6c04229630bfc085958a786618818d40359c62..4928d115fe76eff3c89d69e96253b0674617429a 100644 (file)
@@ -1253,6 +1253,9 @@ void ELFObjectWriterImpl::WriteObject(MCAssembler &Asm,
                          const_cast<MCAsmLayout&>(Layout),
                          SectionIndexMap);
 
+  // Update to include the metadata sections.
+  ComputeIndexMap(Asm, SectionIndexMap);
+
   // Add 1 for the null section.
   unsigned NumSections = Asm.size() + 1;
   uint64_t NaturalAlignment = Is64Bit ? 8 : 4;
@@ -1335,6 +1338,7 @@ void ELFObjectWriterImpl::WriteObject(MCAssembler &Asm,
                                                      SectionKind::getReadOnly(),
                                                      false);
       sh_link = SectionIndexMap[SymtabSection];
+      assert(sh_link && ".symtab not found");
 
       // Remove ".rel" and ".rela" prefixes.
       unsigned SecNameLen = (Section.getType() == ELF::SHT_REL) ? 4 : 5;