summaryrefslogtreecommitdiff
path: root/lib/Object
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-04-02 22:52:46 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-04-02 22:52:46 +0000
commit5a61b72493a700229bac6cf87366188b039c6271 (patch)
treebc09e9609917636e9efe8bb94f529e47cf195405 /lib/Object
parentd7e2a4815398dcaf7111c7ab0e4df52afd93a880 (diff)
downloadllvm-5a61b72493a700229bac6cf87366188b039c6271.tar.gz
llvm-5a61b72493a700229bac6cf87366188b039c6271.tar.bz2
llvm-5a61b72493a700229bac6cf87366188b039c6271.tar.xz
Fix a nomenclature error in llvm-nm.
What llvm-nm prints depends on the file format. On ELF for example, if the file is relocatable, it prints offsets. If it is not, it prints addresses. Since it doesn't really need to care what it is that it is printing, use the generic term value. Fix or implement getSymbolValue to keep llvm-nm working. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205479 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/COFFObjectFile.cpp11
-rw-r--r--lib/Object/MachOObjectFile.cpp3
2 files changed, 11 insertions, 3 deletions
diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp
index 43913e4485..2784f5c444 100644
--- a/lib/Object/COFFObjectFile.cpp
+++ b/lib/Object/COFFObjectFile.cpp
@@ -253,8 +253,15 @@ error_code COFFObjectFile::getSymbolSection(DataRefImpl Ref,
}
error_code COFFObjectFile::getSymbolValue(DataRefImpl Ref,
- uint64_t &Val) const {
- report_fatal_error("getSymbolValue unimplemented in COFFObjectFile");
+ uint64_t &Result) const {
+ const coff_symbol *Symb = toSymb(Ref);
+
+ if (Symb->SectionNumber == COFF::IMAGE_SYM_UNDEFINED)
+ Result = UnknownAddressOrSize;
+ else
+ Result = Symb->Value;
+
+ return object_error::success;
}
void COFFObjectFile::moveSectionNext(DataRefImpl &Ref) const {
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index 6955ef090a..df4e044e71 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -633,7 +633,8 @@ MachOObjectFile::getSymbolSection(DataRefImpl Symb,
error_code MachOObjectFile::getSymbolValue(DataRefImpl Symb,
uint64_t &Val) const {
- report_fatal_error("getSymbolValue unimplemented in MachOObjectFile");
+ // In MachO both relocatable and non-relocatable objects have addresses.
+ return getSymbolAddress(Symb, Val);
}
void MachOObjectFile::moveSectionNext(DataRefImpl &Sec) const {