On Sunday 12 April 2009 19:30:33 Jamie Lokier wrote:
> Mike Frysinger wrote:
> > > It's easy but you need an asm wrapper for each architecture, as the
> > > parent must not touch the stack before calling _exit.
> >
> > i'm aware of this which is why i used INTERNAL_SYSCALL() rather than
> > calling the C library functions.  those expand into the appropriate
> > assembly for making a system call.
>
> I only see INTERNAL_SYSCALL on ARM, but perhaps I'm looking at an old
> version of uclibc?

it should be implemented in most ports now in trunk.  if a port doesnt, well 
it should fix that anyways.

> You have to test the result of clone() before calling _exit().  How do
> you guarantee the compiler inserts no memory writes in that sequence
> using just INTERNAL_SYSCALL on all architectures?

there is no guarantee of course, but i declare the storage of the return value 
of clone with "register", so that seems to be "good enough".  i reviewed the 
disassembly on a few arches and they all look correct.  just dont build with 
optimization turned off ;).

the Blackfin assembly for example is:
  18:   a0 00           EXCPT 0x0;      /* syscall(clone) */
  1a:   ea 63           R2 = -0x3 (X);
  1c:   08 30           R1 = R0;
  1e:   f8 67           R0 += -0x1;
  20:   10 0a           CC = R0 <= R2 (IU);
  22:   03 14           IF !CC JUMP 0x28 <_daemon+0x28> (BP);
  24:   08 68           P0 = 0x1 (X);
  26:   a0 00           EXCPT 0x0;      /* syscall(exit) */
no stack usage by the parent
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to