Are C stack variables stored in reverse?

后端 未结 3 2035
无人共我
无人共我 2020-12-07 02:47

I\'m trying to understand how C allocates memory on stack. I always thought variables on stack could be depicted like structs member variables, they occupy successive, conti

3条回答
  •  Happy的楠姐
    2020-12-07 03:19

    Depends on the compiler and platform. The same thing can be done in more than one way as long it is done consistently by a program (this case the compiler translation to assembly, i.e. machine code) and the platform supports it (good compilers try to optimize assembly to get the “most” of each platform).

    A very good source to deeply understand what goes behind the scenes of c, what happens when compiling a program and why they happen, is the free book Reverse Engineering for Beginners (Understanding Assembly Language) by Dennis Yurichev, the latest version can be found at his site.

提交回复
热议问题