| 448 | // include: runtime_stack_check.js |
| 449 | // Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode. |
| 450 | function writeStackCookie() { |
| 451 | var max = _emscripten_stack_get_end(); |
| 452 | assert((max & 3) == 0); |
| 453 | // If the stack ends at address zero we write our cookies 4 bytes into the |
| 454 | // stack. This prevents interference with the (separate) address-zero check |
| 455 | // below. |
| 456 | if (max == 0) { |
| 457 | max += 4; |
| 458 | } |
| 459 | // The stack grow downwards towards _emscripten_stack_get_end. |
| 460 | // We write cookies to the final two words in the stack and detect if they are |
| 461 | // ever overwritten. |
| 462 | HEAPU32[((max)>>2)] = 0x02135467; |
| 463 | HEAPU32[(((max)+(4))>>2)] = 0x89BACDFE; |
| 464 | // Also test the global address 0 for integrity. |
| 465 | HEAPU32[0] = 0x63736d65; /* 'emsc' */ |
| 466 | } |
| 467 | |
| 468 | function checkStackCookie() { |
| 469 | if (ABORT) return; |