Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3707 corrected array index bug in RISCV_ElfRelocationContext

ghidra10233f35d1fe4
diff --git a/Ghidra/Processors/RISCV/src/main/java/ghidra/app/util/bin/format/elf/relocation/RISCV_ElfRelocationContext.java b/Ghidra/Processors/RISCV/src/main/java/ghidra/app/util/bin/format/elf/relocation/RISCV_ElfRelocationContext.java
index a1a453f546..caf8234f41 100644
--- a/Ghidra/Processors/RISCV/src/main/java/ghidra/app/util/bin/format/elf/relocation/RISCV_ElfRelocationContext.java
+++ b/Ghidra/Processors/RISCV/src/main/java/ghidra/app/util/bin/format/elf/relocation/RISCV_ElfRelocationContext.java
@@ -71,7 +71,7 @@ class RISCV_ElfRelocationContext extends ElfRelocationContext {
--relIndex;
}
// look for hi20 relocation
- while (relIndex < relocations.length && relocations[relIndex - 1].getOffset() == symValue) {
+ while (relIndex < relocations.length && relocations[relIndex].getOffset() == symValue) {
int type = relocations[relIndex].getType();
if ((type == RISCV_ElfRelocationConstants.R_RISCV_PCREL_HI20) ||
(type == RISCV_ElfRelocationConstants.R_RISCV_GOT_HI20)) {