diff options
author | Luís Marques <luismarques@lowrisc.org> | 2019-11-21 22:52:51 +0000 |
---|---|---|
committer | Luís Marques <luismarques@lowrisc.org> | 2019-11-21 22:54:10 +0000 |
commit | b8b57087d3a6954204c6c968fb3de1dc67a87c59 (patch) | |
tree | 1838c27002647284081031fc8d4c51e48a2bf8c8 /llvm/lib/Object/RelocationResolver.cpp | |
parent | 52e377497ddc3aa7178d4fd4c0cda096df4d8a72 (diff) | |
download | bcm5719-llvm-b8b57087d3a6954204c6c968fb3de1dc67a87c59.tar.gz bcm5719-llvm-b8b57087d3a6954204c6c968fb3de1dc67a87c59.zip |
[Object][RISCV] Fix R_RISCV_SET6 and R_RISCV_SUB6 relocations resolution
Summary: These relocations had a suspicious resolution logic, given their name.
This patch makes the resolution match the LLD one, which makes more sense.
Reviewers: asb, lenary, HsiangKai, jrtc27
Reviewed By: HsiangKai
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70396
Diffstat (limited to 'llvm/lib/Object/RelocationResolver.cpp')
-rw-r--r-- | llvm/lib/Object/RelocationResolver.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Object/RelocationResolver.cpp b/llvm/lib/Object/RelocationResolver.cpp index ca89f5671b8..97c69677f58 100644 --- a/llvm/lib/Object/RelocationResolver.cpp +++ b/llvm/lib/Object/RelocationResolver.cpp @@ -363,9 +363,9 @@ static uint64_t resolveRISCV(RelocationRef R, uint64_t S, uint64_t A) { case ELF::R_RISCV_64: return S + RA; case ELF::R_RISCV_SET6: - return (A + (S + RA)) & 0xFF; + return (A & 0xC0) | ((S + RA) & 0x3F); case ELF::R_RISCV_SUB6: - return (A - (S + RA)) & 0xFF; + return (A & 0xC0) | (((A & 0x3F) - (S + RA)) & 0x3F); case ELF::R_RISCV_ADD8: return (A + (S + RA)) & 0xFF; case ELF::R_RISCV_SUB8: |