mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 15:13:49 -04:00
[MC] - Add .stack_size sections into groups and link them with .text
D39788 added a '.stack-size' section containing metadata on function stack sizes
to output ELF files behind the new -stack-size-section flag.
This change does following two things on top:
1) Imagine the case when there are -ffunction-sections flag given and there are text sections in COMDATs.
The patch adds a '.stack-size' section into corresponding COMDAT group, so that linker will be able to
eliminate them fast during resolving the COMDATs.
2) Patch sets a SHF_LINK_ORDER flag and links '.stack-size' with the corresponding .text.
With that linker will be able to do -gc-sections on dead stack sizes sections.
Differential revision: https://reviews.llvm.org/D46874
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@335332 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -948,3 +948,24 @@ MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
|
||||
return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
|
||||
0, utostr(Hash));
|
||||
}
|
||||
|
||||
MCSection *
|
||||
MCObjectFileInfo::getStackSizesSection(const MCSection &TextSec) const {
|
||||
if (Env != IsELF)
|
||||
return StackSizesSection;
|
||||
|
||||
const MCSectionELF &ElfSec = static_cast<const MCSectionELF &>(TextSec);
|
||||
unsigned Flags = ELF::SHF_LINK_ORDER;
|
||||
StringRef GroupName;
|
||||
if (const MCSymbol *Group = ElfSec.getGroup()) {
|
||||
GroupName = Group->getName();
|
||||
Flags |= ELF::SHF_GROUP;
|
||||
}
|
||||
|
||||
const MCSymbol *Link = TextSec.getBeginSymbol();
|
||||
auto It = StackSizesUniquing.insert({Link, StackSizesUniquing.size()});
|
||||
unsigned UniqueID = It.first->second;
|
||||
|
||||
return Ctx->getELFSection(".stack_sizes", ELF::SHT_PROGBITS, Flags, 0,
|
||||
GroupName, UniqueID, cast<MCSymbolELF>(Link));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user