summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2016-12-22 05:11:12 +0000
committerRui Ueyama <ruiu@google.com>2016-12-22 05:11:12 +0000
commite50e8071c2d963ec9d90697fa4288ddfc7d51906 (patch)
tree4a637af6e0b68b5baf6cb36fb1ae74ef86a7aa96
parent34c037641b74dda8d7c10d35ffa476162c0125a6 (diff)
downloadbcm5719-llvm-e50e8071c2d963ec9d90697fa4288ddfc7d51906.tar.gz
bcm5719-llvm-e50e8071c2d963ec9d90697fa4288ddfc7d51906.zip
Define a function to avoid a magic variable 0x3.
llvm-svn: 290320
-rw-r--r--lld/ELF/SymbolTable.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 3cd74598684..987b555f04f 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -243,6 +243,8 @@ template <class ELFT> Symbol *SymbolTable<ELFT>::addUndefined(StringRef Name) {
/*CanOmitFromDynSym*/ false, /*File*/ nullptr);
}
+static uint8_t getVisibility(uint8_t StOther) { return StOther & 3; }
+
template <class ELFT>
Symbol *SymbolTable<ELFT>::addUndefined(StringRef Name, bool IsLocal,
uint8_t Binding, uint8_t StOther,
@@ -251,7 +253,7 @@ Symbol *SymbolTable<ELFT>::addUndefined(StringRef Name, bool IsLocal,
Symbol *S;
bool WasInserted;
std::tie(S, WasInserted) =
- insert(Name, Type, StOther & 3, CanOmitFromDynSym, File);
+ insert(Name, Type, getVisibility(StOther), CanOmitFromDynSym, File);
if (WasInserted) {
S->Binding = Binding;
replaceBody<Undefined>(S, Name, IsLocal, StOther, Type, File);
@@ -322,8 +324,8 @@ Symbol *SymbolTable<ELFT>::addCommon(StringRef N, uint64_t Size,
InputFile *File) {
Symbol *S;
bool WasInserted;
- std::tie(S, WasInserted) =
- insert(N, Type, StOther & 3, /*CanOmitFromDynSym*/ false, File);
+ std::tie(S, WasInserted) = insert(N, Type, getVisibility(StOther),
+ /*CanOmitFromDynSym*/ false, File);
int Cmp = compareDefined(S, WasInserted, Binding);
if (Cmp > 0) {
S->Binding = Binding;
@@ -383,7 +385,7 @@ Symbol *SymbolTable<ELFT>::addRegular(StringRef Name, uint8_t StOther,
InputFile *File) {
Symbol *S;
bool WasInserted;
- std::tie(S, WasInserted) = insert(Name, Type, StOther & 3,
+ std::tie(S, WasInserted) = insert(Name, Type, getVisibility(StOther),
/*CanOmitFromDynSym*/ false, File);
int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, Binding,
Section == nullptr, Value);
@@ -401,7 +403,7 @@ Symbol *SymbolTable<ELFT>::addSynthetic(StringRef N,
uintX_t Value, uint8_t StOther) {
Symbol *S;
bool WasInserted;
- std::tie(S, WasInserted) = insert(N, STT_NOTYPE, /*Visibility*/ StOther & 0x3,
+ std::tie(S, WasInserted) = insert(N, STT_NOTYPE, getVisibility(StOther),
/*CanOmitFromDynSym*/ false, nullptr);
int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, STB_GLOBAL,
/*IsAbsolute*/ false, /*Value*/ 0);
@@ -444,7 +446,7 @@ Symbol *SymbolTable<ELFT>::addBitcode(StringRef Name, uint8_t Binding,
Symbol *S;
bool WasInserted;
std::tie(S, WasInserted) =
- insert(Name, Type, StOther & 3, CanOmitFromDynSym, F);
+ insert(Name, Type, getVisibility(StOther), CanOmitFromDynSym, F);
int Cmp = compareDefinedNonCommon<ELFT>(S, WasInserted, Binding,
/*IsAbs*/ false, /*Value*/ 0);
if (Cmp > 0)
OpenPOWER on IntegriCloud