From owner-svn-src-head@FreeBSD.ORG Sat Jan 3 08:34:42 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CBFAE4CD; Sat, 3 Jan 2015 08:34:42 +0000 (UTC) Received: from mail107.syd.optusnet.com.au (mail107.syd.optusnet.com.au [211.29.132.53]) by mx1.freebsd.org (Postfix) with ESMTP id 5BCA32D5C; Sat, 3 Jan 2015 08:34:41 +0000 (UTC) Received: from c122-106-147-133.carlnfd1.nsw.optusnet.com.au (c122-106-147-133.carlnfd1.nsw.optusnet.com.au [122.106.147.133]) by mail107.syd.optusnet.com.au (Postfix) with ESMTPS id C549CD4732D; Sat, 3 Jan 2015 19:34:26 +1100 (AEDT) Date: Sat, 3 Jan 2015 19:34:25 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ian Lepore Subject: Re: svn commit: r276596 - in head/sys/arm: arm include In-Reply-To: <201501022346.t02NkRgd032775@svn.freebsd.org> Message-ID: <20150103184754.H1159@besplex.bde.org> References: <201501022346.t02NkRgd032775@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=Qdxf4Krv c=1 sm=1 tr=0 a=7NqvjVvQucbO2RlWB8PEog==:117 a=PO7r1zJSAAAA:8 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=TkTTPzHaAAAA:8 a=bcXWhih2kQSunO1Cnb4A:9 a=CjuIK1q_8ugA:10 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Jan 2015 08:34:43 -0000 On Fri, 2 Jan 2015, Ian Lepore wrote: > Log: > Fix alignment directives in arm asm code after clang 3.5 import. > > The ancient gas we've been using interprets .align 0 as align to the > minimum required alignment for the current section. Clang's integrated > assembler interprets it as align to a byte boundary. Fortunately both > assemblers interpret a non-zero value as align to 2^N so just make sure > we have appropriate non-zero values everywhere. > Modified: head/sys/arm/arm/bcopyinout.S > ============================================================================== > --- head/sys/arm/arm/bcopyinout.S Fri Jan 2 23:27:16 2015 (r276595) > +++ head/sys/arm/arm/bcopyinout.S Fri Jan 2 23:46:26 2015 (r276596) > @@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$"); > #else > > .text > - .align 0 > + .align 2 This is still confusing. Doesn't clang on arm support .p2align? On x86, '.align N' means align to boundary N, where N must be a power of 2. Alignment to boundary 2**N can be done by expanding 2**N literally or using '.p2align N'. The latter is better, and is always (?) used in FreeBSD sources. It was also generated by gcc-3.3.3. gcc-4 broke this and generates .align, and clang is bug for bug compatible with the newer gcc. .align used to mean power of 2 alignment on x86 too, but gas changed this in 1995, or at least introduced .p2align then: X Wed Apr 26 15:54:10 1995 Ken Raeburn X X Support for more portable alignment handling in assembly code, X based on patches from Bryan Ford : X * read.c (potable): Added balign and p2align, for aligning by X bytes or powers of two independent of what ".align" does for a X given target. X * doc/as.texinfo: Document them. Everything should have, and still should, use .p2align for portability and anti-confusion. FreeBSD on x86 didn't catch up with this change until 1997. The fix is disguised in some ELF changes in rev.1.16. It is also a style bug to hard-code .align statements. x86 is missing this style bug, so only about 3 lines in this file needed to be changed to keep up with the change in gas. I couldn't find when gas changed the default, and suspect that it was conditional on ELF. Other arches never supported aout, but they apparently ended up with the confusing aout semantics for .align. .align is apparently portable now, but it is still too confusing to use. This is especially confusing for small powers of 2 A few related style bugs have crept into x86/*.s: - i386 has 2 hard-coded .aligns for kdtrace - amd64 and i386 have a few hard-coded .p2align's. Half are my fault. There is a SUPERALIGN_TEXT macro, but no SUPERALIGN_DATA macro. The [SUPER]ALIGN_TEXT and ALIGN_DATA macros are a bit too simple. They hide complications for profiling. However, the best alignment is very machine-dependent and context-dependent. Modern compilers generate very different amounts of alignment depending on -march and the context (different for function targets than for other branch targets...). The macros should at least depend on -march. SUPERALIGN_TEXT is just a hard-coding of a special context for -march=i486. Bruce