diff options
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCContext.cpp | 4 | ||||
-rw-r--r-- | lib/MC/MCSectionELF.cpp | 23 |
2 files changed, 15 insertions, 12 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index e5586a0d7c..1e65f87792 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -160,6 +160,10 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags, StringMapEntry<const MCSectionELF*> &Entry = Map.GetOrCreateValue(Section); if (Entry.getValue()) return Entry.getValue(); + // Possibly refine the entry size first. + if (!EntrySize) { + EntrySize = MCSectionELF::DetermineEntrySize(Kind); + } MCSectionELF *Result = new (*this) MCSectionELF(Entry.getKey(), Type, Flags, Kind, IsExplicit, EntrySize); Entry.setValue(Result); diff --git a/lib/MC/MCSectionELF.cpp b/lib/MC/MCSectionELF.cpp index a7599de1b7..ef935d0c64 100644 --- a/lib/MC/MCSectionELF.cpp +++ b/lib/MC/MCSectionELF.cpp @@ -104,17 +104,8 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI, else if (Type == MCSectionELF::SHT_PROGBITS) OS << "progbits"; - if (getKind().isMergeable1ByteCString()) { - OS << ",1"; - } else if (getKind().isMergeable2ByteCString()) { - OS << ",2"; - } else if (getKind().isMergeable4ByteCString() || - getKind().isMergeableConst4()) { - OS << ",4"; - } else if (getKind().isMergeableConst8()) { - OS << ",8"; - } else if (getKind().isMergeableConst16()) { - OS << ",16"; + if (EntrySize) { + OS << "," << EntrySize; } } @@ -132,4 +123,12 @@ bool MCSectionELF::HasCommonSymbols() const { return false; } - +unsigned MCSectionELF::DetermineEntrySize(SectionKind Kind) { + if (Kind.isMergeable1ByteCString()) return 1; + if (Kind.isMergeable2ByteCString()) return 2; + if (Kind.isMergeable4ByteCString()) return 4; + if (Kind.isMergeableConst4()) return 4; + if (Kind.isMergeableConst8()) return 8; + if (Kind.isMergeableConst16()) return 16; + return 0; +} |