gcc - 我如何进一步了解 gcc 使用的编译过程?
问题描述
我试图对一些使用免费 pspsdk 开发的 psp 程序进行逆向工程
https://sourceforge.net/projects/minpspw/
我注意到我创建了一个函数来查看 MIPS 如何处理超过 4 个参数 (a0-a4)。我认识的每个人都告诉我他们被传递到堆栈上。令我惊讶的是,第 5 个参数实际上被传递给寄存器 t0 并且编译器甚至没有使用堆栈!
它还内联了一个函数,甚至没有使用 jal 或跳转到它。(明显的优化)。尽管确实有一个内存空间,您可以通过使用带有函数指针参数的 print 来仔细检查。执行的实际代码是自动内联的,不需要函数调用指令。
^^ 但这对于逆向工程师的尝试并没有真正让我受益......
这个版本的 gcc 有一个手册页。如果有人能够提供编译的人(如果有的话),安装需要几秒钟。太长了,我什至不知道如何可靠地参考信息
解决方案
如何传递参数由 ABI(应用程序二进制接口)指定。所以你必须找到相应的文件。
此外,还有不止一种这样的 ABI,即n32
和n64
。在.mips-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 后端有更多这样的评论。mips.c
在和中搜索“累积”或“累积” mips.h
。
推荐阅读
- sql - INSERT INTO 语句不起作用错误 3134
- ios - 用于位置栏的 Cordova iOS InAppBrowser 选项
- android - 使用 Retrofit 在 Mock Api 中处理错误
- java - 如何将数据从 Fragment 传递到 Tablayout 片段
- python - ZMQ pub/sub 用于传输 base64 图像
- linux - 在 Ubuntu 16.04 中安装 jenkins 时出现问题
- java - 分配了子类对象值的超类对象如何执行子类的重载方法?
- javascript - 更新 JS 节点依赖包中的代码会导致编译错误(在 npm/Vue.js 中)
- jquery - jquery 无法通过 ajax 动态添加内容
- android - 应用程序关闭时意图过滤器不起作用