Subversion Repositories Kolibri OS

Rev

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

  1.  
  2. .global ___chkstk
  3. .global __alloca
  4.  
  5. .section .text
  6.  
  7. #.def   ___chkstk;      .scl    2;      .type   32;     .endef
  8. #.def   __alloca;       .scl    2;      .type   32;     .endef
  9. ___chkstk:
  10. __alloca:
  11.         pushl   %ecx            /* save temp */
  12.         leal    8(%esp), %ecx   /* point past return addr */
  13.         subl    %eax, %ecx
  14.         cmpl    %fs:4, %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.         .ascii "Stack overflow"
  30.  
  31.  
  32.