[lld] 33ff9e4 - [ELF] Move SharedFile::vernauxNum to Ctx
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 16 17:00:57 PST 2024
Author: Fangrui Song
Date: 2024-11-16T17:00:51-08:00
New Revision: 33ff9e43b4c5bdc3da31c6b11ad51d35a69bec5f
URL: https://github.com/llvm/llvm-project/commit/33ff9e43b4c5bdc3da31c6b11ad51d35a69bec5f
DIFF: https://github.com/llvm/llvm-project/commit/33ff9e43b4c5bdc3da31c6b11ad51d35a69bec5f.diff
LOG: [ELF] Move SharedFile::vernauxNum to Ctx
Added:
Modified:
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/InputFiles.cpp
lld/ELF/InputFiles.h
lld/ELF/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 0c65364e35046e..72feeb9d49cbd0 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -647,6 +647,8 @@ struct Ctx {
// True if all native vtable symbols have corresponding type info symbols
// during LTO.
bool ltoAllVtablesHaveTypeInfos = false;
+ // Number of Vernaux entries (needed shared object names).
+ uint32_t vernauxNum = 0;
// Each symbol assignment and DEFINED(sym) reference is assigned an increasing
// order. Each DEFINED(sym) evaluation checks whether the reference happens
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 78850e23220027..334dfc0e3ba150 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -144,6 +144,7 @@ void Ctx::reset() {
hasSympart.store(false, std::memory_order_relaxed);
hasTlsIe.store(false, std::memory_order_relaxed);
needsTlsLd.store(false, std::memory_order_relaxed);
+ vernauxNum = 0;
scriptSymOrderCounter = 1;
scriptSymOrder.clear();
ppc64noTocRelax.clear();
@@ -170,8 +171,6 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
Ctx &ctx = elf::ctx;
ctx.reset();
ctx.partitions.emplace_back(ctx);
-
- SharedFile::vernauxNum = 0;
};
context->e.logName = args::getFilenameWithoutExe(args[0]);
context->e.errorLimitExceededMsg =
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 63dfffd1d9b849..5a446f3544ada9 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1364,8 +1364,6 @@ static bool isNonCommonDef(Ctx &ctx, MemoryBufferRef mb, StringRef symName,
}
}
-unsigned SharedFile::vernauxNum;
-
SharedFile::SharedFile(Ctx &ctx, MemoryBufferRef m, StringRef defaultSoName)
: ELFFileBase(ctx, SharedKind, getELFKind(ctx, m, ""), m),
soName(defaultSoName), isNeeded(!ctx.arg.asNeeded) {}
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 70cdfc071382ec..a30d8a5ca7d67e 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -351,8 +351,6 @@ class SharedFile : public ELFFileBase {
// Verdefs, otherwise it is empty.
SmallVector<uint32_t, 0> vernauxs;
- static unsigned vernauxNum;
-
SmallVector<StringRef, 0> dtNeeded;
StringRef soName;
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 8a5aa9502f0129..49ffc0b8af5fb2 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -3806,7 +3806,7 @@ void elf::addVerneed(Ctx &ctx, Symbol &ss) {
// [1..getVerDefNum(ctx)]; this causes the vernaux identifiers to start from
// getVerDefNum(ctx)+1.
if (file.vernauxs[ss.versionId] == 0)
- file.vernauxs[ss.versionId] = ++SharedFile::vernauxNum + getVerDefNum(ctx);
+ file.vernauxs[ss.versionId] = ++ctx.vernauxNum + getVerDefNum(ctx);
ss.versionId = file.vernauxs[ss.versionId];
}
@@ -3839,7 +3839,7 @@ template <class ELFT> void VersionNeedSection<ELFT>::finalizeContents() {
if (isGlibc2) {
const char *ver = "GLIBC_ABI_DT_RELR";
vn.vernauxs.push_back({hashSysV(ver),
- ++SharedFile::vernauxNum + getVerDefNum(ctx),
+ ++ctx.vernauxNum + getVerDefNum(ctx),
getPartition(ctx).dynStrTab->addString(ver)});
}
}
@@ -3881,11 +3881,11 @@ template <class ELFT> void VersionNeedSection<ELFT>::writeTo(uint8_t *buf) {
template <class ELFT> size_t VersionNeedSection<ELFT>::getSize() const {
return verneeds.size() * sizeof(Elf_Verneed) +
- SharedFile::vernauxNum * sizeof(Elf_Vernaux);
+ ctx.vernauxNum * sizeof(Elf_Vernaux);
}
template <class ELFT> bool VersionNeedSection<ELFT>::isNeeded() const {
- return isLive() && SharedFile::vernauxNum != 0;
+ return isLive() && ctx.vernauxNum != 0;
}
void MergeSyntheticSection::addSection(MergeInputSection *ms) {
More information about the llvm-commits
mailing list