[llvm] r205592 - Add an assert that this is only used with .o files.

Rafael Espindola rafael.espindola at gmail.com
Thu Apr 3 17:31:12 PDT 2014


Author: rafael
Date: Thu Apr  3 19:31:12 2014
New Revision: 205592

URL: http://llvm.org/viewvc/llvm-project?rev=205592&view=rev
Log:
Add an assert that this is only used with .o files.

I am not sure how to get a relocation in a .dylib, but this function would
return the wrong value if passed one.

Modified:
    llvm/trunk/lib/Object/MachOObjectFile.cpp

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=205592&r1=205591&r2=205592&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Apr  3 19:31:12 2014
@@ -784,8 +784,8 @@ void MachOObjectFile::moveRelocationNext
 
 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(Da
 
 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;





More information about the llvm-commits mailing list