On Thu, 14 Sep 2000, Keith Packard wrote:
>
> > u8 buf[4];
> > u16 *a;
> > a = &buf[1];
> > *a = 4;
>
> > 0xbffffc40 = 0x4
> > 0xbffffc41 = 0x0
> > 0xbffffc42 = 0x0
> > 0xbffffc43 = 0x0
>
>
> I dont' think the ARM can do unaligned memory accesses; this should have
> caused a SIGBUS.
>
> The original IBM RT processor *ignored* the low bits of the address in
> this case giving the result you describe.
>
> Looks like a kernel bug to me.
Not really.... because the ARM has a documented behavior with unaligned
access when the alignment exception isn't enabled. It might (and was in
the past) used to rotate values by using a non-aligned address. For
example, if you have 0x12345678 at the address 0x20000008, then fetching a
full word at 0x2000000a will produce 0x56781234 in the target register,
regardless of what is at 0x2000000c. . I think gcc is even aware of that
kind of trick and may use it if given the proper parameter.
Since there are compatibility issues with old ARM binaries out there, the
default policy is to allow unaligned access in user space. However, IMHO,
it could be configurable with a kernel command line parameter to generate
a SIGBUS if unaligned access happens (I'll probably look into that). This,
of course, if you are sure that all binaries, libraries, etc. aren't
compiled with such unaligned assumptions.
Nicolas
Received on Thu Sep 14 19:50:02 2000
This archive was generated by hypermail 2.1.8 : Tue May 04 2004 - 09:43:42 EDT