/* Copyright (C) 2021 Rain */ /* This file is part of XNIX. */ /* XNIX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) and later version. */ /* XNIX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ /* You should have received a copy of the GNU General Public License along with XNIX. If not, see . */ #ifndef _SCHK_H #define _SCHK_H #include #include #include #include #include void __stack_chk_fail(void); #define schk_init() \ __uint64_t old_sp = get_rsp(); \ syslog(" entering function "); \ syslog(__FUNCTION__); \ if (old_sp < 0x3000) { \ syslog("#1#PANIC: SP < 0x3000\n"); \ __stack_chk_fail(); \ } \ if (old_sp < 0x4000) \ syslog("#2#WARNING: SP < 0x4000 now"); \ else if (old_sp < 0x5000) \ syslog("#3#WARNING: SP < 0x5000 now"); \ else if (old_sp < 0x6000) \ syslog("#4#WARNING: SP < 0x6000 now"); #define schk_leave() \ if (old_sp != get_rsp()) \ __stack_chk_fail(); #endif