[uClinux-dev] execve function of linux-2.4.x of
uClinux-dist-20070130 misbehavior
=?gb2312?B?y84gaHo=?=
chinadldz2002 at hotmail.com
Sat Feb 24 23:19:49 EST 2007
So interesting, if I use GDB/ARMulator, it runs well in both arm-elf-gdb
and skyeye.
Any difference between GDB/ARMulator and Samsung/s3c4510b can cause this
problem?
Regards,
Song
>Hi everybody,
>
>I modified the dispargv.c, so it can show both argv and envp:
>
>############
>dispargv.c
>############
>#include <stdio.h>
>#include <stdlib.h>
>
>int main(int argc, char *argv[], char *envp[])
>{
> int tmp = 0;
>
> printf("argv = %p\n", argv);
> while(argv[tmp] != NULL)
> {
> printf("arg[%d]: %s\n", tmp, argv[tmp]);
> tmp++;
> }
>
> tmp = 0;
> while(envp[tmp] != NULL)
> {
> printf("env[%d]: %s\n", tmp, envp[tmp]);
> tmp++;
> }
> return 0;
>}
>###################################
>And now the result is (without showing the address of argv):
>/> diapargv haha xixi wuwu
>arg[0]: >
>arg[1]: >
>arg[2]: dispargv
>arg[3]: haha
>arg[4]: xixi
>arg[5]: wuwu
>env[0]: wuwu
>
>We could see that envp[0] point to the last argument of argv, so we can
>know both argv and envp pointers are offset backward by 2. I began to
>suspect the fs/binfmt_flat.c: create_flat_tables() function, but no logic
>errors can be found. I tried to modified it to see if it's that function's
>problem:
>133: put_user(argc,--sp);
> // Added by Song
> printk("fs/binfmt_flat.c: create_flat_tables():
> argv=0x%p\n", argv);
> p+=2;
> // Added by Song: above
>134: current->mm->arg_start = (unsigned long) p;
>
>And now:
>/> diapargv haha xixi wuwu
>arg[0]: >
>arg[1]: >
>arg[2]: spargv // NOTE: NO "di" here
>arg[3]: haha
>arg[4]: xixi
>arg[5]: wuwu
>env[0]: wuwu
>So it won't be that function's problem.
>
>After adding the address display:
>/> dispargv haha xixi wuwu
fs/binfmt_flat.c: create_flat_tables(): argv=0x003fff7c
>argv = 0x3fff74 // argv in dispargv
>arg[0]: ?
>arg[1]: ?
>arg[2]: spargv
>arg[3]: haha
>arg[4]: xixi
>arg[5]: wuwu
>env[0]: wuwu
>
>0x003fff7c - 0x3fff74 = 8 just equals 2*sizeof(char *).
>
>So what is the problem?
>
>Regards,
>Song
>
>>Hi everybody.
>>
>>cpu: S3C4510
>>toolchain: arm-elf-tools-20030314
>>use uClibc
>>
>>I run this version of uclinux in skyeye, and find that if parameters are
>>passed from commandline the invoked command often output an error,
>>especially busybox, it can't work at all.
>>
>>And at last, I find the pointer passed to main function is offseted
>>backward by 2.
>>
>>I write two programs to test execve function:
>> ......
_________________________________________________________________
ÓëÁª»úµÄÅóÓѽøÐн»Á÷£¬ÇëʹÓà MSN Messenger: http://messenger.msn.com/cn
More information about the uClinux-dev
mailing list