From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1784 invoked by alias); 20 Jan 2009 07:55:27 -0000 Received: (qmail 1775 invoked by uid 22791); 20 Jan 2009 07:55:26 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from 137-67-76-76-skybeam.com (HELO mail.chez-thomas.org) (76.76.67.137) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Jan 2009 07:55:21 +0000 Received: by mail.chez-thomas.org (Postfix, from userid 999) id C15213B52F36; Tue, 20 Jan 2009 00:54:40 -0700 (MST) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by mail.chez-thomas.org (Postfix) with ESMTP id 96A9E3B526F7; Tue, 20 Jan 2009 00:54:39 -0700 (MST) Message-ID: <49758360.4020009@mlbassoc.com> Date: Tue, 20 Jan 2009 07:55:00 -0000 From: Gary Thomas User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: Jose Vasconcellos CC: ecos-patches@ecos.sourceware.org Subject: Re: redboot fconfig crash with gcc 4.3.2 References: <4974FD62.9090602@verizon.net> In-Reply-To: <4974FD62.9090602@verizon.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact ecos-patches-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: ecos-patches-owner@ecos.sourceware.org X-SW-Source: 2009-01/txt/msg00017.txt.bz2 Jose Vasconcellos wrote: > Redboot gets an exception when trying to set any IP address with fconfig > when using gcc-4.3.2 on an ixp425 target (armeb). The issue seems to be > an alignment problem as val_ptr contains an odd address; it looks like gcc > is optimizing and trying to do a copy on a word boundary. The removal of > the cast fixes the problem. > > > --- fconfig.c 2009-01-18 14:34:11.000000000 -0500 > +++ fconfig.c.new 2009-01-18 14:35:22.000000000 -0500 > @@ -388,7 +388,7 @@ > break; > #ifdef CYGPKG_REDBOOT_NETWORKING > case CONFIG_IP: > - memcpy(&hold_ip_val.s_addr, &((in_addr_t *)val_ptr)->s_addr, > sizeof(in_addr_t)); > + memcpy(&hold_ip_val.s_addr, val_ptr, sizeof(in_addr_t)); > if (!_gethostbyname(line, &new_ip_val)) { > return CONFIG_BAD; > } > Sounds like a *BUG* in the compiler. Have you reported it? This does more than remove the cast :-) What if the s_addr field is not at the start of the structure? I know it hasn't moved in 25+ years, but I don't like tossing correctness [even if only pedantic] away. Maybe there's another way to solve this. Does it happen on arm[el]? -- ------------------------------------------------------------ Gary Thomas | Consulting for the MLB Associates | Embedded world ------------------------------------------------------------