[U-Boot] EABI 4.2
Joakim Tjernlund
joakim.tjernlund at transmode.se
Wed Mar 10 18:29:25 CET 2010
"Martin Krause" <Martin.Krause at tqs.de> wrote on 2010/03/10 17:52:40:
>
> Hi Jocke,
>
> Joakim Tjernlund wrote on Wednesday, March 10, 2010 5:36 PM:
> >> Andrew Dyer wrote on Wednesday, March 10, 2010 4:50 PM: [SNIP]
> >>
> >> Hm, on the wikipedia article for the 'variable length arrays' (VLA) I
> >> read, that the GNU C compiler always uses the stack for this type of
> >> variables. So I think, if the stack is working for all other local
> >> variables, it should not be an memory layout problem.
> >>
> >> Eventually the following might be interesting. I have tried to make
> >> the VLA much bigger, to eliminate 'normal' buffer overrun problems:
> >>
> >> char filename[dirent.namelen + 1 + 2048]
> >>
> >> But this leads to the same result, U-Boot dies. With an fixed length
> >> array of comparable length it works:
> >>
> >> char filename[2048]
> >>
> >> Both (local) variables should end up on the stack.
> >
> > Try alloca to see if stack allocs works at all in your toolchain.
>
> I didn't find alloca(), so I tried it with __builtin_alloca().
Did you do #include <alloca.h> ?
__builtin_alloca should work too.
> The result is the same as with variable length array - u-boot
> dies during the ext2ls command call.
>
> Does this mean, my toolchain is broken? I use ELDK4.2 for ARM.
I belive so, how many bytes is in dirent.namelen? alloca can not handle to big
allocs (arch dependant) and will silently fail is it is too big.
VLA might be impl. using alloca so if alloca is broken, probably VLA too.
Jocke
More information about the U-Boot
mailing list