From 111174be7b14e10ef45c5bd5e57b4b55521f6ff8 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. llvm-svn: 162135 --- llvm/include/llvm/Object/ELF.h | 3 + .../RuntimeDyld/RuntimeDyld.cpp | 27 +++++- .../RuntimeDyld/RuntimeDyldELF.cpp | 91 +++++++++++++++++++ .../RuntimeDyld/RuntimeDyldELF.h | 6 ++ .../RuntimeDyld/RuntimeDyldImpl.h | 2 + llvm/lib/Target/Mips/CMakeLists.txt | 1 + .../Mips/MCTargetDesc/MipsELFObjectWriter.cpp | 8 +- llvm/lib/Target/Mips/MipsTargetMachine.cpp | 1 + llvm/lib/Target/Mips/MipsTargetMachine.h | 6 ++ 9 files changed, 137 insertions(+), 8 deletions(-) diff --git a/llvm/include/llvm/Object/ELF.h b/llvm/include/llvm/Object/ELF.h index 7698441fd1cb..5b95557360b7 100644 --- a/llvm/include/llvm/Object/ELF.h +++ b/llvm/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/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index b4640404f602..a98ddc0e12c3 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/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,