簡體   English   中英

在Linux中,如何通過GNU ARM程序集進行系統調用

[英]In linux, how to do system calls through GNU ARM assembly

到現在為止,我只知道如何通過gnu arm匯編程序退出程序。

#exit(0)
mov r0, #0    # return code
mov r7, #1    # supervisor service number
svc           # call supervisor service

但是仍然有許多其他的系統調用,例如讀,寫,分叉...我想它們每個都將需要不同的服務號,不同數量的寄存器作為參數以及關於如何使用寄存器的不同規則。 我的問題是,在哪里可以獲得有關每個組件編寫匯編的信息。 我搜索了google,但有關該主題的信息較少。

您可以采用類似於Android的Bionic的方法,並通過一些元數據和腳本生成sys調用存根,也 可以直接使用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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM