From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755778AbbCEM0M (ORCPT ); Thu, 5 Mar 2015 07:26:12 -0500 Received: from service87.mimecast.com ([91.220.42.44]:58362 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755743AbbCEM0J convert rfc822-to-8bit (ORCPT ); Thu, 5 Mar 2015 07:26:09 -0500 Date: Thu, 5 Mar 2015 12:26:06 +0000 From: Dave Martin To: Lino Sanfilippo Cc: LinoSanfilippo@gmx.de, linux@arm.linux.org.uk, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [RFC PATCH 0/1] Wrong structure alignment due to compiler attribute "section" Message-ID: <20150305122606.GC3612@e103592.cambridge.arm.com> References: <1425290502-2322-1-git-send-email-lsanfil@marvell.com> <20150303144130.GB5177@e103592.cambridge.arm.com> <54F6EF32.7080306@marvell.com> <20150304143527.GA5653@e103592.cambridge.arm.com> <54F732DA.2050004@marvell.com> MIME-Version: 1.0 In-Reply-To: <54F732DA.2050004@marvell.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-OriginalArrivalTime: 05 Mar 2015 12:26:06.0711 (UTC) FILETIME=[8DC9C070:01D0573F] X-MC-Unique: 115030512260637801 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 04, 2015 at 05:29:14PM +0100, Lino Sanfilippo wrote: > On 04.03.2015 15:35, Dave Martin wrote: > > > > >Try > > > >rm drivers/clk/mvebu/kirkwood.o > >make ARCH=arm KBUILD_CFLAGS_KERNEL=-save-temps drivers/clk/mvebu/kirkwood.o > > > >(abuse of KBUILD_CFLAGS_KERNEL here, but it's empty by default, and > >I'm too lazy to copy-paste command lines...) > > > > > >The compiler will split out the compiled assembly code in kirkwood.s: > > > >Look for ".align" directives between the start of the affected section > >and the start of the next section (next .section directive). > > > >Here, we just have .align 2, which is the expected correct value > >(i.e., align __of_table_mv88f6180_clk on a 2^2 = 4 byte boundary). > > > >A different value here may indicate a bug in the compiler, because > >you observed that gcc _thinks_ that __alignof__ is 4 for the struct > >in this section even in the failing case. > > Ok, this is the result for the assembly: > > .section __clk_of_table,"a",%progbits > .align 3 > .type __of_table_mv88f6180_clk, %object > .size __of_table_mv88f6180_clk, 196 > __of_table_mv88f6180_clk: > .space 64 [...] > Very interesting. It shows an .align 3 which explains alignment on > 8 byte boundaries: > > > c07630f8 T __clk_of_table > c07630f8 t __of_table_fixed_factor_clk > c07630f8 T __stop_kprobe_blacklist > c07631c0 t __of_table_fixed_clk > c0763288 t __of_table_gpio_gate_clk > c0763350 t __of_table_mv88f6180_clk > > So this is indeed a compiler bug, right? It certainly looks like the compiler is causing the issue somehow. Whether this is a bug, a bug-like feature, a configuration issue, or a combination of these is not clear. If you know where to find the toolchain source, it might be worth taking a look. Cheers ---Dave From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave.Martin@arm.com (Dave Martin) Date: Thu, 5 Mar 2015 12:26:06 +0000 Subject: [RFC PATCH 0/1] Wrong structure alignment due to compiler attribute "section" In-Reply-To: <54F732DA.2050004@marvell.com> References: <1425290502-2322-1-git-send-email-lsanfil@marvell.com> <20150303144130.GB5177@e103592.cambridge.arm.com> <54F6EF32.7080306@marvell.com> <20150304143527.GA5653@e103592.cambridge.arm.com> <54F732DA.2050004@marvell.com> Message-ID: <20150305122606.GC3612@e103592.cambridge.arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Wed, Mar 04, 2015 at 05:29:14PM +0100, Lino Sanfilippo wrote: > On 04.03.2015 15:35, Dave Martin wrote: > > > > >Try > > > >rm drivers/clk/mvebu/kirkwood.o > >make ARCH=arm KBUILD_CFLAGS_KERNEL=-save-temps drivers/clk/mvebu/kirkwood.o > > > >(abuse of KBUILD_CFLAGS_KERNEL here, but it's empty by default, and > >I'm too lazy to copy-paste command lines...) > > > > > >The compiler will split out the compiled assembly code in kirkwood.s: > > > >Look for ".align" directives between the start of the affected section > >and the start of the next section (next .section directive). > > > >Here, we just have .align 2, which is the expected correct value > >(i.e., align __of_table_mv88f6180_clk on a 2^2 = 4 byte boundary). > > > >A different value here may indicate a bug in the compiler, because > >you observed that gcc _thinks_ that __alignof__ is 4 for the struct > >in this section even in the failing case. > > Ok, this is the result for the assembly: > > .section __clk_of_table,"a",%progbits > .align 3 > .type __of_table_mv88f6180_clk, %object > .size __of_table_mv88f6180_clk, 196 > __of_table_mv88f6180_clk: > .space 64 [...] > Very interesting. It shows an .align 3 which explains alignment on > 8 byte boundaries: > > > c07630f8 T __clk_of_table > c07630f8 t __of_table_fixed_factor_clk > c07630f8 T __stop_kprobe_blacklist > c07631c0 t __of_table_fixed_clk > c0763288 t __of_table_gpio_gate_clk > c0763350 t __of_table_mv88f6180_clk > > So this is indeed a compiler bug, right? It certainly looks like the compiler is causing the issue somehow. Whether this is a bug, a bug-like feature, a configuration issue, or a combination of these is not clear. If you know where to find the toolchain source, it might be worth taking a look. Cheers ---Dave