[lld] r313154 - Remove CopyRelSecOff from SharedSymbol.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 09:59:12 PDT 2017
Author: rafael
Date: Wed Sep 13 09:59:12 2017
New Revision: 313154
URL: http://llvm.org/viewvc/llvm-project?rev=313154&view=rev
Log:
Remove CopyRelSecOff from SharedSymbol.
This reduces the size of SharedSymbol which in turn reduces the size
of Symbol from 88 to 80 bytes.
Modified:
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/Symbols.cpp
lld/trunk/ELF/Symbols.h
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=313154&r1=313153&r2=313154&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Sep 13 09:59:12 2017
@@ -525,8 +525,12 @@ template <class ELFT> static void addCop
// See if this symbol is in a read-only segment. If so, preserve the symbol's
// memory protection by reserving space in the .bss.rel.ro section.
bool IsReadOnly = isReadOnly<ELFT>(SS);
- BssSection *Sec = IsReadOnly ? InX::BssRelRo : InX::Bss;
- uint64_t Off = Sec->reserveSpace(SymSize, SS->getAlignment<ELFT>());
+ BssSection *Sec = make<BssSection>(IsReadOnly ? ".bss.rel.ro" : ".bss");
+ Sec->reserveSpace(SymSize, SS->getAlignment<ELFT>());
+ if (IsReadOnly)
+ InX::BssRelRo->getParent()->addSection(Sec);
+ else
+ InX::Bss->getParent()->addSection(Sec);
// Look through the DSO's dynamic symbol table for aliases and create a
// dynamic symbol for each one. This causes the copy relocation to correctly
@@ -534,11 +538,10 @@ template <class ELFT> static void addCop
for (SharedSymbol *Sym : getSymbolsAt<ELFT>(SS)) {
Sym->CopyRelSec = Sec;
Sym->IsPreemptible = false;
- Sym->CopyRelSecOff = Off;
Sym->symbol()->IsUsedInRegularObj = true;
}
- In<ELFT>::RelaDyn->addReloc({Target->CopyRel, Sec, Off, false, SS, 0});
+ In<ELFT>::RelaDyn->addReloc({Target->CopyRel, Sec, 0, false, SS, 0});
}
static void errorOrWarn(const Twine &Msg) {
Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=313154&r1=313153&r2=313154&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Wed Sep 13 09:59:12 2017
@@ -110,8 +110,7 @@ static uint64_t getSymVA(const SymbolBod
case SymbolBody::SharedKind: {
auto &SS = cast<SharedSymbol>(Body);
if (SS.CopyRelSec)
- return SS.CopyRelSec->getParent()->Addr + SS.CopyRelSec->OutSecOff +
- SS.CopyRelSecOff;
+ return SS.CopyRelSec->getParent()->Addr + SS.CopyRelSec->OutSecOff;
if (SS.NeedsPltAddr)
return Body.getPltVA();
return 0;
Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=313154&r1=313153&r2=313154&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Wed Sep 13 09:59:12 2017
@@ -243,7 +243,6 @@ public:
// CopyRelSec and CopyRelSecOff are significant only when NeedsCopy is true.
InputSection *CopyRelSec;
- uint64_t CopyRelSecOff;
private:
template <class ELFT> const typename ELFT::Sym &getSym() const {
More information about the llvm-commits
mailing list