mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Michael Olbrich <m.olbrich@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH] libmodbus3: add patch for fixing alignment problem on arm
Date: Thu, 28 Mar 2013 10:27:22 +0100	[thread overview]
Message-ID: <20130328092722.GZ1289@pengutronix.de> (raw)
In-Reply-To: <1575cd81a2d6bc90dc886d8fee1afa6f@idefix.lespocky.dyndns.org>

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

      reply	other threads:[~2013-03-28  9:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-14 12:16 Alexander Dahl
2013-03-19 15:32 ` Michael Olbrich
2013-03-19 15:55   ` Alexander Dahl
2013-03-19 16:27     ` Michael Olbrich
2013-03-26  9:04       ` Alexander Dahl
2013-03-27 17:57         ` Michael Olbrich
2013-03-28  7:46           ` Alexander Dahl
2013-03-28  9:27             ` Michael Olbrich [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130328092722.GZ1289@pengutronix.de \
    --to=m.olbrich@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox