Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Oct 2015 11:22:58 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-arm@FreeBSD.org
Subject:   [Bug 203950] clang mis-assembles immediate operands
Message-ID:  <bug-203950-7@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203950

            Bug ID: 203950
           Summary: clang mis-assembles immediate operands
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: arm
          Assignee: freebsd-arm@FreeBSD.org
          Reporter: peterj@FreeBSD.org

Created attachment 162344
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=162344&action=edit
ARM AES code generated by OpenSSL perl script.

Whilst experimenting with the OpenSSL ARM assembler code, I discovered that
clang is incorrectly handling immediate operands.

This is using:
% cc -c aes_arm.s
% objdump -d aes_arm.o | less
% cc -v
FreeBSD clang version 3.6.1 (tags/RELEASE_361/final 237755) 20150525
Target: armv6--freebsd11.0-gnueabihf
Thread model: posix

The source code (attached) includes:
AES_encrypt:
        sub     r3,pc,#8                @ AES_encrypt
        stmdb   sp!,{r1,r4-r12,lr}
        mov     r12,r0          @ inp
        mov     r11,r2
        sub     r10,r3,#AES_encrypt-AES_Te      @ Te

#AES_encrypt-AES_Te is 1344 or 0x540.  clang compiles this subtraction to
0xe243a540 - which decompiles to:
e243a540        sub     sl, r3, #268435456      ; 0x10000000
because the 12-bit immediate field is not a direct binary number but is a 4-bit
rotation followed by a 8-bit binary value.  A correct value for this field
would be (eg) 0xe54.  Note that as(1) gets compiles the instruction to:
e243ad15        sub     sl, r3, #1344   ; 0x540

-- 
You are receiving this mail because:
You are the assignee for the bug.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-203950-7>