From 4ffc2b13fd9c4e3844f98efa94905b6bbb9d74b1 Mon Sep 17 00:00:00 2001 From: tb Date: Sat, 30 Mar 2024 10:09:43 +0000 Subject: [PATCH] Fix LCRYPTO_UNUSED() in namespace builds If namespace builds are enabled, static links don't work due to missing _lcry_* symbols. Make LCRYPTO_UNUSED() match LCRYPTO_USED() with an extra deprecated attribute. This way we can remove the !LIBRESSL_INTERNAL #ifdef wrapping in public headers. ok beck joshua --- lib/libcrypto/hidden/crypto_namespace.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/hidden/crypto_namespace.h b/lib/libcrypto/hidden/crypto_namespace.h index 5bf9b4d4da7..3aec62f1f14 100644 --- a/lib/libcrypto/hidden/crypto_namespace.h +++ b/lib/libcrypto/hidden/crypto_namespace.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_namespace.h,v 1.2 2023/02/16 08:38:17 tb Exp $ */ +/* $OpenBSD: crypto_namespace.h,v 1.3 2024/03/30 10:09:43 tb Exp $ */ /* * Copyright (c) 2016 Philip Guenther * @@ -25,14 +25,17 @@ */ #ifdef LIBRESSL_NAMESPACE -# define LCRYPTO_UNUSED(x) typeof(x) x __attribute__((deprecated)) #ifdef LIBRESSL_CRYPTO_NAMESPACE -# define LCRYPTO_USED(x) __attribute__((visibility("hidden"))) \ +# define LCRYPTO_UNUSED(x) __attribute__((deprecated)) \ + __attribute__((visibility("hidden"))) \ + typeof(x) x asm("_lcry_"#x) +# define LCRYPTO_USED(x) __attribute__((visibility("hidden"))) \ typeof(x) x asm("_lcry_"#x) # define LCRYPTO_ALIAS1(pre,x) asm(".global "#pre#x"; "#pre#x" = _lcry_"#x) # define LCRYPTO_ALIAS(x) LCRYPTO_ALIAS1(,x); LCRYPTO_ALIAS1(_libre_,x) #else -# define LCRYPTO_USED(x) typeof(x) x asm("_libre_"#x) +# define LCRYPTO_UNUSED(x) typeof(x) x __attribute__((deprecated)) +# define LCRYPTO_USED(x) typeof(x) x asm("_libre_"#x) #endif #else # define LCRYPTO_UNUSED(x) -- 2.20.1