[MCJIT] Make MCJIT honor symbol visibility settings when populating the global

symbol table.

Patch by Anthony Pesch. Thanks Anthony!



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220245 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lang Hames
2014-10-20 23:39:54 +00:00
parent a37862e2de
commit 32aaaeaa05
10 changed files with 62 additions and 7 deletions

View File

@@ -177,6 +177,19 @@ protected:
return DRI;
}
bool isExportedToOtherDSO(const Elf_Sym *ESym) const {
unsigned char Binding = ESym->getBinding();
unsigned char Visibility = ESym->getVisibility();
if (Binding != ELF::STB_GLOBAL && Binding != ELF::STB_WEAK)
return false;
if (Visibility != ELF::STV_DEFAULT && Visibility != ELF::STV_PROTECTED)
return false;
return true;
}
// This flag is used for classof, to distinguish ELFObjectFile from
// its subclass. If more subclasses will be created, this flag will
// have to become an enum.
@@ -373,6 +386,9 @@ uint32_t ELFObjectFile<ELFT>::getSymbolFlags(DataRefImpl Symb) const {
EF.getSymbolTableIndex(ESym) == ELF::SHN_COMMON)
Result |= SymbolRef::SF_Common;
if (isExportedToOtherDSO(ESym))
Result |= SymbolRef::SF_Exported;
return Result;
}