Skip to content

SuperH: Wrong float parameters shown in function call #8615

@Mc-muffin

Description

@Mc-muffin

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 _SomeFunc

I'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:

  1. Assemble the small snippet at the top, command I used sh-elf-as --isa=sh4 -EL repro.s -o repro.o
  2. Analyze and make _BadFloat a function
  3. Set _SomeFunc to take 2 float args
  4. Set reigster FPSCR_SZ to 0 at _BadFloat
  5. Disable "show unreachable code" if not already
  6. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions