mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Add r228980 back.
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>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229541 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user