gcc pushes the arguments in a particular order. What is the order and why?
Answer: gcc pushes arguments in reverse order, last argument first. Because the stack grows down on the x86 (and PDP-11), this means that the first argument (last one pushed) will have the lowest address in memory, just above the function's return address. This way, the called function can find its first argument without knowing exactly how many and what types of other arguments it was called with. Knowing the location and type of the first argument, the function can then locate the second argument (if there is one), and so on. The printf()function depends on this property because it uses its first argument (the format string) to determine how many and what types of additional arguments it was called with.
本文详细解释了GCC编译器如何按逆序推送参数至栈中,即最后一个参数最先被推送。这种做法使得函数能够通过定位首个参数来确定其余参数的数量及类型,如printf函数即依赖这一特性来确定其格式字符串及其他参数。
911

被折叠的 条评论
为什么被折叠?



