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

@ -36,7 +36,10 @@ public:
std::error_code printSymbolName(raw_ostream &OS,
DataRefImpl Symb) const override;
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
const GlobalValue *getSymbolGV(DataRefImpl Symb) const;
GlobalValue *getSymbolGV(DataRefImpl Symb);
const GlobalValue *getSymbolGV(DataRefImpl Symb) const {
return const_cast<IRObjectFile *>(this)->getSymbolGV(Symb);
}
basic_symbol_iterator symbol_begin_impl() const override;
basic_symbol_iterator symbol_end_impl() const override;
@ -46,6 +49,7 @@ public:
Module &getModule() {
return *M;
}
std::unique_ptr<Module> takeModule() { return std::move(M); }
static inline bool classof(const Binary *v) {
return v->isIR();