Skip to content

Commit 53dc4e7

Browse files
committed
[ELF] createSyntheticSections: replace some make<> with unique_ptr
This removes some SpecificAlloc instantiations and makes lld smaller. This drops the small memory waste due to the separate BumpPtrAllocator.
1 parent dbf37e9 commit 53dc4e7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lld/ELF/Config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ struct InStruct {
524524
std::unique_ptr<SyntheticSection> riscvAttributes;
525525
std::unique_ptr<BssSection> bss;
526526
std::unique_ptr<BssSection> bssRelRo;
527+
std::unique_ptr<SyntheticSection> gnuProperty;
528+
std::unique_ptr<SyntheticSection> gnuStack;
527529
std::unique_ptr<GotSection> got;
528530
std::unique_ptr<GotPltSection> gotPlt;
529531
std::unique_ptr<IgotPltSection> igotPlt;

lld/ELF/SyntheticSections.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4907,8 +4907,10 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
49074907
ctx.in.iplt = std::make_unique<IpltSection>(ctx);
49084908
add(*ctx.in.iplt);
49094909

4910-
if (ctx.arg.andFeatures || !ctx.aarch64PauthAbiCoreInfo.empty())
4911-
add(*make<GnuPropertySection>(ctx));
4910+
if (ctx.arg.andFeatures || !ctx.aarch64PauthAbiCoreInfo.empty()) {
4911+
ctx.in.gnuProperty = std::make_unique<GnuPropertySection>(ctx);
4912+
add(*ctx.in.gnuProperty);
4913+
}
49124914

49134915
if (ctx.arg.debugNames) {
49144916
ctx.in.debugNames = std::make_unique<DebugNamesSection<ELFT>>(ctx);
@@ -4925,8 +4927,10 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) {
49254927
// section to control the executable-ness of the stack area, but that
49264928
// is irrelevant these days. Stack area should always be non-executable
49274929
// by default. So we emit this section unconditionally.
4928-
if (ctx.arg.relocatable)
4929-
add(*make<GnuStackSection>(ctx));
4930+
if (ctx.arg.relocatable) {
4931+
ctx.in.gnuStack = std::make_unique<GnuStackSection>(ctx);
4932+
add(*ctx.in.gnuStack);
4933+
}
49304934

49314935
if (ctx.in.symTab)
49324936
add(*ctx.in.symTab);

0 commit comments

Comments
 (0)