On Dec 2, 2008, at 12:46 PM, Hiroshi Ito wrote:

I'm running openocd on EP9307(arm925t) CPU, as a HOST.
and target is EP9307 and ARM926t with EP9307 GPIO.

revision 1183 cause seg fault.
The problem is, cmd_queue_alloc returns unaligned pointer.
but it is used as a pointer to structure.

This patch fix it. and it is working.
Index: src/jtag/jtag.c
===================================================================
--- src/jtag/jtag.c     (revision 1183)
+++ src/jtag/jtag.c     (working copy)
@@ -378,6 +378,8 @@
        int offset;
        u8 *t;

+       /* align to 4 byte boundary */
+       size = ((size+3)/4)*4;
        if (*p_page)
        {
                while ((*p_page)->next)
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development



This doesn't change the pointer returned by cmd_queue_alloc() at all. It just rounds the size of the allocation up to a 4-byte alignment. If that is necessary, it should be fixed by the caller rather than always padding in cmd_queue_alloc(). Otherwise, a 1-byte allocation would take 4-bytes in all cases. What function was calling cmd_queue_alloc() that needs the pointer to be word aligned?

I'm also not entirely sure that a structure must always be aligned. I'm aware that some architectures will trap if an unaligned access is encountered, but the OS should catch the trap and handle the unaligned access correctly.

--
Rick Altherr
[EMAIL PROTECTED]

"He said he hadn't had a byte in three days. I had a short, so I split it with him."
 -- Unsigned



Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to