[llvm-branch-commits] [lld] release/19.x: [ELF] Move ElfSym into Ctx. NFC (PR #101844)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Aug 3 12:16:37 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-elf
Author: None (llvmbot)
<details>
<summary>Changes</summary>
Backport fd791f0fe562a41d8569fcb4d1e84b4c1e5719c7 8e2476e102e8ce3ae496b293bacccb248787404d 09dd0febbbd59a0c470b3909690cae6618a2416a 03be619d9434de0a9616660a2119675635239a5b
Requested by: @<!-- -->MaskRay
---
Patch is 47.68 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/101844.diff
16 Files Affected:
- (modified) lld/ELF/Arch/Mips.cpp (+2-2)
- (modified) lld/ELF/Arch/RISCV.cpp (+2-2)
- (modified) lld/ELF/Config.h (+72)
- (modified) lld/ELF/Driver.cpp (+18-9)
- (modified) lld/ELF/InputFiles.cpp (+2-5)
- (modified) lld/ELF/InputFiles.h (-3)
- (modified) lld/ELF/InputSection.cpp (+2-2)
- (modified) lld/ELF/LinkerScript.cpp (+8-8)
- (modified) lld/ELF/OutputSections.cpp (+1-9)
- (modified) lld/ELF/OutputSections.h (-13)
- (modified) lld/ELF/Relocations.cpp (+2-2)
- (modified) lld/ELF/Symbols.cpp (+2-19)
- (modified) lld/ELF/Symbols.h (+8-58)
- (modified) lld/ELF/SyntheticSections.cpp (+31-38)
- (modified) lld/ELF/Target.cpp (+2-2)
- (modified) lld/ELF/Writer.cpp (+85-87)
``````````diff
diff --git a/lld/ELF/Arch/Mips.cpp b/lld/ELF/Arch/Mips.cpp
index e36e9d59a7401..7c7137117d78e 100644
--- a/lld/ELF/Arch/Mips.cpp
+++ b/lld/ELF/Arch/Mips.cpp
@@ -121,9 +121,9 @@ RelExpr MIPS<ELFT>::getRelExpr(RelType type, const Symbol &s,
// offset between start of function and 'gp' value which by default
// equal to the start of .got section. In that case we consider these
// relocations as relative.
- if (&s == ElfSym::mipsGpDisp)
+ if (&s == ctx.sym.mipsGpDisp)
return R_MIPS_GOT_GP_PC;
- if (&s == ElfSym::mipsLocalGp)
+ if (&s == ctx.sym.mipsLocalGp)
return R_MIPS_GOT_GP;
[[fallthrough]];
case R_MIPS_32:
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 56759c28dcf41..8c2db2145f305 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -466,7 +466,7 @@ void RISCV::relocate(uint8_t *loc, const Relocation &rel, uint64_t val) const {
case INTERNAL_R_RISCV_GPREL_I:
case INTERNAL_R_RISCV_GPREL_S: {
- Defined *gp = ElfSym::riscvGlobalPointer;
+ Defined *gp = ctx.sym.riscvGlobalPointer;
int64_t displace = SignExtend64(val - gp->getVA(), bits);
checkInt(loc, displace, 12, rel);
uint32_t insn = (read32le(loc) & ~(31 << 15)) | (X_GP << 15);
@@ -789,7 +789,7 @@ static void relaxTlsLe(const InputSection &sec, size_t i, uint64_t loc,
static void relaxHi20Lo12(const InputSection &sec, size_t i, uint64_t loc,
Relocation &r, uint32_t &remove) {
- const Defined *gp = ElfSym::riscvGlobalPointer;
+ const Defined *gp = ctx.sym.riscvGlobalPointer;
if (!gp)
return;
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index 0173be396163e..f562985630be4 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -27,6 +27,7 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/GlobPattern.h"
#include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/TarWriter.h"
#include <atomic>
#include <memory>
#include <optional>
@@ -41,8 +42,11 @@ class ELFFileBase;
class SharedFile;
class InputSectionBase;
class EhInputSection;
+class Defined;
class Symbol;
class BitcodeCompiler;
+class OutputSection;
+struct PhdrEntry;
enum ELFKind : uint8_t {
ELFNoneKind,
@@ -458,6 +462,15 @@ struct ConfigWrapper {
LLVM_LIBRARY_VISIBILITY extern ConfigWrapper config;
+// Some index properties of a symbol are stored separately in this auxiliary
+// struct to decrease sizeof(SymbolUnion) in the majority of cases.
+struct SymbolAux {
+ uint32_t gotIdx = -1;
+ uint32_t pltIdx = -1;
+ uint32_t tlsDescIdx = -1;
+ uint32_t tlsGdIdx = -1;
+};
+
struct DuplicateSymbol {
const Symbol *sym;
const InputFile *file;
@@ -467,6 +480,60 @@ struct DuplicateSymbol {
struct Ctx {
LinkerDriver driver;
+
+ // These variables are initialized by Writer and should not be used before
+ // Writer is initialized.
+ uint8_t *bufferStart;
+ PhdrEntry *tlsPhdr;
+ struct OutSections {
+ OutputSection *elfHeader;
+ OutputSection *programHeaders;
+ OutputSection *preinitArray;
+ OutputSection *initArray;
+ OutputSection *finiArray;
+ };
+ OutSections out;
+
+ // Some linker-generated symbols need to be created as
+ // Defined symbols.
+ struct ElfSym {
+ // __bss_start
+ Defined *bss;
+
+ // etext and _etext
+ Defined *etext1;
+ Defined *etext2;
+
+ // edata and _edata
+ Defined *edata1;
+ Defined *edata2;
+
+ // end and _end
+ Defined *end1;
+ Defined *end2;
+
+ // The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention to
+ // be at some offset from the base of the .got section, usually 0 or
+ // the end of the .got.
+ Defined *globalOffsetTable;
+
+ // _gp, _gp_disp and __gnu_local_gp symbols. Only for MIPS.
+ Defined *mipsGp;
+ Defined *mipsGpDisp;
+ Defined *mipsLocalGp;
+
+ // __global_pointer$ for RISC-V.
+ Defined *riscvGlobalPointer;
+
+ // __rel{,a}_iplt_{start,end} symbols.
+ Defined *relaIpltStart;
+ Defined *relaIpltEnd;
+
+ // _TLS_MODULE_BASE_ on targets that support TLSDESC.
+ Defined *tlsModuleBase;
+ };
+ ElfSym sym;
+
SmallVector<std::unique_ptr<MemoryBuffer>> memoryBuffers;
SmallVector<ELFFileBase *, 0> objectFiles;
SmallVector<SharedFile *, 0> sharedFiles;
@@ -475,6 +542,8 @@ struct Ctx {
SmallVector<BitcodeFile *, 0> lazyBitcodeFiles;
SmallVector<InputSectionBase *, 0> inputSections;
SmallVector<EhInputSection *, 0> ehInputSections;
+
+ SmallVector<SymbolAux, 0> symAux;
// Duplicate symbol candidates.
SmallVector<DuplicateSymbol, 0> duplicates;
// Symbols in a non-prevailing COMDAT group which should be changed to an
@@ -489,6 +558,9 @@ struct Ctx {
std::pair<const InputFile *, const InputFile *>>
backwardReferences;
llvm::SmallSet<llvm::StringRef, 0> auxiliaryFiles;
+ // If --reproduce is specified, all input files are written to this tar
+ // archive.
+ std::unique_ptr<llvm::TarWriter> tar;
// InputFile for linker created symbols with no source location.
InputFile *internalFile;
// True if SHT_LLVM_SYMPART is used.
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 40e095a133d95..806f1e52e7244 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -93,6 +93,13 @@ void elf::errorOrWarn(const Twine &msg) {
void Ctx::reset() {
driver = LinkerDriver();
+
+ bufferStart = nullptr;
+ tlsPhdr = nullptr;
+ out = OutSections{};
+
+ sym = ElfSym{};
+
memoryBuffers.clear();
objectFiles.clear();
sharedFiles.clear();
@@ -101,11 +108,14 @@ void Ctx::reset() {
lazyBitcodeFiles.clear();
inputSections.clear();
ehInputSections.clear();
+
+ symAux.clear();
duplicates.clear();
nonPrevailingSyms.clear();
whyExtractRecords.clear();
backwardReferences.clear();
auxiliaryFiles.clear();
+ tar.reset();
internalFile = nullptr;
hasSympart.store(false, std::memory_order_relaxed);
hasTlsIe.store(false, std::memory_order_relaxed);
@@ -136,9 +146,7 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
symtab = SymbolTable();
outputSections.clear();
- symAux.clear();
- tar = nullptr;
in.reset();
partitions.clear();
@@ -153,7 +161,7 @@ bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS,
config = ConfigWrapper();
script = ScriptWrapper();
- symAux.emplace_back();
+ elf::ctx.symAux.emplace_back();
partitions.clear();
partitions.emplace_back();
@@ -224,14 +232,15 @@ std::vector<std::pair<MemoryBufferRef, uint64_t>> static getArchiveMembers(
std::vector<std::pair<MemoryBufferRef, uint64_t>> v;
Error err = Error::success();
- bool addToTar = file->isThin() && tar;
+ bool addToTar = file->isThin() && ctx.tar;
for (const Archive::Child &c : file->children(err)) {
MemoryBufferRef mbref =
CHECK(c.getMemoryBufferRef(),
mb.getBufferIdentifier() +
": could not get the buffer for a child of the archive");
if (addToTar)
- tar->append(relativeToRoot(check(c.getFullName())), mbref.getBuffer());
+ ctx.tar->append(relativeToRoot(check(c.getFullName())),
+ mbref.getBuffer());
v.push_back(std::make_pair(mbref, c.getChildOffset()));
}
if (err)
@@ -640,9 +649,9 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
Expected<std::unique_ptr<TarWriter>> errOrWriter =
TarWriter::create(path, path::stem(path));
if (errOrWriter) {
- tar = std::move(*errOrWriter);
- tar->append("response.txt", createResponseFile(args));
- tar->append("version.txt", getLLDVersion() + "\n");
+ ctx.tar = std::move(*errOrWriter);
+ ctx.tar->append("response.txt", createResponseFile(args));
+ ctx.tar->append("version.txt", getLLDVersion() + "\n");
StringRef ltoSampleProfile = args.getLastArgValue(OPT_lto_sample_profile);
if (!ltoSampleProfile.empty())
readFile(ltoSampleProfile);
@@ -2932,7 +2941,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
// Create elfHeader early. We need a dummy section in
// addReservedSymbols to mark the created symbols as not absolute.
- Out::elfHeader = make<OutputSection>("", 0, SHF_ALLOC);
+ ctx.out.elfHeader = make<OutputSection>("", 0, SHF_ALLOC);
// We need to create some reserved symbols such as _end. Create them.
if (!config->relocatable)
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index f1c0eb292361b..0e4ba06e9b780 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -28,7 +28,6 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/RISCVAttributeParser.h"
-#include "llvm/Support/TarWriter.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
@@ -52,8 +51,6 @@ extern template void ObjFile<ELF64BE>::importCmseSymbols();
bool InputFile::isInGroup;
uint32_t InputFile::nextGroupId;
-std::unique_ptr<TarWriter> elf::tar;
-
// Returns "<internal>", "foo.a(bar.o)" or "baz.o".
std::string lld::toString(const InputFile *f) {
static std::mutex mu;
@@ -261,8 +258,8 @@ std::optional<MemoryBufferRef> elf::readFile(StringRef path) {
MemoryBufferRef mbref = (*mbOrErr)->getMemBufferRef();
ctx.memoryBuffers.push_back(std::move(*mbOrErr)); // take MB ownership
- if (tar)
- tar->append(relativeToRoot(path), mbref.getBuffer());
+ if (ctx.tar)
+ ctx.tar->append(relativeToRoot(path), mbref.getBuffer());
return mbref;
}
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 8566baf61e1ab..b0a74877d0aae 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -39,9 +39,6 @@ namespace elf {
class InputSection;
class Symbol;
-// If --reproduce is specified, all input files are written to this tar archive.
-extern std::unique_ptr<llvm::TarWriter> tar;
-
// Opens a given file.
std::optional<MemoryBufferRef> readFile(StringRef path);
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 570e485455bad..da4c90516ec30 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -665,7 +665,7 @@ static Relocation *getRISCVPCRelHi20(const Symbol *sym, uint64_t addend) {
// target-specific adjustment to produce a thread-pointer-relative offset.
static int64_t getTlsTpOffset(const Symbol &s) {
// On targets that support TLSDESC, _TLS_MODULE_BASE_ at tpoff = 0.
- if (&s == ElfSym::tlsModuleBase)
+ if (&s == ctx.sym.tlsModuleBase)
return 0;
// There are 2 TLS layouts. Among targets we support, x86 uses TLS Variant 2
@@ -679,7 +679,7 @@ static int64_t getTlsTpOffset(const Symbol &s) {
// Variant 2. Static TLS blocks, followed by alignment padding are placed
// before TP. The alignment padding is added so that (TP - padding -
// p_memsz) is congruent to p_vaddr modulo p_align.
- PhdrEntry *tls = Out::tlsPhdr;
+ PhdrEntry *tls = ctx.tlsPhdr;
switch (config->emachine) {
// Variant 1.
case EM_ARM:
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 055fa21d44ca6..bf7491f11eff5 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -1359,8 +1359,8 @@ void LinkerScript::allocateHeaders(SmallVector<PhdrEntry *, 0> &phdrs) {
if ((paged || hasExplicitHeaders) &&
headerSize <= min - computeBase(min, hasExplicitHeaders)) {
min = alignDown(min - headerSize, config->maxPageSize);
- Out::elfHeader->addr = min;
- Out::programHeaders->addr = min + Out::elfHeader->size;
+ ctx.out.elfHeader->addr = min;
+ ctx.out.programHeaders->addr = min + ctx.out.elfHeader->size;
return;
}
@@ -1368,8 +1368,8 @@ void LinkerScript::allocateHeaders(SmallVector<PhdrEntry *, 0> &phdrs) {
if (hasExplicitHeaders)
error("could not allocate headers");
- Out::elfHeader->ptLoad = nullptr;
- Out::programHeaders->ptLoad = nullptr;
+ ctx.out.elfHeader->ptLoad = nullptr;
+ ctx.out.programHeaders->ptLoad = nullptr;
firstPTLoad->firstSec = findFirstSection(firstPTLoad);
llvm::erase_if(phdrs,
@@ -1397,8 +1397,8 @@ LinkerScript::assignAddresses() {
} else {
// Assign addresses to headers right now.
dot = target->getImageBase();
- Out::elfHeader->addr = dot;
- Out::programHeaders->addr = dot + Out::elfHeader->size;
+ ctx.out.elfHeader->addr = dot;
+ ctx.out.programHeaders->addr = dot + ctx.out.elfHeader->size;
dot += getHeaderSize();
}
@@ -1543,9 +1543,9 @@ SmallVector<PhdrEntry *, 0> LinkerScript::createPhdrs() {
PhdrEntry *phdr = make<PhdrEntry>(cmd.type, cmd.flags.value_or(PF_R));
if (cmd.hasFilehdr)
- phdr->add(Out::elfHeader);
+ phdr->add(ctx.out.elfHeader);
if (cmd.hasPhdrs)
- phdr->add(Out::programHeaders);
+ phdr->add(ctx.out.programHeaders);
if (cmd.lmaExpr) {
phdr->p_paddr = cmd.lmaExpr().getValue();
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 29f18f89274f3..509098eed2b83 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -39,14 +39,6 @@ using namespace llvm::ELF;
using namespace lld;
using namespace lld::elf;
-uint8_t *Out::bufferStart;
-PhdrEntry *Out::tlsPhdr;
-OutputSection *Out::elfHeader;
-OutputSection *Out::programHeaders;
-OutputSection *Out::preinitArray;
-OutputSection *Out::initArray;
-OutputSection *Out::finiArray;
-
SmallVector<OutputSection *, 0> elf::outputSections;
uint32_t OutputSection::getPhdrFlags() const {
@@ -272,7 +264,7 @@ static void sortByOrder(MutableArrayRef<InputSection *> in,
uint64_t elf::getHeaderSize() {
if (config->oFormatBinary)
return 0;
- return Out::elfHeader->size + Out::programHeaders->size;
+ return ctx.out.elfHeader->size + ctx.out.programHeaders->size;
}
void OutputSection::sort(llvm::function_ref<int(InputSectionBase *s)> order) {
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 8c0c52f34ac9f..6ced44be47e46 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -150,19 +150,6 @@ llvm::ArrayRef<InputSection *>
getInputSections(const OutputSection &os,
SmallVector<InputSection *, 0> &storage);
-// All output sections that are handled by the linker specially are
-// globally accessible. Writer initializes them, so don't use them
-// until Writer is initialized.
-struct Out {
- static uint8_t *bufferStart;
- static PhdrEntry *tlsPhdr;
- static OutputSection *elfHeader;
- static OutputSection *programHeaders;
- static OutputSection *preinitArray;
- static OutputSection *initArray;
- static OutputSection *finiArray;
-};
-
uint64_t getHeaderSize();
LLVM_LIBRARY_VISIBILITY extern llvm::SmallVector<OutputSection *, 0>
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index e19b1e6c8efb8..1c0dd97ed3910 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -1728,7 +1728,7 @@ static bool handleNonPreemptibleIfunc(Symbol &sym, uint16_t flags) {
auto &dyn = config->androidPackDynRelocs ? *in.relaPlt : *mainPart->relaDyn;
addPltEntry(*in.iplt, *in.igotPlt, dyn, target->iRelativeRel, *directSym);
sym.allocateAux();
- symAux.back().pltIdx = symAux[directSym->auxIdx].pltIdx;
+ ctx.symAux.back().pltIdx = ctx.symAux[directSym->auxIdx].pltIdx;
if (flags & HAS_DIRECT_RELOC) {
// Change the value to the IPLT and redirect all references to it.
@@ -1846,7 +1846,7 @@ void elf::postScanRelocations() {
{R_ADDEND, target->symbolicRel, got->getTlsIndexOff(), 1, &dummy});
}
- assert(symAux.size() == 1);
+ assert(ctx.symAux.size() == 1);
for (Symbol *sym : symtab.getSymbols())
fn(*sym);
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index 93653def328f8..4e1ae819b86fa 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -58,23 +58,6 @@ std::string lld::toString(const elf::Symbol &sym) {
return ret;
}
-Defined *ElfSym::bss;
-Defined *ElfSym::etext1;
-Defined *ElfSym::etext2;
-Defined *ElfSym::edata1;
-Defined *ElfSym::edata2;
-Defined *ElfSym::end1;
-Defined *ElfSym::end2;
-Defined *ElfSym::globalOffsetTable;
-Defined *ElfSym::mipsGp;
-Defined *ElfSym::mipsGpDisp;
-Defined *ElfSym::mipsLocalGp;
-Defined *ElfSym::riscvGlobalPointer;
-Defined *ElfSym::relaIpltStart;
-Defined *ElfSym::relaIpltEnd;
-Defined *ElfSym::tlsModuleBase;
-SmallVector<SymbolAux, 0> elf::symAux;
-
static uint64_t getSymVA(const Symbol &sym, int64_t addend) {
switch (sym.kind()) {
case Symbol::DefinedKind: {
@@ -136,10 +119,10 @@ static uint64_t getSymVA(const Symbol &sym, int64_t addend) {
// after sections are finalized. (e.g. Measuring the size of .rela.dyn
// for Android relocation packing requires knowing TLS symbol addresses
// during section finalization.)
- if (!Out::tlsPhdr || !Out::tlsPhdr->firstSec)
+ if (!ctx.tlsPhdr || !ctx.tlsPhdr->firstSec)
fatal(toString(d.file) +
" has an STT_TLS symbol but doesn't have an SHF_TLS section");
- return va - Out::tlsPhdr->firstSec->addr;
+ return va - ctx.tlsPhdr->firstSec->addr;
}
return va;
}
diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h
index e764fe8d73633..05aed16bfb0dc 100644
--- a/lld/ELF/Symbols.h
+++ b/lld/ELF/Symbols.h
@@ -56,17 +56,6 @@ enum {
NEEDS_TLSIE = 1 << 8,
};
-// Some index properties of a symbol are stored separately in this auxiliary
-// struct to decrease sizeof(SymbolUnion) in the majority of cases.
-struct SymbolAux {
- uint32_t gotIdx = -1;
- uint32_t pltIdx = -1;
- uint32_t tlsDescIdx = -1;
- uint32_t tlsGdIdx = -1;
-};
-
-LLVM_LIBRARY_VISIBILITY extern SmallVector<SymbolAux, 0> symAux;
-
// The base class for real symbol classes.
class Symbol {
public:
@@ -211,10 +200,10 @@ class Symbol {
// truncated by Symbol::parseSymbolVersion().
const char *getVersionSuffix() const { return nameData + nameSize; }
- uint32_t getGotIdx() const { return symAux[auxIdx].gotIdx; }
- uint32_t getPltIdx() const { return symAux[auxIdx].pltIdx; }
- uint32_t getTlsDescIdx() const { return symAux[auxIdx].tlsDescIdx; }
- uint32_t getTlsGdIdx() const { return symAux[auxIdx].tlsGdIdx; }
+ uint32_t getGotIdx() const { return ctx.symAux[auxIdx].gotIdx; }
+ uint32_t getPltIdx() const { return ctx.symAux[auxIdx].pltIdx; }
+ uint32_t getTlsDescIdx() const { return ctx.symAux[auxIdx].tlsDescIdx; }
+ uint32_t getTlsGdIdx() const { return ctx.symAux[auxIdx].tlsGdIdx; }
bool isInGot() const { return getGotIdx() != uint32_t(-1); }
bool isInPlt() const { return getPltIdx() != uint32_t(-1); }
@@ -325,8 +314,8 @@ class Symbol {
// entries during postScanRelocations();
std::atomic<uint16_t> flags;
- // A symAux index used to access GOT/PLT entry indexes. This is allocated in
- // postScanRelocations().
+ // A ctx.symAux index used to access GOT/PLT entry indexes. This is allocated
+ // in postScanRelocations().
uint32_t auxIdx;
uint32_t dynsymIndex;
@@ -357,8 +346,8 @@ class Symbol {
}
void allocateAux() {
assert(auxIdx == 0);
- auxIdx = symAux.size();
- symAux.emplace_back();
+ auxIdx = ctx.symAux.size();
+ ctx.symAux.emplace_back();
}
bool isSection() const { return type == llvm::ELF::STT_SECTION; }
@@ -512,45 +501,6 @@ class LazySymbol : public Symbol {
static bool classof(const Symbol *s) { return s->kind() == LazyKind; }
};
-// Some linker-generated symbols need to be created as
-// Defined symbols.
-struct ElfSym {
- // __bss_start
- static Defined *bss;
-
- // etext and _etext
- static Defined *etext1;
- static Defined *etext2;
-
- // edata and _edata
- static Defined *edata1;
- static Defined *edata2;
-
- // end and _end
- static Defined *end1;
- static Defined *end2;
-
- // The _GLOBAL_OFFSET_TABLE_ symbol is defined by target convention to
- // be at some offset from the base of the .got section, usually 0 or
- // the end of the .got.
- static Defined *globalOffsetTable;
-
- // _gp, _gp_disp and __gnu_local_gp symbols. Only for MIPS.
- static Defined *mipsGp;
- static Defined *mipsGpDisp;
- static Defined *mipsLocalGp;
-
- // __global_pointer$ for RISC-V.
- static Defined *riscvGlobalPointer;
-
- // __rel{,a}_iplt_{start,end} symbols.
- static Defined *relaIpltStart;
- static Defined *relaIpltEnd;
-
- // _TLS_MODULE_BASE_ on targets that support TLSDESC.
- static Defined *tlsModuleBase;
-};
-
// A buffer class that is large ...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/101844
More information about the llvm-branch-commits
mailing list