Handle getting UnknownAddressOrSize or section_end().
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 3 Apr 2014 03:57:03 +0000 (03:57 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 3 Apr 2014 03:57:03 +0000 (03:57 +0000)
These should probably be error conditions.

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

include/llvm/Object/ObjectFile.h

index fa21417027b84802471057514a005a2bc30b775d..8298b63420ba05a40e165effcc4b62f67b622bb1 100644 (file)
@@ -354,12 +354,21 @@ inline error_code SymbolRef::getFileOffset(uint64_t &Result) const {
   uint64_t Address;
   if (error_code EC = getAddress(Address))
     return EC;
+  if (Address == UnknownAddressOrSize) {
+    Result = UnknownAddressOrSize;
+    return object_error::success;
+  }
 
   const ObjectFile *Obj = getObject();
   section_iterator SecI(Obj->section_begin());
   if (error_code EC = getSection(SecI))
     return EC;
 
+  if (SecI == Obj->section_end()) {
+    Result = UnknownAddressOrSize;
+    return object_error::success;
+  }
+
   uint64_t SectionAddress;
   if (error_code EC = SecI->getAddress(SectionAddress))
     return EC;