我试着对一些用免费的pspsdk开发的psp程序进行逆向工程。
https://sourceforge.net/projects/minpspw/
我注意到我创建了一个函数来查看MIPS如何处理4个以上的参数(a0-a4)。我认识的每个人都告诉我,它们会被传递到堆栈中。令我惊讶的是,第5个参数实际上传递给了寄存器t0,而编译器甚至没有使用堆栈!
它还内联了一个函数,甚至没有使用jal或跳转到它。(明显的优化)。尽管确实有一个内存空间,你可以通过函数指针参数使用print来进行双重检查。实际执行的代码是自动内联的,不需要函数调用指令。
^^,但这对我的反向工程尝试并没有真正的好处...
有一个关于这个版本的gcc的手册页。如果有人能够提供用于编译的man,则只需几秒钟即可完成安装。它太长了,我甚至不知道如何可靠地参考信息
发布于 2020-01-24 17:50:07
如何传递参数由ABI (应用程序二进制接口)指定。所以你必须找到各自的文档。
此外,存在不止一个这样的ABI,即n32和n64。在mips-gcc的案例中,一些决策在类似于./gcc/config/mips/mips.h的GCC资源中进行了评论
/* This structure has to cope with two different argument allocation
schemes. Most MIPS ABIs view the arguments as a structure, of which
the first N words go in registers and the rest go on the stack. If I
< N, the Ith word might go in Ith integer argument register or in a
floating-point register. For these ABIs, we only need to remember
the offset of the current argument into the structure.
The EABI instead allocates the integer and floating-point arguments
separately. The first N words of FP arguments go in FP registers,
the rest go on the stack. Likewise, the first N words of the other
arguments go in integer registers, and the rest go on the stack. We
need to maintain three counts: the number of integer registers used,
the number of floating-point registers used, and the number of words
passed on the stack.
We could keep separate information for the two ABIs (a word count for
the standard ABIs, and three separate counts for the EABI). But it
seems simpler to view the standard ABIs as forms of EABI that do not
allocate floating-point registers.
So for the standard ABIs, the first N words are allocated to integer
registers, and mips_function_arg decides on an argument-by-argument
basis whether that argument should really go in an integer register,
or in a floating-point one. */在mips backend中有更多这样的评论。在mips.c和mips.h中搜索"cumulative“或"CUMULATIVE”。
https://stackoverflow.com/questions/59892138
复制相似问题