Ghidra is a software reverse engineering (SRE) framework
Fix eBPF CALL operand decoding
Nicolas Ioossc1d96a214049
diff --git a/Ghidra/Processors/eBPF/data/languages/eBPF.sinc b/Ghidra/Processors/eBPF/data/languages/eBPF.sincindex f41b39840e..8333e9da03 100644--- a/Ghidra/Processors/eBPF/data/languages/eBPF.sinc+++ b/Ghidra/Processors/eBPF/data/languages/eBPF.sinc@@ -350,7 +350,7 @@ SysCall: imm is imm { export *[syscall]:1 imm; }call SysCall;}-disp32: reloc is imm [ reloc = inst_next + imm; ] { export *:4 reloc; }+disp32: reloc is imm [ reloc = inst_next + imm * 8; ] { export *:4 reloc; }:CALL disp32 is imm & src=1 & op_alu_jmp_opcode=0x8 & op_alu_jmp_source=0 & op_insn_class=0x5 & disp32 {call disp32;diff --git a/Ghidra/Processors/eBPF/src/main/java/ghidra/app/util/bin/format/elf/relocation/eBPF_ElfRelocationHandler.java b/Ghidra/Processors/eBPF/src/main/java/ghidra/app/util/bin/format/elf/relocation/eBPF_ElfRelocationHandler.javaindex 1990cdfcca..3c76c8f761 100644--- a/Ghidra/Processors/eBPF/src/main/java/ghidra/app/util/bin/format/elf/relocation/eBPF_ElfRelocationHandler.java+++ b/Ghidra/Processors/eBPF/src/main/java/ghidra/app/util/bin/format/elf/relocation/eBPF_ElfRelocationHandler.java@@ -79,7 +79,7 @@ public class eBPF_ElfRelocationHandlerlong instr_next = relocationAddress.add(0x8).getAddressableWordOffset();if (symbol.isFunction()) {new_value = symbolAddr.getAddressableWordOffset();- int offset = (int) (new_value - instr_next);+ int offset = (int) ((new_value - instr_next) / 8);memory.setInt(relocationAddress.add(0x4), offset);}else if (symbol.isSection()) {@@ -96,7 +96,7 @@ public class eBPF_ElfRelocationHandler// according to formula in "kernel.org" docs: https://www.kernel.org/doc/html/latest/bpf/llvm_reloc.htmlint func_sec_offset = (current_imm + 1) * 8;long func_addr = section_start + func_sec_offset;- int offset = (int) (func_addr - instr_next);+ int offset = (int) ((func_addr - instr_next) / 8);memory.setInt(relocationAddress.add(0x4), offset);}// else {