Index: linux-user/arm-semi.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/arm-semi.c,v
retrieving revision 1.5
diff -r1.5 arm-semi.c
80c80,81
< #define ARG(n) tget32(args + n * 4)
---
> #define ARG(n) tget32(args + (n) * 4)
> #define SET_ARG(n,val) tput32(args + (n) * 4,val)
161,164c162,201
<         /* XXX: Not implemented.  */
<         s = (char *)g2h(ARG(0));
<         *s = 0;
<         return -1;
---
>         /* The ARM semihosting interface requires that the commandline is
>            presented with blanks separating the arguments. Thus, we need
>            to build a new command line, given the global pointer to the
>            command line we received.
>            A better way would be to build this command line on the user stack,
>            similar to the way it is done in loader_build_argptr(), and then
>            just hand that pointer back to the caller */
>         {
>             extern char **global_userspace_argv ; /* initialized in main() */
>             char **av = global_userspace_argv ;   /* work ptr */
>             int len = ARG(1); /* amount of RAM that the ARM binary has set
>                                  aside for the command line */
>             /* lock the buffer on the ARM side */
>             char *cmdline_buffer = (char*)lock_user(ARG(0),len,0);
>             s = cmdline_buffer ;
>             do {
>                 int n = strlen(*av) ;
> 
>                 /* is there still space in the supplied buffer, including
>                    the terminating zero? */
>                 if (s - cmdline_buffer + n+1 > len)
>                     break ; /* no */
> 
>                 memcpy(s,*av,n);
>                 s += n ;
>                 *s++ = ' ';
>                 len -= n+1 ;
>                 av++;
>             } while (*av);
>             *s++ = 0; /* terminate cmdline string */
> 
>             /* unlock the buffer on the ARM side */
>             unlock_user(cmdline_buffer, ARG(0), ARG(1));
> 
>             /* adjust the commandline length argument */
>             SET_ARG(1, (uint32_t)(s - cmdline_buffer));
> 
>             /* successfull return if commandline fit into buffer */
>             return *av == 0 ? 0 : -1 ;
>         }
Index: linux-user/main.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/main.c,v
retrieving revision 1.88
diff -r1.88 main.c
312a313,315
> /* XXX: this is an ugly hack, to make argc/argv available to ARM semihosting */
> char **global_userspace_argv ;
> 
1531,1532c1534,1536
<     
<     if (loader_exec(filename, argv+optind, environ, regs, info) != 0) {
---
>     global_userspace_argv = argv + optind;
> 
>     if ((loader_exec(filename, global_userspace_argv, environ, regs, info)) != 0) {
