Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem disassembling fldt instruction #4

Closed
lukemaurer opened this issue Jan 31, 2019 · 1 comment
Closed

Problem disassembling fldt instruction #4

lukemaurer opened this issue Jan 31, 2019 · 1 comment

Comments

@lukemaurer
Copy link
Contributor

(This came up in Refurbish, but it's almost certainly in Flexdis.)

The musl implementation of floating-point formatting has the instructions

  40103e:       db ac 24 90 1d 00 00    fldt   0x1d90(%rsp)
  401045:       48 8d 05 f8 33 00 00    lea    0x33f8(%rip),%rax        # 404444 <_fini+0xa0>

Refurbish rewrites them as

  40103e:       db 2c 24                fldt   (%rsp)
  401041:       90                      nop
  401042:       1d 00 00 48 8d          sbb    $0x8d480000,%eax
  401047:       05 f8 33 00 00          add    $0x33f8,%eax

What seems to be happening is that the ac in fldt gets misread as 2c, which shortens the instruction, causing the next few instructions to get mangled.

You can test this by adding a line to test-fp.c in the Refurbish tests:

int main() {
  entry();
  printf("%.9f", -0.169075164); /* new line */
  return 0;
}

This will cause a segfault when someone tries to access the nonsense pointer.

@travitch
Copy link
Contributor

Confirmed as a problem in either the disassembler or re-assembler. I have a test case in the roundtrip tests that exhibit the problem (not checked in yet since I don't have a fix yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants