Pointer typecasts may write to incorrect addresses on ARM?

Subramanyam Badri badri_subbu@hotmail.com
Thu Sep 24 16:11:00 GMT 2009


 <4ABB2ECC.3050707@redhat.com>
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0


Hi Andrew/John=2C
=20
Thanks for the mails.=20
=20
We are able to figure out the solution for this problem. U bit is required =
to enable in this ARM processor Register.
=20
Regards=2C
Badri

----------------------------------------
> Date: Thu=2C 24 Sep 2009 09:33:16 +0100
> From: aph@redhat.com
> To: badri_subbu@hotmail.com
> CC: gcc-help@gcc.gnu.org
> Subject: Re: Pointer typecasts may write to incorrect addresses on ARM?
>
> Subramanyam Badri wrote:
>> Hi=2C
>>
>> I am using a GCC compiler for ARM and see an alignment problem with poin=
ter typecasting. We're porting code to ARM and found some writes to incorre=
ct addresses. Can you help? For example:
>>
>> char * pChar =3D (char *)0x100000=3B /* hardcoded for example purposes *=
/
>> pChar[0] =3D 0x0=3B
>> *(int *)&pChar[1] =3D 0x11223344=3B
>>
>> /* We really want pChar[0] to equal 0x00=2C but it equals 0x44 on ARM!!!=
! */
>> printf ("pChar[0] =3D 0x%02x\n"=2C pChar[0])=3B
>>
>> My understanding is that non-aligned memory access is allowed on ARM=2C
>
> No=2C that's not true. *Some* versions of ARM have some support for unali=
gned
> memory accesses=2C some don't. You need to be sure which one you've got.
>
> Andrew. 		 	   		  =0A=
_________________________________________________________________=0A=
Lauren found her dream laptop. Find the PC that=92s right for you.=0A=
http://www.microsoft.com/windows/choosepc/?ocid=3Dftp_val_wl_290=



More information about the Gcc-help mailing list