From: Matt Mackall <mpm@selenic.com>

Experimenting with trying to use cond_syscall for a few arch-specific
syscalls, I discovered that it can't actually be used outside the file
in which sys_ni_syscall is declared because the assembler doesn't feel
obliged to output the symbol in that case:

weak.c:

#define cond_syscall(x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall");
cond_syscall(sys_foo);

$ nm weak.o
         U sys_ni_syscall

One arch (PPC) is apparently trying to use cond_syscall this way
anyway, though it's probably never been actually tested as the above
test was done on a PPC.

After trying a bunch of tricks to get it to work nicely, I decided
there are basically two alternatives: make weak versions of
sys_ni_syscall wherever they're wanted or put the arch-specific
cond_syscalls in kernel/sys.c where sys_ni_syscall is defined.

The former approach is a bit crufty and doesn't actually do the right
thing in practice as you'll get multiple copies of sys_ni_syscall in
your final image.

The latter introduces some slight arch-pollution in sys.c, but as
arch-specific cond_syscalls aren't all that frequent, it should be
pretty minor. So here's a patch to move the current offender to sys.c:



---

 arch/ppc/kernel/syscalls.c |    2 --
 kernel/sys.c               |    3 +++
 2 files changed, 3 insertions(+), 2 deletions(-)

diff -puN arch/ppc/kernel/syscalls.c~ppc-cond_syscall-fix arch/ppc/kernel/syscalls.c
--- 25/arch/ppc/kernel/syscalls.c~ppc-cond_syscall-fix	2004-01-14 12:07:42.000000000 -0800
+++ 25-akpm/arch/ppc/kernel/syscalls.c	2004-01-14 12:07:42.000000000 -0800
@@ -271,5 +271,3 @@ long ppc_fadvise64_64(int fd, int advice
 {
 	return sys_fadvise64_64(fd, offset, len, advice);
 }
-
-cond_syscall(sys_pciconfig_iobase);
diff -puN kernel/sys.c~ppc-cond_syscall-fix kernel/sys.c
--- 25/kernel/sys.c~ppc-cond_syscall-fix	2004-01-14 12:07:42.000000000 -0800
+++ 25-akpm/kernel/sys.c	2004-01-14 12:08:20.000000000 -0800
@@ -249,8 +249,11 @@ cond_syscall(compat_sys_futex)
 cond_syscall(sys_epoll_create)
 cond_syscall(sys_epoll_ctl)
 cond_syscall(sys_epoll_wait)
+
+/* arch-specific weak syscall entries */
 cond_syscall(sys_pciconfig_read)
 cond_syscall(sys_pciconfig_write)
+cond_syscall(sys_pciconfig_iobase)
 
 static int set_one_prio(struct task_struct *p, int niceval, int error)
 {

_