https://bugs.kde.org/show_bug.cgi?id=360425

            Bug ID: 360425
           Summary: arm64 unsupported instruction ldpsw
           Product: valgrind
           Version: unspecified
          Platform: Other
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: vex
          Assignee: jsew...@acm.org
          Reporter: m...@redhat.com

The following program (derived from a gcc test case):

int arr[4][4] = {{0, 1, 1, -1}, {-1, -1, 1, -1}, {1, -1, 1, 1}, {1, -1, -1,
0}};
long long
foo ()
{
  long long ll = 0;
  ll += arr[1][0];
  ll += arr[1][1];
  return ll;
}

int main () { return foo () > 0 ? 1 : 0; }

Will compile with gcc 4.8.3 -O2 to:

0000000000400450 <main>:
  400450:       90000100        adrp    x0, 420000 <_GLOBAL_OFFSET_TABLE_+0x28>
  400454:       91008000        add     x0, x0, #0x20
  400458:       b9801001        ldrsw   x1, [x0,#16]
  40045c:       b9801400        ldrsw   x0, [x0,#20]
  400460:       8b000020        add     x0, x1, x0
  400464:       eb1f001f        cmp     x0, xzr
  400468:       1a9fd7e0        cset    w0, gt
  40046c:       d65f03c0        ret

but with gcc 5.3 -O2 it will generate:

0000000000400420 <main>:
  400420:       90000080        adrp    x0, 410000 <__FRAME_END__+0xf850>
  400424:       9127a000        add     x0, x0, #0x9e8
  400428:       69420001        ldpsw   x1, x0, [x0,#16]
  40042c:       8b000020        add     x0, x1, x0
  400430:       eb1f001f        cmp     x0, xzr
  400434:       1a9fd7e0        cset    w0, gt
  400438:       d65f03c0        ret
  40043c:       d503201f        nop

valgrind doesn't recognize te ldpsw instruction:

ARM64 front end: load_store
disInstr(arm64): unhandled instruction 0x69420001
disInstr(arm64): 0110'1001 0100'0010 0000'0000 0000'0001
==17992== valgrind: Unrecognised instruction at address 0x400428.
==17992==    at 0x400428: foo (foo.c:7)
==17992==    by 0x400428: main (foo.c:12)
==17992== Your program just tried to execute an instruction that Valgrind
==17992== did not recognise.  There are two possible reasons for this.
==17992== 1. Your program has a bug and erroneously jumped to a non-code
==17992==    location.  If you are running Memcheck and you just saw a
==17992==    warning about a bad jump, it's probably your program's fault.
==17992== 2. The instruction is legitimate but Valgrind doesn't handle it,
==17992==    i.e. it's Valgrind's fault.  If you think this is the case or
==17992==    you are not sure, please let us know and we'll try to fix it.
==17992== Either way, Valgrind will now raise a SIGILL signal which will
==17992== probably kill your program.
==17992== 
==17992== Process terminating with default action of signal 4 (SIGILL)
==17992==  Illegal opcode at address 0x400428
==17992==    at 0x400428: foo (foo.c:7)
==17992==    by 0x400428: main (foo.c:12)


Reproducible: Always

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to