Skip to content

Commit 33ff9e4

Browse files
committed
[ELF] Move SharedFile::vernauxNum to Ctx
1 parent abbb0d9 commit 33ff9e4

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

lld/ELF/Config.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,8 @@ struct Ctx {
647647
// True if all native vtable symbols have corresponding type info symbols
648648
// during LTO.
649649
bool ltoAllVtablesHaveTypeInfos = false;
650+
// Number of Vernaux entries (needed shared object names).
651+
uint32_t vernauxNum = 0;
650652

651653
// Each symbol assignment and DEFINED(sym) reference is assigned an increasing
652654
// order. Each DEFINED(sym) evaluation checks whether the reference happens

lld/ELF/Driver.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ void Ctx::reset() {
144144
hasSympart.store(false, std::memory_order_relaxed);
145145
hasTlsIe.store(false, std::memory_order_relaxed);
146146
needsTlsLd.store(false, std::memory_order_relaxed);
147+
vernauxNum = 0;
147148
scriptSymOrderCounter = 1;
148149
scriptSymOrder.clear();
149150
ppc64noTocRelax.clear();
@@ -170,8 +171,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
170171
Ctx &ctx = elf::ctx;
171172
ctx.reset();
172173
ctx.partitions.emplace_back(ctx);
173-
174-
SharedFile::vernauxNum = 0;
175174
};
176175
context->e.logName = args::getFilenameWithoutExe(args[0]);
177176
context->e.errorLimitExceededMsg =

lld/ELF/InputFiles.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,8 +1364,6 @@ static bool isNonCommonDef(Ctx &ctx, MemoryBufferRef mb, StringRef symName,
13641364
}
13651365
}
13661366

1367-
unsigned SharedFile::vernauxNum;
1368-
13691367
SharedFile::SharedFile(Ctx &ctx, MemoryBufferRef m, StringRef defaultSoName)
13701368
: ELFFileBase(ctx, SharedKind, getELFKind(ctx, m, ""), m),
13711369
soName(defaultSoName), isNeeded(!ctx.arg.asNeeded) {}

lld/ELF/InputFiles.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ class SharedFile : public ELFFileBase {
351351
// Verdefs, otherwise it is empty.
352352
SmallVector<uint32_t, 0> vernauxs;
353353

354-
static unsigned vernauxNum;
355-
356354
SmallVector<StringRef, 0> dtNeeded;
357355
StringRef soName;
358356

lld/ELF/SyntheticSections.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3806,7 +3806,7 @@ void elf::addVerneed(Ctx &ctx, Symbol &ss) {
38063806
// [1..getVerDefNum(ctx)]; this causes the vernaux identifiers to start from
38073807
// getVerDefNum(ctx)+1.
38083808
if (file.vernauxs[ss.versionId] == 0)
3809-
file.vernauxs[ss.versionId] = ++SharedFile::vernauxNum + getVerDefNum(ctx);
3809+
file.vernauxs[ss.versionId] = ++ctx.vernauxNum + getVerDefNum(ctx);
38103810

38113811
ss.versionId = file.vernauxs[ss.versionId];
38123812
}
@@ -3839,7 +3839,7 @@ template <class ELFT> void VersionNeedSection<ELFT>::finalizeContents() {
38393839
if (isGlibc2) {
38403840
const char *ver = "GLIBC_ABI_DT_RELR";
38413841
vn.vernauxs.push_back({hashSysV(ver),
3842-
++SharedFile::vernauxNum + getVerDefNum(ctx),
3842+
++ctx.vernauxNum + getVerDefNum(ctx),
38433843
getPartition(ctx).dynStrTab->addString(ver)});
38443844
}
38453845
}
@@ -3881,11 +3881,11 @@ template <class ELFT> void VersionNeedSection<ELFT>::writeTo(uint8_t *buf) {
38813881

38823882
template <class ELFT> size_t VersionNeedSection<ELFT>::getSize() const {
38833883
return verneeds.size() * sizeof(Elf_Verneed) +
3884-
SharedFile::vernauxNum * sizeof(Elf_Vernaux);
3884+
ctx.vernauxNum * sizeof(Elf_Vernaux);
38853885
}
38863886

38873887
template <class ELFT> bool VersionNeedSection<ELFT>::isNeeded() const {
3888-
return isLive() && SharedFile::vernauxNum != 0;
3888+
return isLive() && ctx.vernauxNum != 0;
38893889
}
38903890

38913891
void MergeSyntheticSection::addSection(MergeInputSection *ms) {

0 commit comments

Comments
 (0)