aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/Arch/RISCV.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2022-10-15 16:01:12 +0000
committerDimitry Andric <dim@FreeBSD.org>2022-10-15 16:01:12 +0000
commit6befc758a38754c930daf51e1094f210afb70f25 (patch)
tree5b8466e9c648c3915ad18896362cd43885deca63 /lld/ELF/Arch/RISCV.cpp
parent7f04c68256951282ce8e0136371ef97410ed7db6 (diff)
Vendor import of llvm-project branch release/15.x llvmorg-15.0.2-0-g4bd3f3759259.vendor/llvm-project/llvmorg-15.0.2-0-g4bd3f3759259
Diffstat (limited to 'lld/ELF/Arch/RISCV.cpp')
-rw-r--r--lld/ELF/Arch/RISCV.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 8fca1a686a79..56a516f9cdc1 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -750,12 +750,13 @@ void elf::riscvFinalizeRelax(int passes) {
p += size;
// For R_RISCV_ALIGN, we will place `offset` in a location (among NOPs)
- // to satisfy the alignment requirement. If `remove` is a multiple of 4,
- // it is as if we have skipped some NOPs. Otherwise we are in the middle
- // of a 4-byte NOP, and we need to rewrite the NOP sequence.
+ // to satisfy the alignment requirement. If both `remove` and r.addend
+ // are multiples of 4, it is as if we have skipped some NOPs. Otherwise
+ // we are in the middle of a 4-byte NOP, and we need to rewrite the NOP
+ // sequence.
int64_t skip = 0;
if (r.type == R_RISCV_ALIGN) {
- if (remove % 4 != 0) {
+ if (remove % 4 || r.addend % 4) {
skip = r.addend - remove;
int64_t j = 0;
for (; j + 4 <= skip; j += 4)