[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using __clone() system call on Etrax-LX with Linux 2.4.3



On 18 May 2001 16:51:19 +0200, Hans-Peter Nilsson wrote:
> > From: Ujwal "S." Sathyam <ujwal@xxxxxxx.com>
> > Date: 17 May 2001 17:21:56 -0700
> 
> >   24:   3f0d 0000 0000          jump 0 <__clone>
> >   2a:   7fb6                    ret
> >   2c:   0f05                    nop
> > 
> > I don't know much about assembly, but this does not look quite correct
> > to me. The second instruction is a jump 0.
> 
> No, that detail is most probably not the culprit.  There was
> quite probably a relocation there, which would have been listed
> if you had also given "-r" to objdump-cris.
> 
> brgds, H-P
> 

I did that and got:

00000000 <__clone>:
   0:   7fa2                    moveq -1,$r10
   2:   3f0d 0000 0000          jump 0 <__clone>
                        4: R_CRIS_32    __syscall_error
   8:   7a86                    clear.d $r10
   a:   5fbc 1101               movu.w 0x111,$r11
   e:   fce1 ee1f               push $r1
  12:   5f1c 7800               movu.w 0x78,$r1
  16:   3de9                    break 13
  18:   6e1e                    pop $r1
  1a:   efae 01f0 ffff          cmp.d 0xfffff001,$r10
  20:   0810                    bcs 2a <__clone+0x2a>
  22:   0f05                    nop
  24:   3f0d 0000 0000          jump 0 <__clone>
                        26: R_CRIS_32   __syscall_error
  2a:   7fb6                    ret
  2c:   0f05                    nop

So, the jump statement is still a problem. It is looking like that
instead of implementing clone, syscall_error is called. 

I finally downloaded the source code of glibc for cris and looked at
clone.c, and sure enough, it says that clone is not implemented yet. I
wonder why.

-----------------Begin clone.c---------------------------------------
#include <sysdep.h>

int __clone(int (*fn)(void *arg), void *child_stack, int flags, void
*arg);

/* this is not implemented yet. it just calls error. */

__asm__ (".text\n\t"
	 ".globl " STR(C_SYMBOL_NAME(__clone)) "\n"
	 STR(C_LABEL(__clone)) "\n\t"
	 "moveq -1," __REG_PREFIX "r10\n\t"
	 "jump " STR(C_SYMBOL_NAME(__syscall_error)) "\n\t"
	 /* r10 is argument 1 to clone, the new stack pointer */
	 "clear.d " __REG_PREFIX "r10\n\t"
	 /* flags argument - SIGCHLD | CLONE_VM */
	 "movu.w 0x111," __REG_PREFIX "r11\n\t"
	 "push " __REG_PREFIX "r1\n\t"
	 "movu.w " STR(__NR_clone) "," __REG_PREFIX "r1\n\t"
	 STR(CRIS_SYSCALL) "\n\t"
	 "pop " __REG_PREFIX "r1\n\t"
	 "cmp.d -4095," __REG_PREFIX "r10\n\t"
	 "bcs 1f\n\t"
	 "nop\n\t"
	 "jump " STR(C_SYMBOL_NAME(__syscall_error)) "\n"
	 "1:\n\t"
	 "ret\n\t"
	 "nop\n\t");

weak_alias (__clone, clone)
---------------------End clone.c-------------------------------------

Ujwal