esaulenka / ghidra_v850

Ghidra support for Renesas V850 MCUs
MIT License
60 stars 25 forks source link

Fix JMP disp32[reg1] dereference #32

Closed pd0wm closed 1 month ago

pd0wm commented 2 months ago

addr32abs has a dereference causing it to hold the value at the address pointed by disp32 instead of disp32 itself. This would break jump tables.

# JMP disp32[reg1]
:jmp addr32abs[R0004] is op0515=0x037 & R0004; op1616=0 ... & addr32abs {
    local addr = addr32abs + R0004;
    goto [addr];
}
esaulenka commented 1 month ago

I also found it, but forgot to commit, sorry for it.

BTW, where you found this magic with [const] ? I solved it in more ugly way (just removed all these addr32abs).

pd0wm commented 1 month ago

Found it in the upstream v850 code https://github.com/NationalSecurityAgency/ghidra/blob/master/Ghidra/Processors/V850/data/languages/Helpers/Extras.sinc#L38