aboutsummaryrefslogtreecommitdiff
path: root/sim/bpf
diff options
context:
space:
mode:
authorJose E. Marchesi <jose.marchesi@oracle.com>2023-07-26 11:44:20 +0200
committerJose E. Marchesi <jose.marchesi@oracle.com>2023-07-26 11:44:20 +0200
commit4200337219274445a17e16d18d3c113f555cc786 (patch)
tree2b0111b3400af2513d9d89736d58a1f7e5d9c2c1 /sim/bpf
parent04896832b2e79c042ea1f510b0458ac342512152 (diff)
downloadgdb-4200337219274445a17e16d18d3c113f555cc786.zip
gdb-4200337219274445a17e16d18d3c113f555cc786.tar.gz
gdb-4200337219274445a17e16d18d3c113f555cc786.tar.bz2
bpf: fix neg and neg32 BPF instructions in simulator
This patch fixes the semantics of the neg and neg32 BPF instructions in the simulator, and also updates the corresponding tests accordingly. Tested in target bpf-unknown-none.
Diffstat (limited to 'sim/bpf')
-rw-r--r--sim/bpf/bpf-sim.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sim/bpf/bpf-sim.c b/sim/bpf/bpf-sim.c
index 8d3a28e..5e01dde 100644
--- a/sim/bpf/bpf-sim.c
+++ b/sim/bpf/bpf-sim.c
@@ -728,7 +728,7 @@ execute (SIM_CPU *cpu, struct bpf_insn *insn)
break;
case BPF_INSN_NEGR:
BPF_TRACE ("BPF_INSN_NEGR\n");
- bpf_regs[insn->dst] = - (int64_t) bpf_regs[insn->src];
+ bpf_regs[insn->dst] = - (int64_t) bpf_regs[insn->dst];
break;
case BPF_INSN_NEGI:
BPF_TRACE ("BPF_INSN_NEGI\n");
@@ -865,7 +865,7 @@ execute (SIM_CPU *cpu, struct bpf_insn *insn)
break;
case BPF_INSN_NEG32R:
BPF_TRACE ("BPF_INSN_NEG32R\n");
- bpf_regs[insn->dst] = (uint32_t) (- (int32_t) bpf_regs[insn->src]);
+ bpf_regs[insn->dst] = (uint32_t) (- (int32_t) bpf_regs[insn->dst]);
break;
case BPF_INSN_NEG32I:
BPF_TRACE ("BPF_INSN_NEG32I\n");