From 55ae52fdf81cdcc7d1bf7b883953e2639701d21b Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 29 Apr 2021 14:54:15 +0200 Subject: Kernel: Enable building the kernel with -flto GCC with -flto is more aggressive when it comes to inlining and discarding functions which is why we must mark some of the functions as NEVER_INLINE (because they contain asm labels which would be duplicated in the object files if the compiler decides to inline the function elsewhere) and __attribute__((used)) for others so that GCC doesn't discard them. --- Kernel/Arch/x86/SafeMem.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Kernel/Arch/x86/SafeMem.h') diff --git a/Kernel/Arch/x86/SafeMem.h b/Kernel/Arch/x86/SafeMem.h index 3b984a663e..66d17fb74e 100644 --- a/Kernel/Arch/x86/SafeMem.h +++ b/Kernel/Arch/x86/SafeMem.h @@ -14,14 +14,14 @@ namespace Kernel { struct RegisterState; -[[nodiscard]] bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, void*& fault_at); -[[nodiscard]] ssize_t safe_strnlen(const char* str, size_t max_n, void*& fault_at); -[[nodiscard]] bool safe_memset(void* dest_ptr, int c, size_t n, void*& fault_at); -[[nodiscard]] Optional safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional safe_atomic_exchange_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional safe_atomic_load_relaxed(volatile u32* var); -[[nodiscard]] bool safe_atomic_store_relaxed(volatile u32* var, u32 val); -[[nodiscard]] Optional safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val); +[[nodiscard]] bool safe_memcpy(void* dest_ptr, const void* src_ptr, size_t n, void*& fault_at) __attribute__((used)); +[[nodiscard]] ssize_t safe_strnlen(const char* str, size_t max_n, void*& fault_at) __attribute__((used)); +[[nodiscard]] bool safe_memset(void* dest_ptr, int c, size_t n, void*& fault_at) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_fetch_add_relaxed(volatile u32* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_exchange_relaxed(volatile u32* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_load_relaxed(volatile u32* var) __attribute__((used)); +[[nodiscard]] bool safe_atomic_store_relaxed(volatile u32* var, u32 val) __attribute__((used)); +[[nodiscard]] Optional safe_atomic_compare_exchange_relaxed(volatile u32* var, u32& expected, u32 val) __attribute__((used)); [[nodiscard]] ALWAYS_INLINE Optional safe_atomic_fetch_and_relaxed(volatile u32* var, u32 val) { -- cgit v1.2.3