Convert getFileOffset to getOffset and move it to its only user.
[oota-llvm.git] / include / llvm / Object / ObjectFile.h
index 157a32b8c6f9150cebb668a553a81e1d4870fe49..3533669b8b8652ecade1c2e54903f1cb38fc4e43 100644 (file)
@@ -145,7 +145,6 @@ public:
   /// Returns the symbol virtual address (i.e. address at which it will be
   /// mapped).
   error_code getAddress(uint64_t &Result) const;
-  error_code getFileOffset(uint64_t &Result) const;
   /// @brief Get the alignment of this symbol as the actual value (not log 2).
   error_code getAlignment(uint32_t &Result) const;
   error_code getSize(uint64_t &Result) const;
@@ -348,42 +347,6 @@ inline error_code SymbolRef::getAddress(uint64_t &Result) const {
   return getObject()->getSymbolAddress(getRawDataRefImpl(), Result);
 }
 
-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;
-
-  uint64_t OffsetInSection = Address - SectionAddress;
-
-  StringRef SecContents;
-  if (error_code EC = SecI->getContents(SecContents))
-    return EC;
-
-  // FIXME: this is a hack.
-  uint64_t SectionOffset = (uint64_t)SecContents.data() - (uint64_t)Obj->base();
-
-  Result = SectionOffset + OffsetInSection;
-  return object_error::success;
-}
-
 inline error_code SymbolRef::getAlignment(uint32_t &Result) const {
   return getObject()->getSymbolAlignment(getRawDataRefImpl(), Result);
 }