Skip to content

Commit ee284d2

Browse files
committed
[ELF] Avoid make<GdbIndexSection>. NFC
1 parent b0662a7 commit ee284d2

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

lld/ELF/SyntheticSections.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,7 +2872,8 @@ createSymbols(
28722872
}
28732873

28742874
// Returns a newly-created .gdb_index section.
2875-
template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
2875+
template <class ELFT>
2876+
std::unique_ptr<GdbIndexSection> GdbIndexSection::create() {
28762877
llvm::TimeTraceScope timeScope("Create gdb index");
28772878

28782879
// Collect InputFiles with .debug_info. See the comment in
@@ -2918,7 +2919,7 @@ template <class ELFT> GdbIndexSection *GdbIndexSection::create() {
29182919
nameAttrs[i] = readPubNamesAndTypes<ELFT>(dobj, chunks[i].compilationUnits);
29192920
});
29202921

2921-
auto *ret = make<GdbIndexSection>();
2922+
auto ret = std::make_unique<GdbIndexSection>();
29222923
ret->chunks = std::move(chunks);
29232924
std::tie(ret->symbols, ret->size) = createSymbols(nameAttrs, ret->chunks);
29242925

@@ -3860,6 +3861,7 @@ void InStruct::reset() {
38603861
ppc32Got2.reset();
38613862
ibtPlt.reset();
38623863
relaPlt.reset();
3864+
gdbIndex.reset();
38633865
shStrTab.reset();
38643866
strTab.reset();
38653867
symTab.reset();
@@ -3986,10 +3988,10 @@ InStruct elf::in;
39863988
std::vector<Partition> elf::partitions;
39873989
Partition *elf::mainPart;
39883990

3989-
template GdbIndexSection *GdbIndexSection::create<ELF32LE>();
3990-
template GdbIndexSection *GdbIndexSection::create<ELF32BE>();
3991-
template GdbIndexSection *GdbIndexSection::create<ELF64LE>();
3992-
template GdbIndexSection *GdbIndexSection::create<ELF64BE>();
3991+
template std::unique_ptr<GdbIndexSection> GdbIndexSection::create<ELF32LE>();
3992+
template std::unique_ptr<GdbIndexSection> GdbIndexSection::create<ELF32BE>();
3993+
template std::unique_ptr<GdbIndexSection> GdbIndexSection::create<ELF64LE>();
3994+
template std::unique_ptr<GdbIndexSection> GdbIndexSection::create<ELF64BE>();
39933995

39943996
template void elf::splitSections<ELF32LE>();
39953997
template void elf::splitSections<ELF32BE>();

lld/ELF/SyntheticSections.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ class GdbIndexSection final : public SyntheticSection {
822822
};
823823

824824
GdbIndexSection();
825-
template <typename ELFT> static GdbIndexSection *create();
825+
template <typename ELFT> static std::unique_ptr<GdbIndexSection> create();
826826
void writeTo(uint8_t *buf) override;
827827
size_t getSize() const override { return size; }
828828
bool isNeeded() const override;
@@ -1359,6 +1359,8 @@ struct InStruct {
13591359
std::unique_ptr<PPC32Got2Section> ppc32Got2;
13601360
std::unique_ptr<IBTPltSection> ibtPlt;
13611361
std::unique_ptr<RelocationBaseSection> relaPlt;
1362+
// Non-SHF_ALLOC sections
1363+
std::unique_ptr<GdbIndexSection> gdbIndex;
13621364
std::unique_ptr<StringTableSection> shStrTab;
13631365
std::unique_ptr<StringTableSection> strTab;
13641366
std::unique_ptr<SymbolTableBaseSection> symTab;

lld/ELF/Writer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -541,9 +541,6 @@ template <class ELFT> void elf::createSyntheticSections() {
541541
in.got->hasGotOffRel = true;
542542
}
543543

544-
if (config->gdbIndex)
545-
add(*GdbIndexSection::create<ELFT>());
546-
547544
// We always need to add rel[a].plt to output if it has entries.
548545
// Even for static linking it can contain R_[*]_IRELATIVE relocations.
549546
in.relaPlt = std::make_unique<RelocationSection<ELFT>>(
@@ -568,6 +565,11 @@ template <class ELFT> void elf::createSyntheticSections() {
568565
if (config->andFeatures || !ctx.aarch64PauthAbiCoreInfo.empty())
569566
add(*make<GnuPropertySection>());
570567

568+
if (config->gdbIndex) {
569+
in.gdbIndex = GdbIndexSection::create<ELFT>();
570+
add(*in.gdbIndex);
571+
}
572+
571573
// .note.GNU-stack is always added when we are creating a re-linkable
572574
// object file. Other linkers are using the presence of this marker
573575
// section to control the executable-ness of the stack area, but that

0 commit comments

Comments
 (0)