<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Clang miscompiles ARMv7-a assembly module"
href="https://bugs.llvm.org/show_bug.cgi?id=38133">38133</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Clang miscompiles ARMv7-a assembly module
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.5
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>noloader@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=20548" name="attach_20548" title="Cryptogams AES source files">attachment 20548</a> <a href="attachment.cgi?id=20548&action=edit" title="Cryptogams AES source files">[details]</a></span>
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
<a href="https://wiki.openssl.org/index.php/Cryptogams_AES">https://wiki.openssl.org/index.php/Cryptogams_AES</a>.
$ 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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>