[JITLink][RISCV] ADD/SUB relocs: read value from working memory
authorJob Noorman <jnoorman@igalia.com>
Fri, 7 Apr 2023 07:47:41 +0000 (09:47 +0200)
committerJob Noorman <jnoorman@igalia.com>
Fri, 7 Apr 2023 07:47:49 +0000 (09:47 +0200)
commit6a14a56aaf77c615f9e4ab77b35029b0e6c8909f
tree5cd3726ca134eb177d30e6f4c2fc1303efcf0b8d
parentf1975216846ed69d608e669c37efa5ee0e16276e
[JITLink][RISCV] ADD/SUB relocs: read value from working memory

The various ADD/SUB relocations work by reading the current value the
relocation points to, transforming it, and then writing it back to
memory. While the current implementation writes the value back to
working memory, it reads the current value from the execution address of
the relocation. This causes at least wrong results, but often crashes,
when the addresses of working memory are not equal to execution
addresses. This patch fixes this by reading the current value from
working memory.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D147693
llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp
llvm/test/ExecutionEngine/JITLink/RISCV/riscv_reloc_add.s