[OpenAFS-devel] System Call Stubs for IA64

chas williams chas@cmf.nrl.navy.mil
Fri, 10 May 2002 12:13:22 -0400


>Would an indirect function call (call by function pointer) not force
>the compiler to generate instructions to store and restore the old
>global pointer (in a register). That's what I thought.

i guess the problem lies here:

asmlinkage long afs_syscall_stub(unsigned long arg1, unsigned long arg2,
                                 unsigned long arg3, unsigned long arg4,
                                 unsigned long arg5, unsigned long arg6)
{
        return call_syscall_gp(afs_syscall, arg1, arg2, arg3,
                                            arg4, arg5, arg6);
}

afs_syscall is going to be gp (module space) relative.  you need to write
afs_syscall so that it is not going to be gp (module space) relative and will
be resolved by the insmod when the module is loaded.  this would then work.
i believe i tried this tactic at first when i didnt completely understand
the runtime model.  apparently (as it was explained to me):

.L1:
	addl r14 = .afs_syscall-.L1,r3
...
.afs_syscall:
	data8 @fptr(my_sys_getrlimit)

the . prefix makes these 'temporary' symbols and they then reside in the
text segment (thus you dont need the gp setup to access them).  insmod fills
in @fptr(my_sys_getrlimit) at load time with the ip,gp pair and everything
is happy.  i wouldnt have done this in assembler if i could think of any
way around it.  i am generally lazy.

btw, i think ((long)(fptr))[1] is the gp, not ((long)(fptr))[0].