-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Description
Describe the bug
For some reason float values sometimes get wrongly decoded in the decompiled view, here's a small repro snippet:
_BadFloat:
mova .L2,r0
mov.l .L3,r3
fmov.s @r0,fr5
mova .L1,r0
jmp @r3
fmov.s @r0,fr4
.balign 4
.L1:
.float -2.0
.L2:
.float -20000.0
.L3:
.long _SomeFuncI'd expect the decompiler output to look something like:
void _BadFloat(void)
{
_SomeFunc(-2.0,-20000.0);
return;
}However it currently looks like this:
void _BadFloat(void)
{
_SomeFunc(-20000.0,-20000.0);
return;
}Somewhat related, I noticed that for SH Little Endian the float argument registers are assigned odd-first (so param_1->fr5 & param_2->fr4) which, at least in the binary that had a similar snippet, is not the case (param_1->fr4 & param_2->fr5)
To Reproduce
Steps to reproduce the behavior:
- Assemble the small snippet at the top, command I used
sh-elf-as --isa=sh4 -EL repro.s -o repro.o - Analyze and make
_BadFloata function - Set
_SomeFuncto take 2floatargs - Set reigster
FPSCR_SZto 0 at_BadFloat - Disable "show unreachable code" if not already
- See the bug in action
Expected behavior
I'd expect the correct values to show.
Screenshots
If applicable, add screenshots to help explain your problem.
Attachments
If applicable, please attach any files that caused problems or log files generated by the software.
Environment (please complete the following information):
- OS: Windows 11 24H2
- Java Version: 23.0.1
- Ghidra Version: 11.4.2
- Ghidra Origin: GitHub Releases
Additional context
N/A