<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/71963>71963</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Assertion failure in RuntimeDyldELF::resolveAArch64Relocation
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
MikaelSmith
</td>
</tr>
</table>
<pre>
Using MCJIT, several projects have run into failures like
```
lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:400: void llvm::RuntimeDyldELF::resolveAArch64Relocation(const llvm::SectionEntry&, uint64_t, uint64_t, uint32_t, int64_t): Assertion `isInt<33>(Result) && "overflow check failed for relocation"' failed.
```
at https://github.com/llvm/llvm-project/blob/llvmorg-17.0.4/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp#L518.
* Impala runs into this with LLVM 5.0.1 ([IMPALA-11542](https://issues.apache.org/jira/browse/IMPALA-11542)).
* Numba and Julia have also run into it on newer versions of LLVM (at least 13): https://discourse.llvm.org/t/llvm-rtdyld-aarch64-abi-relocation-restrictions/74616.
I believe this issue is unaddressed in newer releases. As summarized [here](https://discourse.llvm.org/t/llvm-rtdyld-aarch64-abi-relocation-restrictions/74616), MCJIT with the SectionMemoryManager or TrivialMemoryManager allocates sections in separate memory allocation calls. On systems with lots of memory, this can wind up allocating them in different locations in a way that violates AArch64 ABI restrictions (that text and GOT segments must be within 4GB of each other). https://github.com/llvm/llvm-project/commit/574713c3076c11a5677f554ab132d1324be9cb00 is insufficient to fix the issue (tested it in Impala).
RTDyldMemoryManager provides needsToReserveAllocationSpace/reserveAllocationSpace. One proposal is to reserve all necessary memory in a single allocation, ensuring it's one contiguous block. This puts slightly stricter requirements on contiguous memory, which may not be suitable for memory-constrained environments, but for most use-cases it switches from 2-3 allocations to 1 larger allocation. This approach seems to address the issue in Impala.
</pre>
<img width="1px" height="1px" alt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