https://bugs.llvm.org/show_bug.cgi?id=38133

            Bug ID: 38133
           Summary: Clang miscompiles ARMv7-a assembly module
           Product: clang
           Version: 3.5
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: noloa...@gmail.com
                CC: llvm-bugs@lists.llvm.org

Created attachment 20548
  --> https://bugs.llvm.org/attachment.cgi?id=20548&action=edit
Cryptogams AES source files

I'm testing OpenSSL's asm implementation of AES. It appears the assembly
language file is being miscompiled by Clang resulting in a SIGSEGV. Also see
https://wiki.openssl.org/index.php/Cryptogams_AES.

$ gcc -std=c99 -D_XOPEN_SOURCE=600 -march=armv7-a aes-test.c aes-armv4.S -o
test.exe
$ ./test.exe
66457600 bytes
24.38 mbs
37.17 cpb

$ clang -std=c99 -D_XOPEN_SOURCE=600 -march=armv7-a aes-test.c aes-armv4.S -o
test.exe
$ ./test.exe
Segmentation fault

Under GDB here is the disassembly which should match aes-armv4.S exactly.

(gdb) disass
Dump of assembler code for function _armv4_AES_encrypt:
   0x00010d40 <+0>:     push    {lr}            ; (str lr, [sp, #-4]!)
   0x00010d44 <+4>:     ldm     r11!, {r4, r5, r6, r7}
   0x00010d48 <+8>:     eor     r0, r0, r4
   0x00010d4c <+12>:    ldr     r12, [r11, #224]        ; 0xe0
   0x00010d50 <+16>:    eor     r1, r1, r5
   0x00010d54 <+20>:    eor     r2, r2, r6
   0x00010d58 <+24>:    eor     r3, r3, r7
   0x00010d5c <+28>:    sub     r12, r12, #1
   0x00010d60 <+32>:    mov     lr, #255        ; 0xff
   0x00010d64 <+36>:    and     r7, lr, r0
   0x00010d68 <+40>:    and     r8, lr, r0, lsr #8
   0x00010d6c <+44>:    and     r9, lr, r0, lsr #16
   0x00010d70 <+48>:    lsr     r0, r0, #24
=> 0x00010d74 <+52>:    ldr     r4, [r10, r7, lsl #2]

=========================

The issue affects Clang 3.5, which is the default compiler on this BananaPi
dev-board. I realize it is an old version of the compiler. Since there's a
reproducer I'm going to file the report so modern versions of Clang can be
tested.

I apologize the reporeducer is not minimum. I don't have the ARM asm skills to
reduce it. But it is real code in the wild so it would make sense to ensure it
compiles.

$ clang --version
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: arm-unknown-linux-gnueabihf
Thread model: posix

$ uname -a
Linux bananapi 3.4.113-bananian #9 SMP PREEMPT Sat May 6 12:20:11 UTC 2017
armv7l GNU/Linux

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to