Skip to content

Commit 5728b6d

Browse files
author
git apple-llvm automerger
committed
Merge commit '915c84b1480b' from llvm.org/main into next
2 parents 5996ede + 915c84b commit 5728b6d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lldb/source/Expression/IRExecutionUnit.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "llvm/IR/DiagnosticInfo.h"
1616
#include "llvm/IR/LLVMContext.h"
1717
#include "llvm/IR/Module.h"
18+
#include "llvm/Support/CodeGen.h"
1819
#include "llvm/Support/SourceMgr.h"
1920
#include "llvm/Support/raw_ostream.h"
2021

@@ -300,10 +301,13 @@ void IRExecutionUnit::GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
300301
llvm::EngineBuilder builder(std::move(m_module_up));
301302
llvm::Triple triple(m_module->getTargetTriple());
302303

304+
// PIC needed for ELF to avoid generating 32-bit relocations (which overflow
305+
// if the object is loaded into high memory).
306+
bool want_pic = triple.isOSBinFormatMachO() || triple.isOSBinFormatELF();
307+
303308
builder.setEngineKind(llvm::EngineKind::JIT)
304309
.setErrorStr(&error_string)
305-
.setRelocationModel(triple.isOSBinFormatMachO() ? llvm::Reloc::PIC_
306-
: llvm::Reloc::Static)
310+
.setRelocationModel(want_pic ? llvm::Reloc::PIC_ : llvm::Reloc::Static)
307311
.setMCJITMemoryManager(std::make_unique<MemoryManager>(*this))
308312
.setOptLevel(llvm::CodeGenOptLevel::Less);
309313

0 commit comments

Comments
 (0)