mirror_ubuntu-kernels/tools/include/nolibc/compiler.h
Thomas Weißschuh ef32e9b6a3 tools/nolibc: move entrypoint specifics to compiler.h
The specific attributes for the _start entrypoint are duplicated for
each architecture.
Deduplicate it into a dedicated #define into compiler.h.

For clang compatibility, the epilogue will also need to be adapted, so
move that one, too.

Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20240807-nolibc-llvm-v2-5-c20f2f5fc7c2@weissschuh.net
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
2024-08-12 22:21:00 +02:00

31 lines
960 B
C

/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
/*
* NOLIBC compiler support header
* Copyright (C) 2023 Thomas Weißschuh <linux@weissschuh.net>
*/
#ifndef _NOLIBC_COMPILER_H
#define _NOLIBC_COMPILER_H
#if defined(__has_attribute)
# define __nolibc_has_attribute(attr) __has_attribute(attr)
#else
# define __nolibc_has_attribute(attr) 0
#endif
#define __nolibc_entrypoint __attribute__((optimize("Os", "omit-frame-pointer")))
#define __nolibc_entrypoint_epilogue() __builtin_unreachable()
#if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__)
#define _NOLIBC_STACKPROTECTOR
#endif /* defined(__SSP__) ... */
#if __nolibc_has_attribute(no_stack_protector)
# define __no_stack_protector __attribute__((no_stack_protector))
#else
# define __no_stack_protector __attribute__((__optimize__("-fno-stack-protector")))
#endif /* __nolibc_has_attribute(no_stack_protector) */
#endif /* _NOLIBC_COMPILER_H */