在大会的Linux 64的命令行参数 [英] Linux 64 command line parameters in Assembly

查看:198
本文介绍了在大会的Linux 64的命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这说明适用于Linux的32位: 当一个Linux程序开始,所有指向命令行参数都存储在堆栈中。参数的数目被存储为0(%EBP),程序的名称被存储在图4(%EBP),和参数从8(%ebp的)存储

This description is valid for Linux 32 bit: When a Linux program begins, all pointers to command-line arguments are stored on the stack. The number of arguments is stored at 0(%ebp), the name of the program is stored at 4(%ebp), and the arguments are stored from 8(%ebp).

我需要的信息相同的64位。

I need the same information for 64 bit.

编辑: 我有工作code示例展示了如何使用ARGC,ARGV [0]和argv [1]: http://cubbi.com/fibonacci/asm.html

I have working code sample which shows how to use argc, argv[0] and argv[1]: http://cubbi.com/fibonacci/asm.html


.globl _start
_start:
    popq    %rcx        # this is argc, must be 2 for one argument
    cmpq    $2,%rcx
    jne     usage_exit
    addq    $8,%rsp     # skip argv[0]
    popq    %rsi        # get argv[1]
    call ...
...
}

看起来参数是在栈上。由于这code是不明确的,我问这个问题。我的猜测,我可以保持RSP在RBP,然后访问,8(%RBP),16(%RBP)等,这些参数使用0(%RBP)这是正确的?

It looks like parameters are on the stack. Since this code is not clear, I ask this question. My guess that I can keep rsp in rbp, and then access these parameters using 0(%rbp), 8(%rbp), 16(%rbp) etc. It this correct?

推荐答案

它看起来像3.4节的进程初始化的,特别是图3.9中已经提到的System V AMD64 ABI 介绍precisely你想知道什么。

It looks like section 3.4 Process Initialization, and specifically figure 3.9, in the already mentioned System V AMD64 ABI describes precisely what you want to know.

这篇关于在大会的Linux 64的命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆