From b889e0cd2fea4afee623d5be603b912b955a2eca Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Fri, 17 Aug 2012 21:28:04 +0000 Subject: [PATCH] Correct MCJIT functionality for MIPS32 architecture. No new tests are added. All tests in ExecutionEngine/MCJIT that have been failing pass after this patch is applied (when "make check" is done on a mips board). Patch by Petar Jovanovic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162135 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 3 + .../RuntimeDyld/RuntimeDyld.cpp | 27 +++++- .../RuntimeDyld/RuntimeDyldELF.cpp | 91 +++++++++++++++++++ .../RuntimeDyld/RuntimeDyldELF.h | 6 ++ .../RuntimeDyld/RuntimeDyldImpl.h | 2 + lib/Target/Mips/CMakeLists.txt | 1 + .../Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 8 +- lib/Target/Mips/MipsTargetMachine.cpp | 1 + lib/Target/Mips/MipsTargetMachine.h | 6 ++ 9 files changed, 137 insertions(+), 8 deletions(-) diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 7698441fd1c..5b95557360b 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -2044,6 +2044,9 @@ unsigned ELFObjectFile::getArch() const { return Triple::arm; case ELF::EM_HEXAGON: return Triple::hexagon; + case ELF::EM_MIPS: + return (target_endianness == support::little) ? + Triple::mipsel : Triple::mips; default: return Triple::UnknownArch; } diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index b4640404f60..a98ddc0e12c 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -108,7 +108,8 @@ bool RuntimeDyldImpl::loadObject(const MemoryBuffer *InputBuffer) { CommonSymbols[*i] = Size; } else { if (SymType == object::SymbolRef::ST_Function || - SymType == object::SymbolRef::ST_Data) { + SymType == object::SymbolRef::ST_Data || + SymType == object::SymbolRef::ST_Unknown) { uint64_t FileOffset; StringRef SectionData; section_iterator si = obj->end_sections(); @@ -333,15 +334,31 @@ void RuntimeDyldImpl::addRelocationForSymbol(const RelocationEntry &RE, } uint8_t *RuntimeDyldImpl::createStubFunction(uint8_t *Addr) { - // TODO: There is only ARM far stub now. We should add the Thumb stub, - // and stubs for branches Thumb - ARM and ARM - Thumb. if (Arch == Triple::arm) { + // TODO: There is only ARM far stub now. We should add the Thumb stub, + // and stubs for branches Thumb - ARM and ARM - Thumb. uint32_t *StubAddr = (uint32_t*)Addr; *StubAddr = 0xe51ff004; // ldr pc,