Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Exception on unaligned access

Exception on unaligned access

2004-10-05 by jrdavid99

Hi,

Is there any way to have the LPC2000 generate an exception on 
unaligned data accesses? We are using ARM-GCC and it seems neither the 
compiler nor the processor warn us of unaligned data accesses, even 
though they are illegal.

Jean-Rene David

Re: [lpc2000] Exception on unaligned access

2004-10-05 by Robert Adsett

At 07:21 PM 10/5/04 +0000, you wrote:
>Is there any way to have the LPC2000 generate an exception on
>unaligned data accesses? We are using ARM-GCC and it seems neither the
>compiler nor the processor warn us of unaligned data accesses, even
>though they are illegal.

The short answer is no.

But it raises the question.  What kind of code are you writing where this 
is more than a very occasional issue?  The compiler shouldn't be generating 
unaligned access for normal code unless there is a bug in it.

The only case I know of where it would show up involves pointer punning 
which is inherently risky regardless of architecture.

There is also the case of a few registers (AFAIR) that require word access.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: Exception on unaligned access

2004-10-06 by Jean-Rene David

* Robert Adsett <subscriptions@...>:
> But it raises the question.  What kind of code
> are you writing where this is more than a very
> occasional issue?  

We are porting code from Intel/Linux to ARM.
Packed structures are causing the problems. There
are many throughout the code and we are busy
fixing them all but we are worried we might miss
some and not realize it until it's too late.

Re: [lpc2000] Re: Exception on unaligned access

2004-10-06 by Robert Adsett

At 09:36 PM 10/5/04 -0400, you wrote:

>* Robert Adsett <subscriptions@...>:
> > But it raises the question.  What kind of code
> > are you writing where this is more than a very
> > occasional issue?
>
>We are porting code from Intel/Linux to ARM.
>Packed structures are causing the problems. There
>are many throughout the code and we are busy
>fixing them all but we are worried we might miss
>some and not realize it until it's too late.

OK, I partly understand that.  But if the code is self contained (no 'disk' 
storage, no net communications) doesn't GCC have a switch to turn off 
unaligned access globally?  Certainly something like lint will catch it 
(I'm pretty sure PC-Lint will, along with a horde of other sins).

If you are communicating via disk or communications then all the I/O should 
go through a single interface and be translatable there.  Of course that's 
the ideal and it would hardly be surprising (unfortunately) to see the 
cardinal sin of fwrite(  &struct, sizeof( struct), 1 file) sprinkled 
willy-nilly and used to generate the standard file format.  In this case I 
don't think there is a shortcut other than finding (hopefully in a central 
location) and rewriting the I/O in a portable fashion.

As a wise man once said "The definition of portable code is code that has 
been ported."

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.