Don't lookup an object symbol name in the module.

Instead, walk the obj symbol list in parallel to find the GV. This shouldn't
change anything on ELF where global symbols are not mangled, but it is a step
toward supporting other object formats.

Gold itself is ELF only, but bfd ld supports COFF and the logic in the gold
plugin could be reused on lld.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223780 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-12-09 16:13:59 +00:00
parent de0cdb0890
commit 4f20ed1c36
3 changed files with 34 additions and 27 deletions

View File

@ -116,7 +116,7 @@ IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod)
IRObjectFile::~IRObjectFile() {
}
static const GlobalValue *getGV(DataRefImpl &Symb) {
static GlobalValue *getGV(DataRefImpl &Symb) {
if ((Symb.p & 3) == 3)
return nullptr;
@ -235,10 +235,7 @@ uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const {
return Res;
}
const GlobalValue *IRObjectFile::getSymbolGV(DataRefImpl Symb) const {
const GlobalValue *GV = getGV(Symb);
return GV;
}
GlobalValue *IRObjectFile::getSymbolGV(DataRefImpl Symb) { return getGV(Symb); }
basic_symbol_iterator IRObjectFile::symbol_begin_impl() const {
Module::const_iterator I = M->begin();