Convert getFileOffset to getOffset and move it to its only user.

We normally don't drop functions from the C API's, but in this case I think we
can:

* The old implementation of getFileOffset was fairly broken
* The introduction of LLVMGetSymbolFileOffset was itself a C api breaking
  change as it removed LLVMGetSymbolOffset.
* It is an incredibly specialized use case. The only reason MCJIT needs it is
  because of its odd position of being a dynamic linker of .o files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206750 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-04-21 13:45:32 +00:00
parent d329c79f16
commit 7426771280
6 changed files with 34 additions and 69 deletions

View 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);
}