36 lines · c
1/* SPDX-License-Identifier: LGPL-2.1 OR MIT */2/*3 * NOLIBC compiler support header4 * Copyright (C) 2023 Thomas Weißschuh <linux@weissschuh.net>5 */6#ifndef _NOLIBC_COMPILER_H7#define _NOLIBC_COMPILER_H8 9#if defined(__has_attribute)10# define __nolibc_has_attribute(attr) __has_attribute(attr)11#else12# define __nolibc_has_attribute(attr) 013#endif14 15#if __nolibc_has_attribute(naked)16# define __nolibc_entrypoint __attribute__((naked))17# define __nolibc_entrypoint_epilogue()18#else19# define __nolibc_entrypoint __attribute__((optimize("Os", "omit-frame-pointer")))20# define __nolibc_entrypoint_epilogue() __builtin_unreachable()21#endif /* __nolibc_has_attribute(naked) */22 23#if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__)24 25#define _NOLIBC_STACKPROTECTOR26 27#endif /* defined(__SSP__) ... */28 29#if __nolibc_has_attribute(no_stack_protector)30# define __no_stack_protector __attribute__((no_stack_protector))31#else32# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector")))33#endif /* __nolibc_has_attribute(no_stack_protector) */34 35#endif /* _NOLIBC_COMPILER_H */36