Reduce sizeof(Symbol) from 104 bytes to 88 bytes.

Finding aliases for shared symbols doesn't need st_shndx because
we can just compare st_value.

llvm-svn: 316848
This commit is contained in:
Rui Ueyama 2017-10-28 22:18:17 +00:00
parent b37a24e82f
commit bd730e3ca7
3 changed files with 5 additions and 9 deletions

View File

@ -469,7 +469,7 @@ static std::vector<SharedSymbol *> getSymbolsAt(SharedSymbol *SS) {
std::vector<SharedSymbol *> Ret;
for (const Elf_Sym &S : File->getGlobalELFSyms()) {
if (S.st_shndx != SS->Shndx || S.st_value != SS->Value)
if (S.st_shndx == 0 || S.st_value != SS->Value)
continue;
StringRef Name = check(S.getName(File->getStringTable()));
SymbolBody *Sym = Symtab->find(Name);

View File

@ -517,8 +517,7 @@ void SymbolTable::addShared(StringRef Name, SharedFile<ELFT> *File,
if (WasInserted || ((Body->isUndefined() || Body->isLazy()) &&
Body->getVisibility() == STV_DEFAULT)) {
replaceBody<SharedSymbol>(S, File, Name, Sym.st_other, Sym.getType(),
Sym.st_value, Sym.st_size, Alignment,
Sym.st_shndx, Verdef);
Sym.st_value, Sym.st_size, Alignment, Verdef);
if (!S->isWeak())
File->IsUsed = true;
}

View File

@ -219,11 +219,9 @@ public:
static bool classof(const SymbolBody *S) { return S->kind() == SharedKind; }
SharedSymbol(StringRef Name, uint8_t StOther, uint8_t Type, uint64_t Value,
uint64_t Size, uint32_t Alignment, uint64_t Shndx,
const void *Verdef)
uint64_t Size, uint32_t Alignment, const void *Verdef)
: Defined(SharedKind, Name, /*IsLocal=*/false, StOther, Type),
Verdef(Verdef), Value(Value), Size(Size), Shndx(Shndx),
Alignment(Alignment) {
Verdef(Verdef), Value(Value), Size(Size), Alignment(Alignment) {
// GNU ifunc is a mechanism to allow user-supplied functions to
// resolve PLT slot values at load-time. This is contrary to the
// regualr symbol resolution scheme in which symbols are resolved just
@ -257,8 +255,7 @@ public:
InputSection *CopyRelSec = nullptr;
uint64_t Value; // st_value
uint64_t Size; // st_size
uint64_t Shndx; // st_shndx
uint32_t Size; // st_size
uint32_t Alignment;
};