From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28445 invoked by alias); 22 Feb 2015 20:51:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 28431 invoked by uid 89); 22 Feb 2015 20:51:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org Received: from smtp.gentoo.org (HELO smtp.gentoo.org) (140.211.166.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 22 Feb 2015 20:51:35 +0000 Received: from vapier (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with SMTP id F0492340841; Sun, 22 Feb 2015 20:51:32 +0000 (UTC) Date: Sun, 22 Feb 2015 20:51:00 -0000 From: Mike Frysinger To: Jiri Gaisler Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2 10/22] sim/erc32: Switched emulated memory to host endian order. Message-ID: <20150222205132.GA31422@vapier> Mail-Followup-To: Jiri Gaisler , gdb-patches@sourceware.org References: <1424385100-15397-1-git-send-email-jiri@gaisler.se> <1424385100-15397-11-git-send-email-jiri@gaisler.se> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline In-Reply-To: <1424385100-15397-11-git-send-email-jiri@gaisler.se> X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00632.txt.bz2 --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1451 On 19 Feb 2015 23:31, Jiri Gaisler wrote: > + *((unsigned short *) &(mem[waddr])) =3D *data & 0x0ffff; this violates strict aliasing. you can't cast the RHS side like this. it = also=20 violates alignment since the buffer is passed in as unsigned char *. you should use memcpy() instead. on systems where unaligned access are OK,= gcc=20 should optimize it down to a few load/stores anyways. this form shows up a few times in this patch and they should all get fixed. > --- a/sim/erc32/exec.c > +++ b/sim/erc32/exec.c >=20=20 > +static int > +extract_short(uint32 data, uint32 address) space before the (. comes up multiple times in this patch. > + return((data>>((2 - (address & 2))*8)) & 0xffff); need to fix the spacing here: return ((data >> ((2 - (address & 2)) * 8)) & 0xffff); comes up multiple times in this patch. > @@ -808,21 +808,28 @@ disp_mem(addr, len) >=20=20 > uint32 i; > unsigned char data[4]; > + uint32 *wdata =3D (uint32 *) data; you need to use a union here to avoid aliasing/alignment problems: union { unsigned char u8[4]; uint32 u32; } data; > while (section_size > 0) { > - char buffer[1024]; > int count; > + char buffer[1024]; > + uint32 *wbuffer =3D (uint32 *) buffer; same here > + for (i=3D0; i