diff options
author | Fangrui Song <i@maskray.me> | 2024-11-17 00:09:06 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-11-17 00:09:06 -0800 |
commit | 53dc4e7600f95ae232bc49b9051f77199e79ec13 (patch) | |
tree | 7ebbda575eb7b083a2a8bb66d4cfc653d43cfe28 | |
parent | dbf37e956a0dd60ac84e3c08bc1fe8170cf44d22 (diff) | |
download | llvm-53dc4e7600f95ae232bc49b9051f77199e79ec13.zip llvm-53dc4e7600f95ae232bc49b9051f77199e79ec13.tar.gz llvm-53dc4e7600f95ae232bc49b9051f77199e79ec13.tar.bz2 |
[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.
-rw-r--r-- | lld/ELF/Config.h | 2 | ||||
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index ef81867..1e83104 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -524,6 +524,8 @@ struct InStruct { std::unique_ptr<SyntheticSection> riscvAttributes; std::unique_ptr<BssSection> bss; std::unique_ptr<BssSection> bssRelRo; + std::unique_ptr<SyntheticSection> gnuProperty; + std::unique_ptr<SyntheticSection> gnuStack; std::unique_ptr<GotSection> got; std::unique_ptr<GotPltSection> gotPlt; std::unique_ptr<IgotPltSection> igotPlt; diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 3b97111..00149aa 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -4907,8 +4907,10 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) { ctx.in.iplt = std::make_unique<IpltSection>(ctx); add(*ctx.in.iplt); - if (ctx.arg.andFeatures || !ctx.aarch64PauthAbiCoreInfo.empty()) - add(*make<GnuPropertySection>(ctx)); + if (ctx.arg.andFeatures || !ctx.aarch64PauthAbiCoreInfo.empty()) { + ctx.in.gnuProperty = std::make_unique<GnuPropertySection>(ctx); + add(*ctx.in.gnuProperty); + } if (ctx.arg.debugNames) { ctx.in.debugNames = std::make_unique<DebugNamesSection<ELFT>>(ctx); @@ -4925,8 +4927,10 @@ template <class ELFT> void elf::createSyntheticSections(Ctx &ctx) { // section to control the executable-ness of the stack area, but that // is irrelevant these days. Stack area should always be non-executable // by default. So we emit this section unconditionally. - if (ctx.arg.relocatable) - add(*make<GnuStackSection>(ctx)); + if (ctx.arg.relocatable) { + ctx.in.gnuStack = std::make_unique<GnuStackSection>(ctx); + add(*ctx.in.gnuStack); + } if (ctx.in.symTab) add(*ctx.in.symTab); |