Add an assert that this is only used with .o files.
authorRafael Espindola <rafael.espindola@gmail.com>
Fri, 4 Apr 2014 00:31:12 +0000 (00:31 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Fri, 4 Apr 2014 00:31:12 +0000 (00:31 +0000)
I am not sure how to get a relocation in a .dylib, but this function would
return the wrong value if passed one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205592 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Object/MachOObjectFile.cpp

index 7ce62eb2a4476c8edc7838a63b0675638676f514..ce4b3d5d0c1b6e160ecfda1596ca19d4a5cbebb6 100644 (file)
@@ -784,8 +784,8 @@ void MachOObjectFile::moveRelocationNext(DataRefImpl &Rel) const {
 
 error_code
 MachOObjectFile::getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const {
-  MachO::any_relocation_info RE = getRelocation(Rel);
-  uint64_t Offset = getAnyRelocationAddress(RE);
+  uint64_t Offset;
+  getRelocationOffset(Rel, Offset);
 
   DataRefImpl Sec;
   Sec.d.a = Rel.d.a;
@@ -797,6 +797,8 @@ MachOObjectFile::getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const {
 
 error_code MachOObjectFile::getRelocationOffset(DataRefImpl Rel,
                                                 uint64_t &Res) const {
+  assert(getHeader().filetype == MachO::MH_OBJECT &&
+         "Only implemented for MH_OBJECT");
   MachO::any_relocation_info RE = getRelocation(Rel);
   Res = getAnyRelocationAddress(RE);
   return object_error::success;