lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240807-nolibc-llvm-v2-6-c20f2f5fc7c2@weissschuh.net>
Date: Wed, 07 Aug 2024 23:51:42 +0200
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Willy Tarreau <w@....eu>, Shuah Khan <shuah@...nel.org>
Cc: linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org, 
 Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH v2 06/15] tools/nolibc: compiler: use attribute((naked)) if
 available

The current entrypoint attributes optimize("Os", "omit-frame-pointer")
are intended to avoid all compiler generated code, like function
porologue and epilogue.
This is the exact usecase implemented by the attribute "naked".

Unfortunately this is not implemented by GCC for all targets,
so only use it where available.
This also provides compatibility with clang, which recognizes the
"naked" attribute but not the previously used attribute "optimized".

Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
 tools/include/nolibc/compiler.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/include/nolibc/compiler.h b/tools/include/nolibc/compiler.h
index 14a854929910..e4cb5cf772ee 100644
--- a/tools/include/nolibc/compiler.h
+++ b/tools/include/nolibc/compiler.h
@@ -12,8 +12,13 @@
 #  define __nolibc_has_attribute(attr) 0
 #endif
 
-#define __nolibc_naked __attribute__((optimize("Os", "omit-frame-pointer")))
-#define __nolibc_naked_epilogue() __builtin_unreachable()
+#if __nolibc_has_attribute(naked)
+#  define __nolibc_naked __attribute__((naked))
+#  define __nolibc_naked_epilogue()
+#else
+#  define __nolibc_naked __attribute__((optimize("Os", "omit-frame-pointer")))
+#  define __nolibc_naked_epilogue() __builtin_unreachable()
+#endif /* __nolibc_has_attribute(naked) */
 
 #if defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__) || defined(__SSP_EXPLICIT__)
 

-- 
2.46.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ