From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from ptx.hi.pengutronix.de ([2001:6f8:1178:2:5054:ff:fec0:8e10] ident=Debian-exim) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1UL97E-0003sN-ER for ptxdist@pengutronix.de; Thu, 28 Mar 2013 10:27:24 +0100 Received: from mol by ptx.hi.pengutronix.de with local (Exim 4.72) (envelope-from ) id 1UL97C-00018x-C4 for ptxdist@pengutronix.de; Thu, 28 Mar 2013 10:27:22 +0100 Date: Thu, 28 Mar 2013 10:27:22 +0100 From: Michael Olbrich Message-ID: <20130328092722.GZ1289@pengutronix.de> References: <1363263396-10029-1-git-send-email-post@lespocky.de> <20130319153256.GC30288@pengutronix.de> <418cf186bf4178fef3675a181603dd34@idefix.lespocky.dyndns.org> <20130319162757.GD30288@pengutronix.de> <20130327175740.GS1289@pengutronix.de> <1575cd81a2d6bc90dc886d8fee1afa6f@idefix.lespocky.dyndns.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1575cd81a2d6bc90dc886d8fee1afa6f@idefix.lespocky.dyndns.org> Subject: Re: [ptxdist] [PATCH] libmodbus3: add patch for fixing alignment problem on arm Reply-To: ptxdist@pengutronix.de List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: ptxdist-bounces@pengutronix.de Errors-To: ptxdist-bounces@pengutronix.de To: ptxdist@pengutronix.de Hi, On Thu, Mar 28, 2013 at 08:46:59AM +0100, Alexander Dahl wrote: > Am 2013-03-27 18:57, schrieb Michael Olbrich: > > When does this issue happen anyways? I've never seen it. > > The problem is in one of the test programs, code was like this before: > > uint16_t *tab_rp_registers; > /* load some data to this poiner */ > *((uint32_t *)tab_rp_registers) = something_else; > > On ARMv5 (which we use here) and older the CPU can not access memory > bytewise, so fetching an 2 or 4 byte integer from an unaligned memory > address leads to wrong data. Get a detailed explanation here: > http://lecs.cs.ucla.edu/wiki/index.php/XScale_alignment > > The cast from an *uint16_t to an *uint32_t could lead to such an > unaligned access. You can let the compiler spot such things and warn you > with -Wcast-align (which is btw not part of -Wall) and we set > -Wcast-align globally to spot those things in our own code for ARMv5 > architecture. > > The problem is with libmodbus3 setting -Werror which leads to all > warnings be handled as errors and thus the failing build. Ah, here is the missing link. I know the alignment issue, but I also know that this usually doesn't generate build errors. > In short: the combination of -Werror in libmodbus and -Wcast-align in > our PTXCONF_TARGET_EXTRA_CFLAGS triggered this. > > > But I like the change, because we compile less that way. > > Someone who wants the test would have to edit the rules then, but she > would need to edit the targetinstall rule then anyway. True. Michael -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- ptxdist mailing list ptxdist@pengutronix.de