Indirect system call

bill bill at zycor.UUCP
Sat Nov 11 03:44:17 AEST 1989


In article <28945 at shemp.CS.UCLA.EDU> dieter at lynn.cs.ucla.edu (Dieter Rothmeier) writes:
>While browsing through section 2 of the Unix manual,
>I came upon the concept of an indirect system call,
>as in syscall(2). Now that puzzled me. What might be
>the use for such a facility?

You have stumbled on an interesting quirk in some implementations of UNIX.
It would seem that some processors don't expect the data for a
system call to be on the user stack, but instead immediately following
the system-call opcode in the user address space. In other words, 
something like:
	syscall	5
	word	v1
	word	v2
instead of the more common way that system calls work in a CPU:
	push	v2
	push	v1
	syscall	5

(So on the OS side, it uses the saved PC to access the operands
instead of the user stack pointer).

The problem is that if the system call instruction is in the TEXT
segment you can't write variable quantities after the syscall
opcode, since the text is r/o. Thus, you put the actual opcode
and its operands out in the data segment, and the indirect system
call points at the real one. 

The only time I have seen this was years ago on an Onyx running 7.

Bill Mahoney
bill at zycor.UUCP
The holiday season: time to wonder if the Salvation Army has tanks...



More information about the Comp.unix.wizards mailing list