Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1.  
  2. .global ___chkstk
  3. .global __alloca
  4.  
  5. .section .text
  6.  
  7. .align 4
  8. ___chkstk:
  9. __alloca:
  10.         pushl   %ecx            /* save temp */
  11.         leal    8(%esp), %ecx   /* point past return addr */
  12.         subl    %eax, %ecx
  13.         call *__imp__GetStackBase
  14.         cmpl    %eax, %ecx      # check low stack limit
  15.         jb      1f
  16.  
  17.         movl    %esp, %eax      /* save old stack pointer */
  18.         movl    %ecx, %esp      /* decrement stack */
  19.         movl    (%eax), %ecx    /* recover saved temp */
  20.         movl    4(%eax), %eax   /* recover return address */
  21.  
  22.         /* Push the return value back.  Doing this instead of just
  23.            jumping to %eax preserves the cached call-return stack
  24.            used by most modern processors.  */
  25.         pushl   %eax
  26.         ret
  27. 1:
  28.         int3                    #trap to debugger.
  29.                                 #Oh wait... there is no kernel debugger
  30.         .ascii "Stack overflow"
  31.  
  32.