[llvm-dev] [JITLink] How to allocate correct target memory in small code model

Lang Hames via llvm-dev llvm-dev at lists.llvm.org
Thu Jul 22 15:42:35 PDT 2021


Hi Stephen,

You'll need to write a custom JITLinkMemoryManager that allocates memory in
the low 2GiB for this to work.

See e.g.
https://github.com/llvm/llvm-project/blob/68d6278a6e9879794850e879a036774544b49e99/llvm/tools/llvm-jitlink/llvm-jitlink.cpp#L358
or
https://github.com/llvm/llvm-project/blob/bf281f364757d6af8d9d8456f26d334d1eeaf575/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp#L20

While it's desirable to support all code models, it sounds like medium and
compact would be more generally useful. Do you know what the default code
model is for RISCV64?

-- Lang.



On Thu, Jul 22, 2021 at 5:43 PM 陆旭凡 <luxufan981014 at gmail.com> wrote:

> Hi All,
> In RISCV64, if the compiler compile with small code model (mcmodel=medlow)(
> https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md#code-models),
> the symbol address need to at the lower 2GiB of the RISCV64 address space.
> However, when the jitlink allocate target memory, it will allocate to a
> address out of range of the lower 2GiB of the RISCV64 address space. How
> can I solve this problem ?
> Regards,
> Stephen.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210723/47ac61a1/attachment.html>


More information about the llvm-dev mailing list