1 /* 2 * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "sdkconfig.h" 8 #include "esp_system.h" 9 #include "esp_random.h" 10 #include "esp_rom_sys.h" 11 12 #if CONFIG_COMPILER_STACK_CHECK 13 14 #include "esp_log.h" 15 const static char *TAG = "stack_chk"; 16 17 void *__stack_chk_guard = NULL; 18 19 static void __attribute__ ((constructor)) __esp_stack_guard_setup(void)20__esp_stack_guard_setup (void) 21 { 22 ESP_LOGD(TAG, "Intialize random stack guard"); 23 __stack_chk_guard = (void *)esp_random(); 24 } 25 __stack_chk_fail(void)26IRAM_ATTR void __stack_chk_fail (void) 27 { 28 esp_system_abort(DRAM_STR("Stack smashing protect failure!")); 29 } 30 31 #endif 32