[U-Boot] EABI 4.2

Martin Krause Martin.Krause at tqs.de
Thu Mar 11 11:11:09 CET 2010


Joakim Tjernlund wrote on Wednesday, March 10, 2010 6:29 PM:
> "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> ?

Yes, but then I get an "ext2fs.c:31:20: error: alloca.h: No such file 
or directory" error. I'm using an older Version of U-Boot, though ...
(U-Boot 1.3.4).

> __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

In the first call 2 bytes, in the second call 3 bytes, and then
U-Boot dies.

> 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. 

This sounds plausible.

I compiled the original code with VLA with ELDK4.1 and there 
everything works. And also the '__builtin_alloca' Version works
with ELDK4.1.

Regards,
Martin



More information about the U-Boot mailing list