diff options
author | Fangrui Song <i@maskray.me> | 2021-12-21 20:19:51 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-12-21 20:19:51 -0800 |
commit | eb37330ac77774a9fe030aaa3c5759afa3377db5 (patch) | |
tree | 399730d0b091459c516acfd7b2a6e438e9e46b28 /lld/ELF/SyntheticSections.cpp | |
parent | 9effb6f81620058b57316401807b23db99e1682d (diff) | |
download | llvm-eb37330ac77774a9fe030aaa3c5759afa3377db5.zip llvm-eb37330ac77774a9fe030aaa3c5759afa3377db5.tar.gz llvm-eb37330ac77774a9fe030aaa3c5759afa3377db5.tar.bz2 |
[ELF] Change mipsGotIndex to uint32_t
This does not decrease sizeof(InputSection) (important for memory usage) on
ELF64 by itself but allows we to add another uint32_t.
Diffstat (limited to 'lld/ELF/SyntheticSections.cpp')
-rw-r--r-- | lld/ELF/SyntheticSections.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index a901c89..e25401b 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -763,18 +763,18 @@ size_t MipsGotSection::FileGot::getIndexedEntriesNum() const { } MipsGotSection::FileGot &MipsGotSection::getGot(InputFile &f) { - if (!f.mipsGotIndex.hasValue()) { + if (f.mipsGotIndex == uint32_t(-1)) { gots.emplace_back(); gots.back().file = &f; f.mipsGotIndex = gots.size() - 1; } - return gots[*f.mipsGotIndex]; + return gots[f.mipsGotIndex]; } uint64_t MipsGotSection::getPageEntryOffset(const InputFile *f, const Symbol &sym, int64_t addend) const { - const FileGot &g = gots[*f->mipsGotIndex]; + const FileGot &g = gots[f->mipsGotIndex]; uint64_t index = 0; if (const OutputSection *outSec = sym.getOutputSection()) { uint64_t secAddr = getMipsPageAddr(outSec->addr); @@ -788,7 +788,7 @@ uint64_t MipsGotSection::getPageEntryOffset(const InputFile *f, uint64_t MipsGotSection::getSymEntryOffset(const InputFile *f, const Symbol &s, int64_t addend) const { - const FileGot &g = gots[*f->mipsGotIndex]; + const FileGot &g = gots[f->mipsGotIndex]; Symbol *sym = const_cast<Symbol *>(&s); if (sym->isTls()) return g.tls.lookup(sym) * config->wordsize; @@ -798,13 +798,13 @@ uint64_t MipsGotSection::getSymEntryOffset(const InputFile *f, const Symbol &s, } uint64_t MipsGotSection::getTlsIndexOffset(const InputFile *f) const { - const FileGot &g = gots[*f->mipsGotIndex]; + const FileGot &g = gots[f->mipsGotIndex]; return g.dynTlsSymbols.lookup(nullptr) * config->wordsize; } uint64_t MipsGotSection::getGlobalDynOffset(const InputFile *f, const Symbol &s) const { - const FileGot &g = gots[*f->mipsGotIndex]; + const FileGot &g = gots[f->mipsGotIndex]; Symbol *sym = const_cast<Symbol *>(&s); return g.dynTlsSymbols.lookup(sym) * config->wordsize; } @@ -1061,10 +1061,9 @@ uint64_t MipsGotSection::getGp(const InputFile *f) const { // For files without related GOT or files refer a primary GOT // returns "common" _gp value. For secondary GOTs calculate // individual _gp values. - if (!f || !f->mipsGotIndex.hasValue() || *f->mipsGotIndex == 0) + if (!f || f->mipsGotIndex == uint32_t(-1) || f->mipsGotIndex == 0) return ElfSym::mipsGp->getVA(0); - return getVA() + gots[*f->mipsGotIndex].startIndex * config->wordsize + - 0x7ff0; + return getVA() + gots[f->mipsGotIndex].startIndex * config->wordsize + 0x7ff0; } void MipsGotSection::writeTo(uint8_t *buf) { |