在linux中,如何通过GNU ARM组件进行系统调用
到目前为止,我只知道如何通过gnu arm汇编退出程序在linux中,如何通过GNU ARM组件进行系统调用,linux,assembly,arm,gnu,system-calls,Linux,Assembly,Arm,Gnu,System Calls,到目前为止,我只知道如何通过gnu arm汇编退出程序 #exit(0) mov r0, #0 # return code mov r7, #1 # supervisor service number svc # call supervisor service 但是还有很多其他的系统调用,比如读、写、叉。。。我假设它们中的每一个都需要不同的服务编号、不同数量的寄存器作为参数以及关于如何使用寄存器的不同规则。我的问题是,在哪里可以获得关于为每一个组件编写程序集的信
#exit(0)
mov r0, #0 # return code
mov r7, #1 # supervisor service number
svc # call supervisor service
但是还有很多其他的系统调用,比如读、写、叉。。。我假设它们中的每一个都需要不同的服务编号、不同数量的寄存器作为参数以及关于如何使用寄存器的不同规则。我的问题是,在哪里可以获得关于为每一个组件编写程序集的信息。我搜索了谷歌,但关于这个主题的信息较少。你可以采用类似Android的仿生和/或使用的方法 下面是Bionic的libc/SYSCALLS.TXT
# this file is used to list all the syscalls that will be supported by
# the Bionic C library. It is used to automatically generate the syscall
# stubs, the list of syscall constants (__NR_xxxx) and the content of <linux/_unistd.h>
#
# each non comment line has the following format:
#
# return_type func_name[:syscall_name[:call_id]]([parameter_list]) (syscall_number|"stub")
#
# note that:
# - syscall_name correspond to the name of the syscall, which may differ from
# the exported function name (example: the exit syscall is implemented by the _exit()
# function, which is not the same as the standard C exit() function which calls it)
# The call_id parameter, given that func_name and syscall_name have
# been provided, allows the user to specify dispatch style syscalls.
# For example, socket() syscall on i386 actually becomes:
# socketcall(__NR_socket, 1, *(rest of args on stack)).
#
# - each parameter type is assumed to be stored on 32 bits, there is no plan to support
# 64-bit architectures at the moment
#
# - it there is "stub" instead of a syscall number, the tool will not generate any
# assembler template for the syscall; it's up to the bionic implementation to provide
# a relevant C stub
#
# - additionally, if the syscall number is different amoung ARM, and x86, MIPS use:
# return_type funcname[:syscall_name](parameters) arm_number,x86_number,mips_number
#
# the file is processed by a python script named gensyscalls.py
#
# process management
void _exit:exit_group (int) 248,252,246
void _exit_thread:exit (int) 1
pid_t __fork:fork (void) 2
<skipped rest of the file>
#此文件用于列出将由支持的所有系统调用
#仿生C库。它用于自动生成系统调用
#存根、系统调用常量列表(_NR_xxxx)和
#
#每个非注释行的格式如下:
#
#返回_type func_name[:syscall_name[:call_id]]([参数_列表])(syscall_编号|“存根”)
#
#请注意:
#-syscall\u name对应于系统调用的名称,该名称可能不同于
#导出的函数名(例如:exit syscall由_exit()实现)
#函数,它与调用它的标准C exit()函数不同)
#call_id参数,假定func_name和syscall_name
#允许用户指定分派样式的系统调用。
#例如,i386上的socket()syscall实际上变成:
#socketcall(_NR_socket,1,*(堆栈上的其余参数))。
#
#-假设每个参数类型存储在32位上,没有计划支持
#目前的64位体系结构
#
#-如果存在“存根”而不是系统调用号,该工具将不会生成任何
#系统调用的汇编程序模板;这取决于仿生实现提供什么
#相关的C存根
#
#-此外,如果系统调用号与ARM和x86不同,MIPS将使用:
#返回\u类型funcname[:syscall\u name](参数)arm\u编号、x86\u编号、mips\u编号
#
#该文件由名为gensyscalls.py的python脚本处理
#
#过程管理
无效-退出:退出-组(内部)248252246
void _exit_线程:exit(int)1
pid_t_____fork:fork(void)2
我会查看glibc
源代码,它们一定会有关于每个系统调用的信息。请看一下syscall()
宏(
),可能吧。我想这会给出系统调用号。你也可以看看。谢谢@auselen。一年后,我终于明白你说的话了。