Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Debugging Epiphany/Midori (webkit-gtk based) on earmv6hf (RPI 2)

On Thu 08 Oct 2015 at 17:59:22 +0000, Stephan wrote:
> IMHO it would be valid to pass the value of sp as the first argument
> (mov r0, sp). However, the way how r0 is computed looks quite
> obfuscated to me:
>    0x4621402c <g_dpgettext2+72>: mov r3, sp        => ?
>    0x46214030 <g_dpgettext2+76>: lsr r7, r3, #3   => ?
>    0x46214034 <g_dpgettext2+80>: lsl r4, r7, #3   => ?
>    0x46214040 <g_dpgettext2+92>: mov r0, r4          => ?

I don't really know any ARM assembly but it seems that the value from sp
is shifted right 3 bits and then left again. In effect clearing the low
3 bits, or aligning to 8. Which by itself is a very sensible thing to do
for an allocator.

Unfortunately (since it rounds down) it can have the effect of
allocating the memory lower than sp, which is bound to fail at some
point. Probably the value should also go back into sp.

There is also an alloca in libc: cvs/src/lib/libc/arch/arm/gen/alloca.S.
It uses a similar shifting trick but it uses it to round up the
allocation size to multiples of 8, and it does end up with the same
value in r0 and sp.

___ Olaf 'Rhialto' Seibert  -- The Doctor: No, 'eureka' is Greek for
\X/ rhialto/at/    -- 'this bath is too hot.'

Attachment: pgp7dCT4BIwvW.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index