mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-20 10:24:12 +00:00
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:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user