Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 28 Nov 2017 13:59:48 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] Wasm support patch 2 (static syscalls)

* Nicholas Wilson <nicholas.wilson@...lvnc.com> [2017-11-28 12:31:18 +0000]:
> Imagine an application that calls "getpid()".  This will cause "getpid.o" to be linked in, to provide the C API:
> 
> pid_t getpid(void)
> {
> 	return __syscall(SYS_getpid);
> }
> 
> On all of Musl's existing archs, the syscalls are implemented via a seven generic "__syscallN" functions. The assumption is that the kernel provides all syscalls.
> 
> For Wasm, what I've done is made it so that the interpreter environment instead provides *named* syscall functions, in this case, a "__syscall_getpid" function. Then, at link-time, when the linker links against libc.a it's able to link in to the application only the syscalls that are actually used.

we may change the syscall abstraction at some point, but
to do what you want, there is no need for intrusive changes.
just have

static inline long __syscall0(long n)
{
	switch (n) {
	...
	case SYS_getpid: return __syscall_getpid();
	...
	}
}

in arc/wasm/syscall_arch.h and the compiler will do the
right thing without any change to generic musl code.

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ