diff --git a/lldb/source/Expression/ClangExpressionParser.cpp b/lldb/source/Expression/ClangExpressionParser.cpp index a601b00aa553..7be3784088ac 100644 --- a/lldb/source/Expression/ClangExpressionParser.cpp +++ b/lldb/source/Expression/ClangExpressionParser.cpp @@ -601,10 +601,15 @@ ClangExpressionParser::PrepareForExecution (lldb::addr_t &func_allocation_addr, } llvm::Triple triple(module_ap->getTargetTriple()); llvm::Function *function = module_ap->getFunction (function_name.c_str()); + llvm::Reloc::Model relocModel; + if (triple.isOSBinFormatELF()) + relocModel = llvm::Reloc::Static; + else + relocModel = llvm::Reloc::PIC_; EngineBuilder builder(module_ap.release()); builder.setEngineKind(EngineKind::JIT) .setErrorStr(&error_string) - .setRelocationModel(llvm::Reloc::PIC_) + .setRelocationModel(relocModel) .setJITMemoryManager(jit_memory_manager) .setOptLevel(CodeGenOpt::Less) .setAllocateGVsWithCode(true) diff --git a/lldb/source/Expression/RecordingMemoryManager.cpp b/lldb/source/Expression/RecordingMemoryManager.cpp index 6dc202959f24..2a81fc2d1258 100644 --- a/lldb/source/Expression/RecordingMemoryManager.cpp +++ b/lldb/source/Expression/RecordingMemoryManager.cpp @@ -294,6 +294,8 @@ RecordingMemoryManager::ReportAllocations (llvm::ExecutionEngine &engine) engine.mapSectionAddress((void*)ai->m_local_start, ai->m_remote_start); } + // Trigger re-application of relocations. + engine.finalizeObject(); } bool