首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我如何才能进一步了解gcc使用的编译过程?

我如何才能进一步了解gcc使用的编译过程?
EN

Stack Overflow用户
提问于 2020-01-24 15:31:12
回答 1查看 22关注 0票数 0

我试着对一些用免费的pspsdk开发的psp程序进行逆向工程。

https://sourceforge.net/projects/minpspw/

我注意到我创建了一个函数来查看MIPS如何处理4个以上的参数(a0-a4)。我认识的每个人都告诉我,它们会被传递到堆栈中。令我惊讶的是,第5个参数实际上传递给了寄存器t0,而编译器甚至没有使用堆栈!

它还内联了一个函数,甚至没有使用jal或跳转到它。(明显的优化)。尽管确实有一个内存空间,你可以通过函数指针参数使用print来进行双重检查。实际执行的代码是自动内联的,不需要函数调用指令。

^^,但这对我的反向工程尝试并没有真正的好处...

有一个关于这个版本的gcc的手册页。如果有人能够提供用于编译的man,则只需几秒钟即可完成安装。它太长了,我甚至不知道如何可靠地参考信息

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-24 17:50:07

如何传递参数由ABI (应用程序二进制接口)指定。所以你必须找到各自的文档。

此外,存在不止一个这样的ABI,即n32n64。在mips-gcc的案例中,一些决策在类似于./gcc/config/mips/mips.h的GCC资源中进行了评论

代码语言:javascript
复制
/* 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.cmips.h中搜索"cumulative“或"CUMULATIVE”。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59892138

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档