Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
x86-64 Linux NASM(YASM)的系统调用详细说明_Linux_X86 64_Nasm_System Calls - Fatal编程技术网

x86-64 Linux NASM(YASM)的系统调用详细说明

x86-64 Linux NASM(YASM)的系统调用详细说明,linux,x86-64,nasm,system-calls,Linux,X86 64,Nasm,System Calls,我找到了x86-64模式的系统调用列表(带参数): 但是我在哪里可以得到这个系统调用的详细描述呢 例如,在其他情况下,除了0102o(rw,create),哪些标志可用于“打开”系统调用: 只读、只读等 SECTION .data message: db 'Hello, world!',0x0a length: equ $-message fname db "result" fd dq 0 SECTION .

我找到了x86-64模式的系统调用列表(带参数): 但是我在哪里可以得到这个系统调用的详细描述呢

例如,在其他情况下,除了0102o(rw,create),哪些标志可用于“打开”系统调用: 只读、只读等

SECTION .data
    message: db 'Hello, world!',0x0a    
    length:    equ    $-message        
    fname    db "result"
    fd       dq 0

SECTION .text
global _start   
_start:
        mov rax, 2            ; 'open' syscall
        mov rdi, fname        ; file name
        mov rsi, 0102o        ; read and write mode, create if not
        mov rdx, 0666o        ; permissions set
        syscall

        mov [fd], rax

        mov    rax, 1          ; 'write' syscall
        mov    rdi, [fd]       ; file descriptor
        mov    rsi, message    ; message address
        mov    rdx, length     ; message string length
        syscall

        mov rax, 3             ; 'close' syscall
        mov rdi, [fd]          ; file descriptor  
        syscall 

        mov    rax, 60        
        mov    rdi, 0        
        syscall
基于来源(可能是)
如何理解它,可以使用哪些(打开的所有标记的列表?

系统调用的文档在手册页的第2节和/或源代码中的注释中

手册页以以下内容开头:

   #include <sys/types.h>
   #include <sys/stat.h>
   #include <fcntl.h>

   int open(const char *pathname, int flags);
   int open(const char *pathname, int flags, mode_t mode);
#包括
#包括
#包括
int open(常量字符*路径名,int标志);
int open(常量字符*路径名、int标志、模式);
参数标志必须包括以下访问模式之一:O_RDONLYO_WRONLYO_RDWR。这些请求分别以只读、只读或读/写方式打开文件

此外,零个或多个文件创建标志和文件状态标志可以是按位的,也可以是按位的。文件创建标志为O_createO_EXCLO_NOCTTYO_TRUNC


这些值可以在系统头文件中轻松查找。

grep-i 0102/usr/include/asm/unistd_64.h-无。怎么服用?@Alex0102o:我不明白。该文件是一个syscall条目号列表:和flags参数无关。标志位于
/usr/include/bits/fcntl.h
中,其中0102显然是
O|RDWR | O|u CREAT
(至少在Fedora 17-64中是这样)。wallyk,在/usr/include/bits/fcntl.h中是这样的(Debian Lenny 64位)谢谢!(对不起,我的英语不好)0102我是从32位nasm取的。@Alex0102o:不客气。请确保通过单击我的答案旁边的复选标记“接受”我的答案。当你有足够的声誉时,你也可以对好答案投赞成票(对坏答案投反对票)。@wallyk#include是关于c,而不是asm。在nasm中有没有一种方法可以包含这些符号?SO中的其他答案也说“使用名称,而不是数字”,但nasm当然不承认Ordonly。