From owner-freebsd-arm@freebsd.org Thu Oct 22 11:22:58 2015 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 79147A1B2E9 for ; Thu, 22 Oct 2015 11:22:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4BE3A1720 for ; Thu, 22 Oct 2015 11:22:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id t9MBMwEv013670 for ; Thu, 22 Oct 2015 11:22:58 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-arm@FreeBSD.org Subject: [Bug 203950] clang mis-assembles immediate operands Date: Thu, 22 Oct 2015 11:22:58 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: arm X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: peterj@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-arm@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Oct 2015 11:22:58 -0000 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.