mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-15 21:24:00 +00:00
MC CFG: Add "dynamic disassembly" support to MCObjectDisassembler.
It can now disassemble code in situations where the effective load address is different than the load address declared in the object file. This happens for PIC, hence "dynamic". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188884 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -44,7 +44,7 @@ uint64_t MCObjectDisassembler::getEntrypoint() {
|
||||
if (Name == "main" || Name == "_main") {
|
||||
uint64_t Entrypoint;
|
||||
SI->getAddress(Entrypoint);
|
||||
return Entrypoint;
|
||||
return getEffectiveLoadAddr(Entrypoint);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@ -58,6 +58,14 @@ ArrayRef<uint64_t> MCObjectDisassembler::getStaticExitFunctions() {
|
||||
return ArrayRef<uint64_t>();
|
||||
}
|
||||
|
||||
uint64_t MCObjectDisassembler::getEffectiveLoadAddr(uint64_t Addr) {
|
||||
return Addr;
|
||||
}
|
||||
|
||||
uint64_t MCObjectDisassembler::getOriginalLoadAddr(uint64_t Addr) {
|
||||
return Addr;
|
||||
}
|
||||
|
||||
MCModule *MCObjectDisassembler::buildEmptyModule() {
|
||||
MCModule *Module = new MCModule;
|
||||
Module->Entrypoint = getEntrypoint();
|
||||
@ -90,6 +98,7 @@ void MCObjectDisassembler::buildSectionAtoms(MCModule *Module) {
|
||||
uint64_t SecSize; SI->getSize(SecSize);
|
||||
if (StartAddr == UnknownAddressOrSize || SecSize == UnknownAddressOrSize)
|
||||
continue;
|
||||
StartAddr = getEffectiveLoadAddr(StartAddr);
|
||||
|
||||
StringRef Contents; SI->getContents(Contents);
|
||||
StringRefMemoryObject memoryObject(Contents, StartAddr);
|
||||
@ -170,6 +179,7 @@ void MCObjectDisassembler::buildCFG(MCModule *Module) {
|
||||
if (SymType == SymbolRef::ST_Function) {
|
||||
uint64_t SymAddr;
|
||||
SI->getAddress(SymAddr);
|
||||
SymAddr = getEffectiveLoadAddr(SymAddr);
|
||||
Calls.insert(SymAddr);
|
||||
Splits.insert(SymAddr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user