forked from OSchip/llvm-project
[ELF] - Simplify a SymbolBody class interface a bit.
Get rid of few accessors in that class, and replace them with direct fields access. Differential revision: http://reviews.llvm.org/D17879 llvm-svn: 262796
This commit is contained in:
parent
4d1d16d0ed
commit
2f0fab53e4
|
@ -282,7 +282,7 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd,
|
||||||
SymVA = Out<ELFT>::Got->getMipsLocalFullAddr(*Body);
|
SymVA = Out<ELFT>::Got->getMipsLocalFullAddr(*Body);
|
||||||
else
|
else
|
||||||
SymVA = Body->getGotVA<ELFT>();
|
SymVA = Body->getGotVA<ELFT>();
|
||||||
if (Body->isTls())
|
if (Body->IsTls)
|
||||||
Type = Target->getTlsGotRel(Type);
|
Type = Target->getTlsGotRel(Type);
|
||||||
} else if (!Target->needsCopyRel<ELFT>(Type, *Body) &&
|
} else if (!Target->needsCopyRel<ELFT>(Type, *Body) &&
|
||||||
isa<SharedSymbol<ELFT>>(*Body)) {
|
isa<SharedSymbol<ELFT>>(*Body)) {
|
||||||
|
|
|
@ -955,7 +955,7 @@ bool elf::canBePreempted(const SymbolBody *Body) {
|
||||||
return false;
|
return false;
|
||||||
if (Body->getVisibility() != STV_DEFAULT)
|
if (Body->getVisibility() != STV_DEFAULT)
|
||||||
return false;
|
return false;
|
||||||
if (Config->Bsymbolic || (Config->BsymbolicFunctions && Body->isFunc()))
|
if (Config->Bsymbolic || (Config->BsymbolicFunctions && Body->IsFunc))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ template <class ELFT> void SymbolTable<ELFT>::resolve(SymbolBody *New) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (New->isTls() != Existing->isTls()) {
|
if (New->IsTls != Existing->IsTls) {
|
||||||
error("TLS attribute mismatch for symbol: " + conflictMsg(Existing, New));
|
error("TLS attribute mismatch for symbol: " + conflictMsg(Existing, New));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -346,8 +346,7 @@ void SymbolTable<ELFT>::addMemberFile(Undefined *Undef, Lazy *L) {
|
||||||
L->setWeak();
|
L->setWeak();
|
||||||
|
|
||||||
// FIXME: Do we need to copy more?
|
// FIXME: Do we need to copy more?
|
||||||
if (Undef->isTls())
|
L->IsTls |= Undef->IsTls;
|
||||||
L->setTls();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ typename ELFFile<ELFT>::uintX_t SymbolBody::getVA() const {
|
||||||
auto *SS = cast<SharedSymbol<ELFT>>(this);
|
auto *SS = cast<SharedSymbol<ELFT>>(this);
|
||||||
if (!SS->NeedsCopyOrPltAddr)
|
if (!SS->NeedsCopyOrPltAddr)
|
||||||
return 0;
|
return 0;
|
||||||
if (SS->isFunc())
|
if (SS->IsFunc)
|
||||||
return getPltVA<ELFT>();
|
return getPltVA<ELFT>();
|
||||||
else
|
else
|
||||||
return Out<ELFT>::Bss->getVA() + SS->OffsetInBss;
|
return Out<ELFT>::Bss->getVA() + SS->OffsetInBss;
|
||||||
|
|
|
@ -84,8 +84,6 @@ public:
|
||||||
bool isLazy() const { return SymbolKind == LazyKind; }
|
bool isLazy() const { return SymbolKind == LazyKind; }
|
||||||
bool isShared() const { return SymbolKind == SharedKind; }
|
bool isShared() const { return SymbolKind == SharedKind; }
|
||||||
bool isUsedInRegularObj() const { return IsUsedInRegularObj; }
|
bool isUsedInRegularObj() const { return IsUsedInRegularObj; }
|
||||||
bool isFunc() const { return Type == llvm::ELF::STT_FUNC; }
|
|
||||||
bool isTls() const { return Type == llvm::ELF::STT_TLS; }
|
|
||||||
|
|
||||||
// Returns the symbol name.
|
// Returns the symbol name.
|
||||||
StringRef getName() const { return Name; }
|
StringRef getName() const { return Name; }
|
||||||
|
@ -131,8 +129,9 @@ protected:
|
||||||
SymbolBody(Kind K, StringRef Name, bool IsWeak, uint8_t Visibility,
|
SymbolBody(Kind K, StringRef Name, bool IsWeak, uint8_t Visibility,
|
||||||
uint8_t Type)
|
uint8_t Type)
|
||||||
: SymbolKind(K), IsWeak(IsWeak), Visibility(Visibility),
|
: SymbolKind(K), IsWeak(IsWeak), Visibility(Visibility),
|
||||||
MustBeInDynSym(false), NeedsCopyOrPltAddr(false),
|
MustBeInDynSym(false), NeedsCopyOrPltAddr(false), Name(Name) {
|
||||||
Type(Type), Name(Name) {
|
IsFunc = Type == llvm::ELF::STT_FUNC;
|
||||||
|
IsTls = Type == llvm::ELF::STT_TLS;
|
||||||
IsUsedInRegularObj = K != SharedKind && K != LazyKind;
|
IsUsedInRegularObj = K != SharedKind && K != LazyKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,9 +153,10 @@ public:
|
||||||
// symbol or if the symbol should point to its plt entry.
|
// symbol or if the symbol should point to its plt entry.
|
||||||
unsigned NeedsCopyOrPltAddr : 1;
|
unsigned NeedsCopyOrPltAddr : 1;
|
||||||
|
|
||||||
protected:
|
unsigned IsTls : 1;
|
||||||
uint8_t Type;
|
unsigned IsFunc : 1;
|
||||||
|
|
||||||
|
protected:
|
||||||
StringRef Name;
|
StringRef Name;
|
||||||
Symbol *Backref = nullptr;
|
Symbol *Backref = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -305,7 +305,7 @@ public:
|
||||||
// OffsetInBss is significant only when needsCopy() is true.
|
// OffsetInBss is significant only when needsCopy() is true.
|
||||||
uintX_t OffsetInBss = 0;
|
uintX_t OffsetInBss = 0;
|
||||||
|
|
||||||
bool needsCopy() const { return this->NeedsCopyOrPltAddr && !this->isFunc(); }
|
bool needsCopy() const { return this->NeedsCopyOrPltAddr && !this->IsFunc; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// This class represents a symbol defined in an archive file. It is
|
// This class represents a symbol defined in an archive file. It is
|
||||||
|
@ -326,7 +326,6 @@ public:
|
||||||
// was already returned.
|
// was already returned.
|
||||||
std::unique_ptr<InputFile> getMember();
|
std::unique_ptr<InputFile> getMember();
|
||||||
|
|
||||||
void setTls() { this->Type = llvm::ELF::STT_TLS; }
|
|
||||||
void setWeak() { IsWeak = true; }
|
void setWeak() { IsWeak = true; }
|
||||||
void setUsedInRegularObj() { IsUsedInRegularObj = true; }
|
void setUsedInRegularObj() { IsUsedInRegularObj = true; }
|
||||||
|
|
||||||
|
|
|
@ -264,7 +264,7 @@ TargetInfo *createTarget() {
|
||||||
TargetInfo::~TargetInfo() {}
|
TargetInfo::~TargetInfo() {}
|
||||||
|
|
||||||
bool TargetInfo::canRelaxTls(uint32_t Type, const SymbolBody *S) const {
|
bool TargetInfo::canRelaxTls(uint32_t Type, const SymbolBody *S) const {
|
||||||
if (Config->Shared || (S && !S->isTls()))
|
if (Config->Shared || (S && !S->IsTls))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// We know we are producing an executable.
|
// We know we are producing an executable.
|
||||||
|
@ -485,7 +485,7 @@ bool X86TargetInfo::needsCopyRelImpl(uint32_t Type) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool X86TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
|
bool X86TargetInfo::needsGot(uint32_t Type, SymbolBody &S) const {
|
||||||
if (S.isTls() && Type == R_386_TLS_GD)
|
if (S.IsTls && Type == R_386_TLS_GD)
|
||||||
return Target->canRelaxTls(Type, &S) && canBePreempted(&S);
|
return Target->canRelaxTls(Type, &S) && canBePreempted(&S);
|
||||||
if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE)
|
if (Type == R_386_TLS_GOTIE || Type == R_386_TLS_IE)
|
||||||
return !canRelaxTls(Type, &S);
|
return !canRelaxTls(Type, &S);
|
||||||
|
|
|
@ -268,7 +268,7 @@ static bool handleTlsRelocation(uint32_t Type, SymbolBody *Body,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Body || !Body->isTls())
|
if (!Body || !Body->IsTls)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Target->isTlsGlobalDynamicRel(Type)) {
|
if (Target->isTlsGlobalDynamicRel(Type)) {
|
||||||
|
@ -424,7 +424,7 @@ void Writer<ELFT>::scanRelocs(
|
||||||
if (CBP || Dynrel) {
|
if (CBP || Dynrel) {
|
||||||
uint32_t DynType;
|
uint32_t DynType;
|
||||||
if (CBP)
|
if (CBP)
|
||||||
DynType = Body->isTls() ? Target->TlsGotRel : Target->GotRel;
|
DynType = Body->IsTls ? Target->TlsGotRel : Target->GotRel;
|
||||||
else
|
else
|
||||||
DynType = Target->RelativeRel;
|
DynType = Target->RelativeRel;
|
||||||
Out<ELFT>::RelaDyn->addReloc(
|
Out<ELFT>::RelaDyn->addReloc(
|
||||||
|
|
Loading…
Reference in New Issue