[llvm] r237943 - Pass a const MCAssembler to writeSectionHeader.
Rafael Espindola
rafael.espindola at gmail.com
Thu May 21 12:46:39 PDT 2015
Author: rafael
Date: Thu May 21 14:46:39 2015
New Revision: 237943
URL: http://llvm.org/viewvc/llvm-project?rev=237943&view=rev
Log:
Pass a const MCAssembler to writeSectionHeader.
It never creates sections, so it can use Asm.getSectionData instead of
Asm.getOrCreateSectionData.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=237943&r1=237942&r2=237943&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu May 21 14:46:39 2015
@@ -230,7 +230,7 @@ class ELFObjectWriter : public MCObjectW
void ExecutePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override;
- void writeSectionHeader(MCAssembler &Asm, const MCAsmLayout &Layout,
+ void writeSectionHeader(const MCAssembler &Asm, const MCAsmLayout &Layout,
const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets);
@@ -1299,7 +1299,7 @@ void ELFObjectWriter::writeSection(const
}
void ELFObjectWriter::writeSectionHeader(
- MCAssembler &Asm, const MCAsmLayout &Layout,
+ const MCAssembler &Asm, const MCAsmLayout &Layout,
const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets) {
const unsigned NumSections = SectionTable.size();
@@ -1310,7 +1310,6 @@ void ELFObjectWriter::writeSectionHeader
WriteSecHdrEntry(0, 0, 0, 0, 0, FirstSectionSize, 0, 0, 0, 0);
for (MCSectionELF *Section : SectionTable) {
- const MCSectionData &SD = Asm.getOrCreateSectionData(*Section);
uint32_t GroupSymbolIndex;
unsigned Type = Section->getType();
if (Type != ELF::SHT_GROUP)
@@ -1320,8 +1319,13 @@ void ELFObjectWriter::writeSectionHeader
const std::pair<uint64_t, uint64_t> &Offsets =
SectionOffsets.find(Section)->second;
- uint64_t Size = Type == ELF::SHT_NOBITS ? Layout.getSectionAddressSize(&SD)
- : Offsets.second - Offsets.first;
+ uint64_t Size;
+ if (Type == ELF::SHT_NOBITS) {
+ const MCSectionData &SD = Asm.getSectionData(*Section);
+ Size = Layout.getSectionAddressSize(&SD);
+ } else {
+ Size = Offsets.second - Offsets.first;
+ }
writeSection(SectionIndexMap, GroupSymbolIndex, Offsets.first, Size,
*Section);
More information about the llvm-commits
mailing list