diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-09-29 14:52:01 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-09-29 14:52:01 +0000 |
commit | 53f0bf194a0bb7837dbf732a4f72998a99261c81 (patch) | |
tree | a85b07c544e6da329dabbc026f87c429b1d22eb9 /llvm/lib/MC/MCELFStreamer.cpp | |
parent | 68e05d404ab803f800332e184031e7ae4f30d140 (diff) | |
download | bcm5719-llvm-53f0bf194a0bb7837dbf732a4f72998a99261c81.tar.gz bcm5719-llvm-53f0bf194a0bb7837dbf732a4f72998a99261c81.zip |
Move "local commons" to the end of .bss to match the gnu as behavior.
llvm-svn: 115037
Diffstat (limited to 'llvm/lib/MC/MCELFStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCELFStreamer.cpp | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index 6bf61a194c6..465f9ce79cb 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -111,6 +111,13 @@ public: virtual void Finish(); private: + struct LocalCommon { + MCSymbolData *SD; + uint64_t Size; + unsigned ByteAlignment; + }; + std::vector<LocalCommon> LocalCommons; + SmallPtrSet<MCSymbol *, 16> BindingExplicitlySet; /// @} void SetSection(StringRef Section, unsigned Type, unsigned Flags, @@ -343,17 +350,10 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, MCSectionELF::SHF_WRITE | MCSectionELF::SHF_ALLOC, SectionKind::getBSS()); - - MCSectionData &SectData = getAssembler().getOrCreateSectionData(*Section); - new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &SectData); - - MCFragment *F = new MCFillFragment(0, 0, Size, &SectData); - SD.setFragment(F); Symbol->setSection(*Section); - // Update the maximum alignment of the section if necessary. - if (ByteAlignment > SectData.getAlignment()) - SectData.setAlignment(ByteAlignment); + struct LocalCommon L = {&SD, Size, ByteAlignment}; + LocalCommons.push_back(L); } else { SD.setCommon(Size, ByteAlignment); } @@ -499,6 +499,26 @@ void MCELFStreamer::EmitInstruction(const MCInst &Inst) { } void MCELFStreamer::Finish() { + for (std::vector<LocalCommon>::const_iterator i = LocalCommons.begin(), + e = LocalCommons.end(); + i != e; ++i) { + MCSymbolData *SD = i->SD; + uint64_t Size = i->Size; + unsigned ByteAlignment = i->ByteAlignment; + const MCSymbol &Symbol = SD->getSymbol(); + const MCSection &Section = Symbol.getSection(); + + MCSectionData &SectData = getAssembler().getOrCreateSectionData(Section); + new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &SectData); + + MCFragment *F = new MCFillFragment(0, 0, Size, &SectData); + SD->setFragment(F); + + // Update the maximum alignment of the section if necessary. + if (ByteAlignment > SectData.getAlignment()) + SectData.setAlignment(ByteAlignment); + } + // FIXME: We create more atoms than it is necessary. Some relocations to // merge sections can be implemented with section address + offset, // figure out which ones and why. |