summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-05-21 19:46:39 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-05-21 19:46:39 +0000
commit1aa20fcb41ea4d940aca67135fe6200ad568f867 (patch)
treeebbb12a4f6c002d014a60d04e4ac0fb418eef860 /llvm/lib/MC/ELFObjectWriter.cpp
parent481dca239365287462520a6c582756280bc742a3 (diff)
downloadbcm5719-llvm-1aa20fcb41ea4d940aca67135fe6200ad568f867.tar.gz
bcm5719-llvm-1aa20fcb41ea4d940aca67135fe6200ad568f867.zip
Pass a const MCAssembler to writeSectionHeader.
It never creates sections, so it can use Asm.getSectionData instead of Asm.getOrCreateSectionData. llvm-svn: 237943
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index f1ba758dad5..ad3debf090b 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -230,7 +230,7 @@ class ELFObjectWriter : public MCObjectWriter {
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 SectionIndexMapTy &SectionIndexMap,
}
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);
OpenPOWER on IntegriCloud