From 76e71bd66ef3d0ca040d3b13bda828e5b249e80b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 30 Apr 2015 14:21:49 +0000 Subject: [PATCH] Write sections mostly in one pass. During ELF writing, there is no need to further relax the sections, so we should not be creating fragments. This patch avoids doing so in all cases but debug section compression (that is next). Also, the ELF format is fairly simple to write. We can do a single pass over the sections to write them out and compute the section header table. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236235 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/MC/ELFObjectWriter.cpp | 238 +++++++++------------- test/MC/ARM/eh-directive-section-comdat.s | 11 +- test/MC/ARM/eh-directive-section.s | 4 +- test/MC/ARM/eh-link.s | 12 +- test/MC/ELF/comdat-dup-group-name.s | 14 +- test/MC/ELF/comdat-reloc.s | 4 +- test/MC/ELF/comdat.s | 26 ++- test/MC/ELF/section-sym.s | 10 +- 8 files changed, 138 insertions(+), 181 deletions(-) diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index ae57f9521e0..725461d76c6 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -78,10 +78,6 @@ class ELFObjectWriter : public MCObjectWriter { static bool isInSymtab(const MCAsmLayout &Layout, const MCSymbolData &Data, bool Used, bool Renamed); static bool isLocal(const MCSymbolData &Data, bool isUsedInReloc); - static bool IsELFMetaDataSection(const MCSectionData &SD); - - void writeDataSectionData(MCAssembler &Asm, const MCAsmLayout &Layout, - const MCSectionData &SD); /// Helper struct for containing some precomputed information on symbols. struct ELFSymbolData { @@ -193,7 +189,8 @@ class ELFObjectWriter : public MCObjectWriter { const MCAsmLayout &Layout); // Start and end offset of each section - typedef std::vector> SectionOffsetsTy; + typedef std::map> + SectionOffsetsTy; void WriteSymbolTable(MCAssembler &Asm, const MCAsmLayout &Layout, std::vector &Sections, @@ -224,32 +221,17 @@ class ELFObjectWriter : public MCObjectWriter { const SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap); - void maybeAddToGroup(MCAssembler &Asm, - ArrayRef Sections, - const RevGroupMapTy &RevGroupMap, - const MCSectionELF &Section, unsigned Index); - - void computeIndexMap(MCAssembler &Asm, - std::vector &Sections, - SectionIndexMapTy &SectionIndexMap, - const RevGroupMapTy &RevGroupMap); - - void createRelocationSection(MCAssembler &Asm, const MCSectionELF &Sec); + const MCSectionELF *createRelocationSection(MCAssembler &Asm, + const MCSectionELF &Sec); void CompressDebugSections(MCAssembler &Asm, MCAsmLayout &Layout); - void + const MCSectionELF * createSectionHeaderStringTable(MCAssembler &Asm, std::vector &Sections); - void createStringTable(MCAssembler &Asm, - std::vector &Sections); - - // Create the sections that show up in the symbol table. Currently - // those are the .note.GNU-stack section and the group sections. - void createIndexedSections(MCAssembler &Asm, const MCAsmLayout &Layout, - RevGroupMapTy &RevGroupMap, - std::vector &Sections, - SectionIndexMapTy &SectionIndexMap); + const MCSectionELF * + createStringTable(MCAssembler &Asm, + std::vector &Sections); void ExecutePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout) override; @@ -628,7 +610,7 @@ void ELFObjectWriter::WriteSymbolTable( } uint64_t SecEnd = OS.tell(); - SectionOffsets.push_back(std::make_pair(SecStart, SecEnd)); + SectionOffsets[SymtabSection] = std::make_pair(SecStart, SecEnd); ArrayRef ShndxIndexes = Writer.getShndxIndexes(); if (ShndxIndexes.empty()) @@ -644,7 +626,7 @@ void ELFObjectWriter::WriteSymbolTable( for (uint32_t Index : ShndxIndexes) write(Index); SecEnd = OS.tell(); - SectionOffsets.push_back(std::make_pair(SecStart, SecEnd)); + SectionOffsets[SymtabShndxSection] = std::make_pair(SecStart, SecEnd); } // It is always valid to create a relocation with a symbol. It is preferable @@ -948,37 +930,6 @@ bool ELFObjectWriter::isLocal(const MCSymbolData &Data, bool isUsedInReloc) { return true; } -void ELFObjectWriter::maybeAddToGroup(MCAssembler &Asm, - ArrayRef Sections, - const RevGroupMapTy &RevGroupMap, - const MCSectionELF &Section, - unsigned Index) { - const MCSymbol *Sym = Section.getGroup(); - if (!Sym) - return; - const MCSectionELF *Group = Sections[RevGroupMap.lookup(Sym) - 1]; - MCSectionData &Data = Asm.getOrCreateSectionData(*Group); - // FIXME: we could use the previous fragment - MCDataFragment *F = new MCDataFragment(&Data); - write(*F, Index); -} - -void ELFObjectWriter::computeIndexMap( - MCAssembler &Asm, std::vector &Sections, - SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap) { - for (const MCSectionData &SD : Asm) { - const MCSectionELF &Section = - static_cast(SD.getSection()); - if (Section.getType() == ELF::SHT_GROUP) - continue; - Sections.push_back(&Section); - unsigned Index = Sections.size(); - SectionIndexMap[&Section] = Index; - maybeAddToGroup(Asm, Sections, RevGroupMap, Section, Index); - createRelocationSection(Asm, Section); - } -} - void ELFObjectWriter::computeSymbolTable( MCAssembler &Asm, const MCAsmLayout &Layout, const SectionIndexMapTy &SectionIndexMap, @@ -1124,10 +1075,11 @@ void ELFObjectWriter::computeSymbolTable( UndefinedSymbolData[i].SymbolData->setIndex(Index++); } -void ELFObjectWriter::createRelocationSection(MCAssembler &Asm, - const MCSectionELF &Sec) { +const MCSectionELF * +ELFObjectWriter::createRelocationSection(MCAssembler &Asm, + const MCSectionELF &Sec) { if (Relocations[&Sec].empty()) - return; + return nullptr; MCContext &Ctx = Asm.getContext(); const StringRef SectionName = Sec.getSectionName(); @@ -1149,6 +1101,7 @@ void ELFObjectWriter::createRelocationSection(MCAssembler &Asm, Flags, EntrySize, Sec.getGroup(), &Sec); MCSectionData &RelSD = Asm.getOrCreateSectionData(*RelaSection); RelSD.setAlignment(is64Bit() ? 8 : 4); + return RelaSection; } static SmallVector @@ -1356,7 +1309,7 @@ void ELFObjectWriter::writeRelocations(const MCAssembler &Asm, } } -void ELFObjectWriter::createSectionHeaderStringTable( +const MCSectionELF *ELFObjectWriter::createSectionHeaderStringTable( MCAssembler &Asm, std::vector &Sections) { const MCSectionELF *ShstrtabSection = Sections[ShstrtabIndex - 1]; @@ -1369,9 +1322,10 @@ void ELFObjectWriter::createSectionHeaderStringTable( } ShStrTabBuilder.finalize(StringTableBuilder::ELF); OS << ShStrTabBuilder.data(); + return ShstrtabSection; } -void ELFObjectWriter::createStringTable( +const MCSectionELF *ELFObjectWriter::createStringTable( MCAssembler &Asm, std::vector &Sections) { MCContext &Ctx = Asm.getContext(); const MCSectionELF *StrtabSection = @@ -1380,43 +1334,7 @@ void ELFObjectWriter::createStringTable( Sections.push_back(StrtabSection); StringTableIndex = Sections.size(); OS << StrTabBuilder.data(); -} - -void ELFObjectWriter::createIndexedSections( - MCAssembler &Asm, const MCAsmLayout &Layout, RevGroupMapTy &RevGroupMap, - std::vector &Sections, - SectionIndexMapTy &SectionIndexMap) { - MCContext &Ctx = Asm.getContext(); - - const MCSectionELF *ShstrtabSection = - Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0); - Sections.push_back(ShstrtabSection); - ShstrtabIndex = Sections.size(); - assert(ShstrtabIndex == 1); - - // Build the groups - for (const MCSectionData &SD : Asm) { - const MCSectionELF &Section = - static_cast(SD.getSection()); - if (!(Section.getFlags() & ELF::SHF_GROUP)) - continue; - - const MCSymbol *SignatureSymbol = Section.getGroup(); - Asm.getOrCreateSymbolData(*SignatureSymbol); - unsigned &GroupIdx = RevGroupMap[SignatureSymbol]; - if (!GroupIdx) { - const MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol); - Sections.push_back(Group); - GroupIdx = Sections.size(); - - MCSectionData &Data = Asm.getOrCreateSectionData(*Group); - Data.setAlignment(4); - MCDataFragment *F = new MCDataFragment(&Data); - write(*F, uint32_t(ELF::GRP_COMDAT)); - } - } - - computeIndexMap(Asm, Sections, SectionIndexMap, RevGroupMap); + return StrtabSection; } void ELFObjectWriter::writeSection(MCAssembler &Asm, @@ -1472,26 +1390,6 @@ void ELFObjectWriter::writeSection(MCAssembler &Asm, Alignment, Section.getEntrySize()); } -bool ELFObjectWriter::IsELFMetaDataSection(const MCSectionData &SD) { - return SD.getOrdinal() == ~UINT32_C(0) && - !SD.getSection().isVirtualSection(); -} - -void ELFObjectWriter::writeDataSectionData(MCAssembler &Asm, - const MCAsmLayout &Layout, - const MCSectionData &SD) { - if (IsELFMetaDataSection(SD)) { - for (MCSectionData::const_iterator i = SD.begin(), e = SD.end(); i != e; - ++i) { - const MCFragment &F = *i; - assert(F.getKind() == MCFragment::FT_Data); - WriteBytes(cast(F).getContents()); - } - } else { - Asm.writeSectionData(&SD, Layout); - } -} - void ELFObjectWriter::writeSectionHeader( ArrayRef Sections, MCAssembler &Asm, const MCAsmLayout &Layout, const SectionIndexMapTy &SectionIndexMap, @@ -1512,7 +1410,8 @@ void ELFObjectWriter::writeSectionHeader( else GroupSymbolIndex = getSymbolIndexInSymbolTable(Asm, Section.getGroup()); - const std::pair &Offsets = SectionOffsets[i]; + const std::pair &Offsets = + SectionOffsets.find(&Section)->second; uint64_t Size = Section.getType() == ELF::SHT_NOBITS ? Layout.getSectionAddressSize(&SD) : Offsets.second - Offsets.first; @@ -1524,56 +1423,107 @@ void ELFObjectWriter::writeSectionHeader( void ELFObjectWriter::WriteObject(MCAssembler &Asm, const MCAsmLayout &Layout) { + CompressDebugSections(Asm, const_cast(Layout)); + + std::vector Sections; + MCContext &Ctx = Asm.getContext(); + const MCSectionELF *ShstrtabSection = + Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0); + Sections.push_back(ShstrtabSection); + ShstrtabIndex = Sections.size(); + RevGroupMapTy RevGroupMap; SectionIndexMapTy SectionIndexMap; - CompressDebugSections(Asm, const_cast(Layout)); - std::vector Sections; - createIndexedSections(Asm, Layout, RevGroupMap, Sections, SectionIndexMap); - - // Compute symbol table information. - computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap); - - SectionOffsetsTy SectionOffsets; + std::map> GroupMembers; // Write out the ELF header ... writeHeader(Asm); // ... then the sections ... - SectionOffsets.push_back(std::make_pair(0, 0)); - for (auto I = ++Sections.begin(), E = Sections.end(); I != E; ++I) { - const MCSectionELF &Sec = **I; - const MCSectionData &SD = Asm.getOrCreateSectionData(Sec); + SectionOffsetsTy SectionOffsets; + bool ComputedSymtab = false; + for (const MCSectionData &SD : Asm) { + const MCSectionELF &Section = + static_cast(SD.getSection()); + uint64_t Padding = OffsetToAlignment(OS.tell(), SD.getAlignment()); WriteZeros(Padding); // Remember the offset into the file for this section. uint64_t SecStart = OS.tell(); - unsigned Type = Sec.getType(); - if (Type != ELF::SHT_REL && Type != ELF::SHT_RELA) - writeDataSectionData(Asm, Layout, SD); - else - writeRelocations(Asm, *Sec.getAssociatedSection()); + const MCSymbol *SignatureSymbol = Section.getGroup(); + unsigned Type = Section.getType(); + if (Type == ELF::SHT_GROUP) { + assert(SignatureSymbol); + write(uint32_t(ELF::GRP_COMDAT)); + for (const MCSectionELF *Member : GroupMembers[SignatureSymbol]) { + uint32_t SecIndex = SectionIndexMap.lookup(Member); + write(SecIndex); + } + } else if (Type == ELF::SHT_REL || Type == ELF::SHT_RELA) { + if (!ComputedSymtab) { + // Compute symbol table information. + computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap); + ComputedSymtab = true; + } + writeRelocations(Asm, *Section.getAssociatedSection()); + } else { + Asm.writeSectionData(&SD, Layout); + } uint64_t SecEnd = OS.tell(); - SectionOffsets.push_back(std::make_pair(SecStart, SecEnd)); + SectionOffsets[&Section] = std::make_pair(SecStart, SecEnd); + + if (Type == ELF::SHT_GROUP || Type == ELF::SHT_REL || Type == ELF::SHT_RELA) + continue; + + const MCSectionELF *RelSection = createRelocationSection(Asm, Section); + + if (SignatureSymbol) { + Asm.getOrCreateSymbolData(*SignatureSymbol); + unsigned &GroupIdx = RevGroupMap[SignatureSymbol]; + if (!GroupIdx) { + const MCSectionELF *Group = Ctx.createELFGroupSection(SignatureSymbol); + Sections.push_back(Group); + GroupIdx = Sections.size(); + MCSectionData *GroupD = &Asm.getOrCreateSectionData(*Group); + GroupD->setAlignment(4); + } + GroupMembers[SignatureSymbol].push_back(&Section); + if (RelSection) + GroupMembers[SignatureSymbol].push_back(RelSection); + } + + Sections.push_back(&Section); + SectionIndexMap[&Section] = Sections.size(); + if (RelSection) { + Sections.push_back(RelSection); + SectionIndexMap[RelSection] = Sections.size(); + } + } + + if (!ComputedSymtab) { + // Compute symbol table information. + computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap); + ComputedSymtab = true; } WriteSymbolTable(Asm, Layout, Sections, SectionOffsets); { uint64_t SecStart = OS.tell(); - createStringTable(Asm, Sections); + const MCSectionELF *Sec = createStringTable(Asm, Sections); uint64_t SecEnd = OS.tell(); - SectionOffsets.push_back(std::make_pair(SecStart, SecEnd)); + SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd); } { uint64_t SecStart = OS.tell(); - createSectionHeaderStringTable(Asm, Sections); + const MCSectionELF *Sec = createSectionHeaderStringTable(Asm, Sections); uint64_t SecEnd = OS.tell(); - SectionOffsets[0] = std::make_pair(SecStart, SecEnd); + SectionOffsets[Sec] = std::make_pair(SecStart, SecEnd); } uint64_t NaturalAlignment = is64Bit() ? 8 : 4; diff --git a/test/MC/ARM/eh-directive-section-comdat.s b/test/MC/ARM/eh-directive-section-comdat.s index a397acd37de..9c7160ea5e7 100644 --- a/test/MC/ARM/eh-directive-section-comdat.s +++ b/test/MC/ARM/eh-directive-section-comdat.s @@ -93,12 +93,16 @@ func1: @ CHECK: ] @ CHECK: } +@ CHECK: Section { +@ CHECK: Index: 8 +@ CHECK-NEXT: Name: .rel.ARM.extab.TEST1 +@ CHECK: } @------------------------------------------------------------------------------- @ Check the .ARM.exidx.TEST1 section @------------------------------------------------------------------------------- @ CHECK: Section { -@ CHECK: Index: 8 +@ CHECK: Index: 9 @ CHECK-NEXT: Name: .ARM.exidx.TEST1 @ CHECK: Type: SHT_ARM_EXIDX (0x70000001) @------------------------------------------------------------------------------- @@ -113,11 +117,6 @@ func1: @ CHECK: } -@ CHECK: Section { -@ CHECK: Index: 9 -@ CHECK-NEXT: Name: .rel.ARM.extab.TEST1 -@ CHECK: } - @ CHECK: Section { @ CHECK: Index: 10 @ CHECK-NEXT: Name: .rel.ARM.exidx.TEST1 diff --git a/test/MC/ARM/eh-directive-section.s b/test/MC/ARM/eh-directive-section.s index f46daf3ad8a..e36d9a99aaf 100644 --- a/test/MC/ARM/eh-directive-section.s +++ b/test/MC/ARM/eh-directive-section.s @@ -109,7 +109,7 @@ func2: @ Check the TEST2 section (without the dot in the beginning) @------------------------------------------------------------------------------- @ CHECK: Section { -@ CHECK: Index: 8 +@ CHECK: Index: 10 @ CHECK-NEXT: Name: TEST2 @ CHECK: SectionData ( @ CHECK: 0000: 1EFF2FE1 |../.| @@ -143,7 +143,7 @@ func2: @------------------------------------------------------------------------------- @ This section should linked with TEST2 section. @------------------------------------------------------------------------------- -@ CHECK: Link: 8 +@ CHECK: Link: 10 @------------------------------------------------------------------------------- @ The first word should be relocated to the code address in TEST2 section. diff --git a/test/MC/ARM/eh-link.s b/test/MC/ARM/eh-link.s index 039eb73497e..e14fb0638b9 100644 --- a/test/MC/ARM/eh-link.s +++ b/test/MC/ARM/eh-link.s @@ -8,7 +8,7 @@ @ name first we could use a FileCheck variable. @ CHECK: Section { -@ CHECK: Index: 7 +@ CHECK: Index: 6 @ CHECK-NEXT: Name: .text @ CHECK-NEXT: Type: SHT_PROGBITS @ CHECK-NEXT: Flags [ @@ -25,7 +25,7 @@ @ CHECK-NEXT: EntrySize: 0 @ CHECK-NEXT: } @ CHECK-NEXT: Section { -@ CHECK-NEXT: Index: 8 +@ CHECK-NEXT: Index: 7 @ CHECK-NEXT: Name: .ARM.exidx @ CHECK-NEXT: Type: SHT_ARM_EXIDX @ CHECK-NEXT: Flags [ @@ -36,14 +36,14 @@ @ CHECK-NEXT: Address: 0x0 @ CHECK-NEXT: Offset: @ CHECK-NEXT: Size: 8 -@ CHECK-NEXT: Link: 7 +@ CHECK-NEXT: Link: 6 @ CHECK-NEXT: Info: 0 @ CHECK-NEXT: AddressAlignment: 4 @ CHECK-NEXT: EntrySize: 0 @ CHECK-NEXT: } @ CHECK: Section { -@ CHECK: Index: 9 +@ CHECK: Index: 10 @ CHECK-NEXT: Name: .text @ CHECK-NEXT: Type: SHT_PROGBITS @ CHECK-NEXT: Flags [ @@ -60,7 +60,7 @@ @ CHECK-NEXT: EntrySize: 0 @ CHECK-NEXT: } @ CHECK-NEXT: Section { -@ CHECK-NEXT: Index: 10 +@ CHECK-NEXT: Index: 11 @ CHECK-NEXT: Name: .ARM.exidx @ CHECK-NEXT: Type: SHT_ARM_EXIDX @ CHECK-NEXT: Flags [ @@ -71,7 +71,7 @@ @ CHECK-NEXT: Address: 0x0 @ CHECK-NEXT: Offset: @ CHECK-NEXT: Size: 8 -@ CHECK-NEXT: Link: 9 +@ CHECK-NEXT: Link: 10 @ CHECK-NEXT: Info: 0 @ CHECK-NEXT: AddressAlignment: 4 @ CHECK-NEXT: EntrySize: 0 diff --git a/test/MC/ELF/comdat-dup-group-name.s b/test/MC/ELF/comdat-dup-group-name.s index acf0db1b54e..a2dc4cc33d9 100644 --- a/test/MC/ELF/comdat-dup-group-name.s +++ b/test/MC/ELF/comdat-dup-group-name.s @@ -2,14 +2,14 @@ // Test that we produce two foo sections, each in separate groups -// CHECK: Index: 2 +// CHECK: Index: 5 // CHECK-NEXT: Name: .group -// CHECK: Index: 3 -// CHECK-NEXT: Name: .group +// CHECK: Index: 6 +// CHECK-NEXT: Name: .foo // CHECK: Index: 7 -// CHECK-NEXT: Name: .foo +// CHECK-NEXT: Name: .group // CHECK: Index: 8 // CHECK-NEXT: Name: .foo @@ -18,15 +18,15 @@ // CHECK: Name: f1 // CHECK-NOT: } -// CHECK: Section: .group (0x2) +// CHECK: Section: .group (0x5) // CHECK: Name: f2 // CHECK-NOT: } -// CHECK: Section: .group (0x3) +// CHECK: Section: .group (0x7) // CHECK: Name: .foo // CHECK-NOT: } -// CHECK: Section: .foo (0x7) +// CHECK: Section: .foo (0x6) // CHECK: Name: .foo // CHECK-NOT: } diff --git a/test/MC/ELF/comdat-reloc.s b/test/MC/ELF/comdat-reloc.s index 80901deac6e..1ea3d1e57ef 100644 --- a/test/MC/ELF/comdat-reloc.s +++ b/test/MC/ELF/comdat-reloc.s @@ -16,9 +16,9 @@ world: // CHECK: Name: .group // CHECK-NOT: SectionData // CHECK: SectionData -// CHECK-NEXT: 0000: 01000000 06000000 08000000 +// CHECK-NEXT: 0000: 01000000 07000000 08000000 -// CHECK: Index: 6 +// CHECK: Index: 7 // CHECK-NEXT: Name: .text.world // CHECK-NOT: Section { // CHECK: SHF_GROUP diff --git a/test/MC/ELF/comdat.s b/test/MC/ELF/comdat.s index 0f4e82a076e..e71dea089c4 100644 --- a/test/MC/ELF/comdat.s +++ b/test/MC/ELF/comdat.s @@ -1,10 +1,9 @@ -// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -t | FileCheck %s +// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s -t -sd | FileCheck %s -// Test that we produce the group sections and that they are at the beginning -// of the file. +// Test that we produce the group sections and that they are before the members // CHECK: Section { -// CHECK: Index: 2 +// CHECK: Index: 5 // CHECK-NEXT: Name: .group // CHECK-NEXT: Type: SHT_GROUP // CHECK-NEXT: Flags [ @@ -16,9 +15,12 @@ // CHECK-NEXT: Info: 1 // CHECK-NEXT: AddressAlignment: 4 // CHECK-NEXT: EntrySize: 4 +// CHECK-NEXT: SectionData ( +// CHECK-NEXT: 0000: 01000000 06000000 07000000 +// CHECK-NEXT: ) // CHECK-NEXT: } -// CHECK-NEXT: Section { -// CHECK-NEXT: Index: 3 +// CHECK: Section { +// CHECK: Index: 8 // CHECK-NEXT: Name: .group // CHECK-NEXT: Type: SHT_GROUP // CHECK-NEXT: Flags [ @@ -30,9 +32,12 @@ // CHECK-NEXT: Info: 2 // CHECK-NEXT: AddressAlignment: 4 // CHECK-NEXT: EntrySize: 4 +// CHECK-NEXT: SectionData ( +// CHECK-NEXT: 0000: 01000000 09000000 +// CHECK-NEXT: ) // CHECK-NEXT: } -// CHECK-NEXT: Section { -// CHECK-NEXT: Index: 4 +// CHECK: Section { +// CHECK: Index: 10 // CHECK-NEXT: Name: .group // CHECK-NEXT: Type: SHT_GROUP // CHECK-NEXT: Flags [ @@ -44,6 +49,9 @@ // CHECK-NEXT: Info: 10 // CHECK-NEXT: AddressAlignment: 4 // CHECK-NEXT: EntrySize: 4 +// CHECK-NEXT: SectionData ( +// CHECK-NEXT: 0000: 01000000 0B000000 0C000000 +// CHECK-NEXT: ) // CHECK-NEXT: } // Test that g1 and g2 are local, but g3 is an undefined global. @@ -64,7 +72,7 @@ // CHECK-NEXT: Binding: Local // CHECK-NEXT: Type: None // CHECK-NEXT: Other: 0 -// CHECK-NEXT: Section: .group (0x3) +// CHECK-NEXT: Section: .group (0x8) // CHECK-NEXT: } // CHECK: Symbol { diff --git a/test/MC/ELF/section-sym.s b/test/MC/ELF/section-sym.s index 3b39939297b..f012b2f1bed 100644 --- a/test/MC/ELF/section-sym.s +++ b/test/MC/ELF/section-sym.s @@ -7,9 +7,9 @@ // Test that the relocation points to the first section foo. -// The first seciton foo has index 7 +// The first seciton foo has index 6 // CHECK: Section { -// CHECK: Index: 7 +// CHECK: Index: 6 // CHECK-NEXT: Name: foo (28) // CHECK-NEXT: Type: SHT_PROGBITS (0x1) // CHECK-NEXT: Flags [ (0x202) @@ -24,8 +24,8 @@ // CHECK-NEXT: AddressAlignment: 1 // CHECK-NEXT: EntrySize: 0 // CHECK-NEXT: } -// CHECK-NEXT: Section { -// CHECK-NEXT: Index: 8 +// CHECK: Section { +// CHECK: Index: 8 // CHECK-NEXT: Name: foo (28) // CHECK-NEXT: Type: SHT_PROGBITS (0x1) // CHECK-NEXT: Flags [ (0x200) @@ -83,7 +83,7 @@ // symbol 6 // CHECK-NOT: Name // CHECK: Name: foo -// CHECK: Section: foo (0x7) +// CHECK: Section: foo (0x6) // symbol 7 // CHECK-NOT: Name