Add a SymbolRef::getValue.

This returns either the symbol offset or address. Since it is not defined which
one, it never has to lookup the section and so never fails.

I will add users in the next commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240569 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-06-24 19:11:10 +00:00
parent 234c5890e7
commit 9fa0ab3335
6 changed files with 59 additions and 27 deletions
+10 -7
View File
@@ -370,14 +370,17 @@ std::error_code MachOObjectFile::getIndirectName(DataRefImpl Symb,
return std::error_code();
}
std::error_code MachOObjectFile::getSymbolAddress(DataRefImpl Symb,
uint64_t &Res) const {
uint64_t NValue = getNValue(Symb);
MachO::nlist_base Entry = getSymbolTableEntryBase(this, Symb);
uint64_t MachOObjectFile::getSymbolValue(DataRefImpl Sym) const {
uint64_t NValue = getNValue(Sym);
MachO::nlist_base Entry = getSymbolTableEntryBase(this, Sym);
if ((Entry.n_type & MachO::N_TYPE) == MachO::N_UNDF && NValue == 0)
Res = UnknownAddress;
else
Res = NValue;
return UnknownAddress;
return NValue;
}
std::error_code MachOObjectFile::getSymbolAddress(DataRefImpl Sym,
uint64_t &Res) const {
Res = getSymbolValue(Sym);
return std::error_code();
}