Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lld/ELF/SyntheticSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,6 +1707,9 @@ void RelocationBaseSection::partitionRels() {
}

void RelocationBaseSection::finalizeContents() {
mergeRels();
// Compute DT_RELACOUNT to be used by part.dynamic.
partitionRels();
SymbolTableBaseSection *symTab = getPartition(ctx).dynSymTab.get();

// When linking glibc statically, .rel{,a}.plt contains R_*_IRELATIVE
Expand Down Expand Up @@ -1796,6 +1799,8 @@ void RelrBaseSection::mergeRels() {
relocsVec.clear();
}

void RelrBaseSection::finalizeContents() { mergeRels(); }

template <class ELFT>
AndroidPackedRelocationSection<ELFT>::AndroidPackedRelocationSection(
Ctx &ctx, StringRef name, unsigned concurrency)
Expand Down
7 changes: 4 additions & 3 deletions lld/ELF/SyntheticSections.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,14 +530,14 @@ class RelocationBaseSection : public SyntheticSection {
}
size_t getSize() const override { return relocs.size() * this->entsize; }
size_t getRelativeRelocCount() const { return numRelativeRelocs; }
void mergeRels();
void partitionRels();
void finalizeContents() override;

int32_t dynamicTag, sizeDynamicTag;
SmallVector<DynamicReloc, 0> relocs;

protected:
void mergeRels();
void partitionRels();
void computeRels();
// Used when parallel relocation scanning adds relocations. The elements
// will be moved into relocs by mergeRel().
Expand Down Expand Up @@ -608,14 +608,15 @@ class RelrBaseSection : public SyntheticSection {
isec.addReloc({expr, addendRelType, offsetInSec, addend, &sym});
addReloc<shard>({&isec, isec.relocs().size() - 1});
}
void mergeRels();
bool isNeeded() const override {
return !relocs.empty() ||
llvm::any_of(relocsVec, [](auto &v) { return !v.empty(); });
}
void finalizeContents() override;
SmallVector<RelativeReloc, 0> relocs;

protected:
void mergeRels();
SmallVector<SmallVector<RelativeReloc, 0>, 0> relocsVec;
};

Expand Down
17 changes: 3 additions & 14 deletions lld/ELF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2111,20 +2111,9 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
// Dynamic section must be the last one in this list and dynamic
// symbol table section (dynSymTab) must be the first one.
for (Partition &part : ctx.partitions) {
if (part.relaDyn) {
part.relaDyn->mergeRels();
// Compute DT_RELACOUNT to be used by part.dynamic.
part.relaDyn->partitionRels();
finalizeSynthetic(ctx, part.relaDyn.get());
}
if (part.relrDyn) {
part.relrDyn->mergeRels();
finalizeSynthetic(ctx, part.relrDyn.get());
}
if (part.relrAuthDyn) {
part.relrAuthDyn->mergeRels();
finalizeSynthetic(ctx, part.relrAuthDyn.get());
}
finalizeSynthetic(ctx, part.relaDyn.get());
finalizeSynthetic(ctx, part.relrDyn.get());
finalizeSynthetic(ctx, part.relrAuthDyn.get());

finalizeSynthetic(ctx, part.dynSymTab.get());
finalizeSynthetic(ctx, part.gnuHashTab.get());
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.