summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-02-12 23:29:51 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-02-12 23:29:51 +0000
commitb6a812ebb10c074266d6e4f9d2e2405bf57e4788 (patch)
treea108b29b58d3e0b9b9bdf17a74d667d207a3cc10 /llvm/lib/MC/MCContext.cpp
parenta12fcb790fb3694c6fcdf14047be72283ae4a0ee (diff)
downloadbcm5719-llvm-b6a812ebb10c074266d6e4f9d2e2405bf57e4788.tar.gz
bcm5719-llvm-b6a812ebb10c074266d6e4f9d2e2405bf57e4788.zip
Add support for having multiple sections with the same name and comdat.
Using this in combination with -ffunction-sections allows LLVM to output a .o file with mulitple sections named .text. This saves space by avoiding long unique names of the form .text.<C++ mangled name>. llvm-svn: 228980
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 35609893e28..721edd451ee 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -272,12 +272,13 @@ void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) {
const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize,
- StringRef Group) {
+ StringRef Group, bool Unique) {
// Do the lookup, if we have a hit, return it.
auto IterBool = ELFUniquingMap.insert(
std::make_pair(SectionGroupPair(Section, Group), nullptr));
auto &Entry = *IterBool.first;
- if (!IterBool.second) return Entry.second;
+ if (!IterBool.second && !Unique)
+ return Entry.second;
MCSymbol *GroupSym = nullptr;
if (!Group.empty())
@@ -292,15 +293,22 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
Kind = SectionKind::getReadOnly();
MCSectionELF *Result = new (*this)
- MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym);
- Entry.second = Result;
+ MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym, Unique);
+ if (!Unique)
+ Entry.second = Result;
return Result;
}
+const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
+ unsigned Flags, unsigned EntrySize,
+ StringRef Group) {
+ return getELFSection(Section, Type, Flags, EntrySize, Group, false);
+}
+
const MCSectionELF *MCContext::CreateELFGroupSection() {
MCSectionELF *Result =
- new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0,
- SectionKind::getReadOnly(), 4, nullptr);
+ new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0,
+ SectionKind::getReadOnly(), 4, nullptr, false);
return Result;
}
OpenPOWER on IntegriCloud