Subversion Repositories Kolibri OS

Rev

Rev 1693 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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