mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Alexander Dahl <post@lespocky.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH] libmodbus3: add patch for fixing alignment problem on arm
Date: Thu, 28 Mar 2013 08:46:59 +0100	[thread overview]
Message-ID: <1575cd81a2d6bc90dc886d8fee1afa6f@idefix.lespocky.dyndns.org> (raw)
In-Reply-To: <20130327175740.GS1289@pengutronix.de>

Hei hei, 

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.

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.

Greets
Alex

-- 
»With the first link, the chain is forged. The first speech censured,
the first thought forbidden, the first freedom denied, chains us all
irrevocably.« (Jean-Luc Picard, quoting Judge Aaron Satie)
*** GnuPG-FP: 02C8 A590 7FE5 CA5F 3601  D1D5 8FBA 7744 CC87 10D0 ***

-- 
ptxdist mailing list
ptxdist@pengutronix.de

  reply	other threads:[~2013-03-28  7:47 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 [this message]
2013-03-28  9:27             ` Michael Olbrich

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=1575cd81a2d6bc90dc886d8fee1afa6f@idefix.lespocky.dyndns.org \
    --to=post@lespocky.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