Storing data under the stack pointer?

Looking at the disassembly (along with the command trace) of ld.so installed in Ubuntu 9.04, I swear that from time to time I see data stored under the stack pointer (i.e., outside the top of the stack). It seems crazy to me, but perhaps it is more common than I think. Does this happen often?

Here is what I see:

ebp: 0xBF8269E8, esp: 0xBF8269DC

c98:       8b 45 f0                mov    -0x10(%ebp),%eax
c9b:       8d 14 06                lea    (%esi,%eax,1),%edx
c9e:       8b 83 28 03 00 00       mov    0x328(%ebx),%eax
ca4:       3b 50 04                cmp    0x4(%eax),%edx
+3
source share
2 answers

What exactly makes you think that the material is stored under the stack pointer. All I see is the negative offset from ebp, which is the frame pointer.

This is usually used as a pointer to the next stack stack up from the current one for a number of reasons.

  • ebp - , ( ebp) locals ( ebp). -0x10(%ebp) , - .
  • , %esp %ebp .

, - %esp, , .

"" :

     +------------------------+
     | Parameters passed to x |
     +------------------------+
     | Return address         |
%ebp +------------------------+
     | Locals for x           |
%esp +------------------------+

( , , , ), :

  • (push, push,...).
  • %ebp (push %ebp).
  • %ebp %esp% (mov %ebp, %esp).
  • (call XYZ).
  • callle locals (sub %esp,N).
  • callle (%ebp+N) , (%ebp-N) .

:

  • %esp %ebp (mov %esp, %ebp).
  • calllee (ret).
  • %ebp (pop %ebp).
  • caller (add %esp,N).
+1

. ABI.

PowerPC ( ?) . (, .) , -. + , .

+1

Source: https://habr.com/ru/post/1733828/


All Articles