Hi,
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
On Tue, Mar 11, 2014 at 11:55 PM, Kim Chan <ckim@xxxxxxxxxx> wrote:
--
Wow, that was it. I'm happy to hear that because I thought it should end up with a system call anyway.Then isn't there some codes making the system call? Or is it that the compiler understands that 'write' is a system call and inserts the assembly code for calling it by itself?
In uclibc, the write source code is found here:
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common/write.c
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/common/write.c
How the syscall is actually implemented is architecture specific, and will be in one of the directories here:
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux
For example, for ARM, with EABI, then I believe that it winds up here:
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/arm/syscall-eabi.S
http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/arm/syscall-eabi.S
The SWI instruction transfers control to the kernel.
On the kernel side, how the syscalls get handled is also architecture specific, but it will generally wind up at a function called sys_FUNCTION, however the generation of the function name is usually hidden behind a macro.
So sys_write in the kernel winds up being declared here:
http://lxr.linux.no/#linux+v3.13.5/fs/read_write.c#L514
http://lxr.linux.no/#linux+v3.13.5/fs/read_write.c#L514
Dave Hylands
Shuswap, BC, Canada
http://www.davehylands.com
_______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies