diff --git a/musl_src.gni b/musl_src.gni index 230f3a0761703c30cca7b72c4e069738e7ef2220..8a2c8655f8f2315c1b3fa11a8946d709be5816ff 100644 --- a/musl_src.gni +++ b/musl_src.gni @@ -1883,6 +1883,7 @@ musl_inc_sys_files = [ "include/sys/signal.h", "include/sys/socket.h", "include/sys/soundcard.h", + "include/sys/sspret.h", "include/sys/statfs.h", "include/sys/stat.h", "include/sys/statvfs.h", @@ -2045,6 +2046,7 @@ musl_src_porting_file = [ "include/stdlib.h", "include/string.h", "include/sys/stat.h", + "include/sys/sspret.h", "include/fortify/fcntl.h", "include/fortify/fortify.h", "include/fortify/poll.h", diff --git a/porting/linux/user/include/sys/sspret.h b/porting/linux/user/include/sys/sspret.h new file mode 100644 index 0000000000000000000000000000000000000000..8256ad5ffe663627fba6c7c290d8b14332c75d8f --- /dev/null +++ b/porting/linux/user/include/sys/sspret.h @@ -0,0 +1,40 @@ +#ifndef _SSPRET_H +#define _SSPRET_H + +#if defined(__SSP_RET_STRONG__) || defined(__SSP_RET_ALL__) +#if defined(__aarch64__) +# define SSPRET_CALC_RETCOOKIE(reg) \ + eor reg, reg, x30 + +# define SSPRET_LOAD_COOKIE(x, reg) \ + mov reg, x29 + +# define SSPRET_SETUP(x, reg) \ + SSPRET_LOAD_COOKIE(x, reg); \ + SSPRET_CALC_RETCOOKIE(reg) + +# define SSPRET_CHECK(x, reg) \ + SSPRET_LOAD_COOKIE(x, x9); \ + SSPRET_CALC_RETCOOKIE(x9); \ + subs reg, reg, x9; \ + cbz reg, 6788f; \ + brk #0x1; \ +6788: + +# define SSPRET_PUSH(reg) \ + str reg, [sp, #-16]! + +# define SSPRET_POP(reg) \ + ldr reg, [sp, #16]! + +#endif /* __aarch64__ */ +#else +# define SSPRET_CALC_RETCOOKIE(reg) +# define SSPRET_LOAD_COOKIE(x, reg) +# define SSPRET_SETUP(x, reg) +# define SSPRET_CHECK(x, reg) +# define SSPRET_PUSH(reg) +# define SSPRET_POP(reg) +#endif /* __SSP_RET_STRONG__ || __SSP_RET_ALL__ */ + +#endif /* _SSPRET_H */