From de42c188897f28f8a7b20cd9d8ea4130c83f2a36 Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Sat, 14 Mar 2015 21:57:15 +0000 Subject: [PATCH] Use setVisibility() rather than assigning the value directly. We don't want to risk to override wrong st_other bits, and when we need to zero, we can do that explictly. llvm-svn: 232282 --- lld/lib/ReaderWriter/ELF/ELFFile.h | 4 ++-- lld/lib/ReaderWriter/ELF/SectionChunks.h | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h index e726f10..fb7c021 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.h +++ b/lld/lib/ReaderWriter/ELF/ELFFile.h @@ -448,7 +448,7 @@ public: symbol->st_value = 0; symbol->st_shndx = llvm::ELF::SHN_ABS; symbol->setBindingAndType(llvm::ELF::STB_GLOBAL, llvm::ELF::STT_OBJECT); - symbol->st_other = llvm::ELF::STV_DEFAULT; + symbol->setVisibility(llvm::ELF::STV_DEFAULT); symbol->st_size = 0; auto newAtom = this->handleAbsoluteSymbol(symbolName, symbol, -1); this->_absoluteAtoms._atoms.push_back(*newAtom); @@ -463,7 +463,7 @@ public: symbol->st_value = 0; symbol->st_shndx = llvm::ELF::SHN_UNDEF; symbol->setBindingAndType(llvm::ELF::STB_GLOBAL, llvm::ELF::STT_NOTYPE); - symbol->st_other = llvm::ELF::STV_DEFAULT; + symbol->setVisibility(llvm::ELF::STV_DEFAULT); symbol->st_size = 0; auto newAtom = this->handleUndefinedSymbol(symbolName, symbol); this->_undefinedAtoms._atoms.push_back(*newAtom); diff --git a/lld/lib/ReaderWriter/ELF/SectionChunks.h b/lld/lib/ReaderWriter/ELF/SectionChunks.h index e8b3b5b..7496b72 100644 --- a/lld/lib/ReaderWriter/ELF/SectionChunks.h +++ b/lld/lib/ReaderWriter/ELF/SectionChunks.h @@ -784,7 +784,7 @@ void SymbolTable::addAbsoluteAtom(Elf_Sym &sym, const AbsoluteAtom *aa, sym.st_shndx = llvm::ELF::SHN_ABS; switch (aa->scope()) { case AbsoluteAtom::scopeLinkageUnit: - sym.st_other = llvm::ELF::STV_HIDDEN; + sym.setVisibility(llvm::ELF::STV_HIDDEN); binding = llvm::ELF::STB_LOCAL; break; case AbsoluteAtom::scopeTranslationUnit: @@ -843,7 +843,8 @@ void SymbolTable::addSymbol(const Atom *atom, int32_t sectionIndex, symbol.st_size = 0; symbol.st_shndx = sectionIndex; symbol.st_value = 0; - symbol.st_other = llvm::ELF::STV_DEFAULT; + symbol.st_other = 0; + symbol.setVisibility(llvm::ELF::STV_DEFAULT); // Add all the atoms if (const DefinedAtom *da = dyn_cast(atom)) -- 2.7.4