<分区>
Possible Duplicate:
Need help with glibc source
我了解如何在 linux 内核中实现我们自己的系统调用。我知道我们可以在 c 程序中使用 syscall()
或 _asm()
调用它。
但我想了解如何为这个新的系统调用编写 glibc api?
open()
和read()
glibc 函数调用如何映射到内核中的系统调用?char message[ ] = "Hello!\n"; int main( void ) { write( 1, message, 7 ); exit( 0 ); }
当我将上面的程序转换为程序集时,它给出了
main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $20, %esp
movl $7, 8(%esp)
movl $message, 4(%esp)
movl $1, (%esp)
call write
movl $0, (%esp)
call exit
.size main, .-main
.ident "GCC: (Debian 4.3.2-1.1) 4.3.2"
.section .note.GNU-stack,"",@progbits
~
3、在“call write”中我认为write是glibc调用这里?。之后会发生什么?它如何将 glibc 调用映射到系统调用?