[webkit-dev] Alignment issues in MIPS

Luciano Montanaro mikelima at gmail.com
Tue Apr 6 03:06:23 PDT 2010


On Tue, Apr 6, 2010 at 9:21 AM, Alex Vazquez <alexvazquezfente at gmail.com> wrote:
> Hello list,
>
> I'm cross-compiling WebKit (revision 40084) for a MIPS board using DirectFB
> backend.
>
> While executing in the target, libwebkit is causing SIGBUS errors due to
> misaligned double data. The errors raise when loading a misaligned double in
> the FPU using the ldc1 instruction (it is stated in the MIPS documentation
> that data loaded in the FPU must be 8-byte aligned to avoid an address
> error). I know that the kernel can be configured to manage misaligned
> accesses but i prefer not to mess with that by the moment.

I have SIGBUS problems cross-compiling on SH4 with Qt, similar to yours.
Debug builds work fine, but release builds crash as soon as the first
webkit-related
call is made. I've not had time to investigate further, though I'll
soon have to.

I'm looking into your suggestion, and I see the class is not
optimallly laid out (there is a function pointer which is presumably 4
bytes, followed by a double which is 8), though the compiler should
correctly align it putting a 4 byte hole between the pointer and the
double. At new time, the class should be allocated from a correctly
aligned memory block, so any misalignments are probably due to copying
the class around?

>
> After some debugging, i found out that the offending variable is the
> attribute m_nextFireTime in the TimerBase class, which sometimes is not
> aligned to an 8-byte boundary. As a test, i tried compiling with
> -msoft-float (emulate FPU by software) and checked that the dissassembled
> code does not use the FPU but, in that case, webkit does not render
> anything. I also tried using the "__attribute__ aligned" directive without
> any success.

Well, that confirms it, the member variable was already aligned anyway.

>
> Finally, i made an ugly patch to avoid the load from an unaligned address
> and it worked fine but i don't know if there are other places in the code
> whith the same problem.
>
> I have 2 questions:
>
> 1) Has anyone found similar alignment problems compiling webkit for MIPS? If
> so, how were they fixed?
>
> 2) Is there any standard way of forcing alignment of doubles to 8 bytes
> boundary through compiler options (i'm using gcc 4.3.2)?
>


-- 
Luciano Montanaro

Anyone who is capable of getting themselves made President should on
no account be allowed to do the job. -- Douglas Adams


More information about the webkit-dev mailing list