Problems in __environ in mips

Khem Raj raj.khem at gmail.com
Mon Mar 15 00:50:38 UTC 2010


On Sun, Mar 14, 2010 at 4:14 AM, Lluís Batlle <viriketo at gmail.com> wrote:
> Argh! I tried uclibc-0.9.30.3 and now all works!!!! It took me hours
> to get until the problem in __environ.
>
> I noticed
> http://lists.uclibc.org/pipermail/uclibc/2010-January/043501.html
>
> Well, good that now all works.
>
> Regards,
> Lluís.
>
> 2010/3/14 Lluís Batlle <viriketo at gmail.com>:
>> Hello,
>>
>> I'm trying to build a program for a mips (OpenWRT in brcm63xx), linux
>> 2.6.32.9, statically linked.
>>
>> Having built the program with a cross-toolchain (linux-headers
>> 2.6.32.9, gcc 4.4.3, binutils 2.20, uclibc 0.9.30.2) for
>> mips-unknown-linux, I'm having problems with the __environ variable.
>>
>> Debugging the target, I see that the contents of __environ just after
>> the __uClibc_main line saying:
>> 293         __environ = &argv[argc + 1];
>>
>> The values of __environ are:
>> (gdb) print __environ[0]
>> $30 = 0x7f855f5e "USER=root"
>> (gdb) print __environ[1]
>> $31 = 0x43a2e0 <Address 0x43a2e0 out of bounds>
>> (gdb) print __environ[2]
>> $33 = 0x7f855f74 "HOME=/root"
>> (gdb) print __environ[3]
>> $32 = 0x7f855f7f "PS1=\\u@\\h:\\w\\$ "
>>
>> As you see, accessing __environ[1] causes a segfault. According to
>> /proc/PID/environ, that should contain "OLDPWD=/etc".
>>
>> And, if it rings a bell to anyone, the value 0x43a2e0 is also the
>> content of the register 'gp'. And looking at the argv array, the
>> __environ[1] value is already bad at the start of __uClibc_main.
>>
>> Any help? What am I doing wrong?

0.9.30.2 has a bug for mips its been fixed in .3 see commit
2911103dd4a03bbd3aad11eddfce524a5c9ba9b3

>>
>> For what it matters, I'm using the O32 ABI, and the MIPS32 cpu, for
>> both uclibc and the program I link.
>>
>> Regards,
>> Lluís.
>>
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc


More information about the uClibc mailing list