Remove CopyRelSecOff from SharedSymbol.

This reduces the size of SharedSymbol which in turn reduces the size
of Symbol from 88 to 80 bytes.

llvm-svn: 313154
This commit is contained in:
Rafael Espindola 2017-09-13 16:59:12 +00:00
parent b1bb468aa9
commit f6c74c472d
3 changed files with 8 additions and 7 deletions

View File

@ -525,8 +525,12 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol *SS) {
// 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 addCopyRelSymbol(SharedSymbol *SS) {
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) {

View File

@ -110,8 +110,7 @@ static uint64_t getSymVA(const SymbolBody &Body, int64_t &Addend) {
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;

View File

@ -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 {