Good links for system calls

I need a link, but a good one, perhaps with some good examples. I need this because I'm starting to write code in the assembly using the NASM assembler. I have this link:

http://bluemaster.iu.hio.no/edu/dark/lin-asm/syscalls.html

which is quite nice and useful, but it has many limitations, because it does not explain fields in other registers. For example, if I use syscall entries, I know that I should put 1 in the EAX register, and ECX is probably a pointer to a string, but what about EBX and EDX? I would also like to clarify that EBX defines the input (0 for stdin, 1 for something else, etc.), and EDX is the length of the line to be entered, etc. Etc. I hope you understand what I want, I could not find such materials, so I write here. Thanks in advance.

+5
source share
2 answers

Linux C. - C, . C , , , .

-, , C. , , man man-, write, . , , , syscall open. , (0 = stdin, 1 = stdout, 2 = stderr). - , - ( ). , , , .

, ? 32- x86 (, , , ); , 64- x86 (, 32- 32- , . , ). , 32- x86 - int $0x80.

int $0x80 %eax, %ebx, %ecx, %edx, %esi, %edi %ebp, . int $0x80, %eax. , , ; , C , -errno (, -EINVAL). C errno -1 . . syscalls (2) intro (2) .

, write write %eax, ( ) %ebx, ( ) %ecx ( ) %edx. %eax , , ( -1 -4095, ).

, ? /usr/include/linux/unistd.h. /usr/include/asm/unistd.h, , , /usr/include/asm/unistd_32.h, ( write __NR_write is 4). , /usr/include/linux/errno.h ( /usr/include/asm-generic/errno-base.h, - /usr/include/asm-generic/errno.h). , , , , .


, , int $0x80 - . , . , ​​ (vDSO; , ) , , , , . , , .

vsyscall, vDSO, . , , , . .

+11

- ( ) , "" , . C-, , .

, C sys_. , , man 2 lseek, sys_lseek:

off_t lseek(int fd, off_t offset, int whence);

, , HTML:

%ebx           %ecx    %edx
unsigned int   off_t   unsigned int
0

All Articles