]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
dlwrap: use different macro for library soname in generated code
authorDaiki Ueno <ueno@gnu.org>
Tue, 23 Jul 2024 02:25:18 +0000 (11:25 +0900)
committerDaiki Ueno <ueno@gnu.org>
Tue, 23 Jul 2024 06:12:58 +0000 (15:12 +0900)
As GnuTLS opt in for manual initialization of dlopen'ed libraries,
config.h shouldn't define the SONAME macro used in the generated code.

Signed-off-by: Daiki Ueno <ueno@gnu.org>
devel/generate-dlwrap.sh
lib/dlwrap/brotlidec.c
lib/dlwrap/brotlienc.c
lib/dlwrap/oqs.c
lib/dlwrap/zlib.c
lib/dlwrap/zstd.c

index 3e253d92281a075ce7b4227bfc259009eb2ca48e..0394655bbfd38eaac24a1a7d34e497f6e447f411 100755 (executable)
@@ -21,20 +21,28 @@ DST="$srcdir/lib/$DLWRAP"
 
 echo "Generating $DST/zlib.h"
 
-"$DLWRAP" --input /usr/include/zlib.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/z.syms" --license-file "$SRC/z.license" --soname Z_LIBRARY_SONAME --prefix gnutls_zlib --header-guard GNUTLS_LIB_DLWRAP_ZLIB_H_ --include "<zlib.h>"
+"$DLWRAP" --input /usr/include/zlib.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/z.syms" --license-file "$SRC/z.license" --soname Z_LIBRARY_SONAME_UNUSED --prefix gnutls_zlib --header-guard GNUTLS_LIB_DLWRAP_ZLIB_H_ --include "<zlib.h>"
 
 echo "Generating $DST/zstd.h"
 
-"$DLWRAP" --input /usr/include/zstd.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/zstd.syms" --license-file "$SRC/zstd.license" --soname ZSTD_LIBRARY_SONAME --prefix gnutls_zstd --header-guard GNUTLS_LIB_DLWRAP_ZSTD_H_ --include "<zstd.h>"
+"$DLWRAP" --input /usr/include/zstd.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/zstd.syms" --license-file "$SRC/zstd.license" --soname ZSTD_LIBRARY_SONAME_UNUSED --prefix gnutls_zstd --header-guard GNUTLS_LIB_DLWRAP_ZSTD_H_ --include "<zstd.h>"
 
 echo "Generating $DST/brotlienc.h"
 
-"$DLWRAP" --input /usr/include/brotli/encode.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/brotlienc.syms" --license-file "$SRC/brotli.license" --soname BROTLIENC_LIBRARY_SONAME --prefix gnutls_brotlienc --loader-basename brotlienc --header-guard GNUTLS_LIB_DLWRAP_BROTLIENC_H_ --include "<brotli/encode.h>"
+"$DLWRAP" --input /usr/include/brotli/encode.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/brotlienc.syms" --license-file "$SRC/brotli.license" --soname BROTLIENC_LIBRARY_SONAME_UNUSED --prefix gnutls_brotlienc --loader-basename brotlienc --header-guard GNUTLS_LIB_DLWRAP_BROTLIENC_H_ --include "<brotli/encode.h>"
 
 echo "Generating $DST/brotlidec.h"
 
-"$DLWRAP" --input /usr/include/brotli/decode.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/brotlidec.syms" --license-file "$SRC/brotli.license" --soname BROTLIDEC_LIBRARY_SONAME --prefix gnutls_brotlidec --loader-basename brotlidec --header-guard GNUTLS_LIB_DLWRAP_BROTLIDEC_H_ --include "<brotli/decode.h>"
+"$DLWRAP" --input /usr/include/brotli/decode.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/brotlidec.syms" --license-file "$SRC/brotli.license" --soname BROTLIDEC_LIBRARY_SONAME_UNUSED --prefix gnutls_brotlidec --loader-basename brotlidec --header-guard GNUTLS_LIB_DLWRAP_BROTLIDEC_H_ --include "<brotli/decode.h>"
 
 echo "Generating $DST/oqs.h"
 
-"$DLWRAP" --input /usr/include/oqs/oqs.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/oqs.syms" --license "SPDX-License-Identifier: MIT" --soname OQS_LIBRARY_SONAME --prefix gnutls_oqs --header-guard GNUTLS_LIB_DLWRAP_OQS_H_ --include "<oqs/oqs.h>"
+"$DLWRAP" --input /usr/include/oqs/oqs.h -o "$DST" --clang-resource-dir $(clang -print-resource-dir) --symbol-file "$SRC/oqs.syms" --license "SPDX-License-Identifier: MIT" --soname OQS_LIBRARY_SONAME_UNUSED --prefix gnutls_oqs --header-guard GNUTLS_LIB_DLWRAP_OQS_H_ --include "<oqs/oqs.h>"
+
+sed -i '/^#include <oqs\/oqs.h>/i\
+/* Local modification: remove this once liboqs 0.10.2 is released */\
+#include "config.h"\
+#if !HAVE_DECL_OQS_SHA3_SET_CALLBACKS\
+#include "liboqs/backport/sha3_ops.h"\
+#endif\
+' "$DST/oqs.h"
index 45c9b4b25916925f105003c191b1477cbb2dbe68..15cee63bd67567b1227caf83e25c350cac0cc8ec 100644 (file)
 #include <errno.h>
 #include <stdlib.h>
 
-/* If BROTLIDEC_LIBRARY_SONAME is defined, dlopen handle can be automatically
+/* If BROTLIDEC_LIBRARY_SONAME_UNUSED is defined, dlopen handle can be automatically
  * set; otherwise, the caller needs to call
  * gnutls_brotlidec_ensure_library with soname determined at run time.
  */
-#ifdef BROTLIDEC_LIBRARY_SONAME
+#ifdef BROTLIDEC_LIBRARY_SONAME_UNUSED
 
 static void
 ensure_library (void)
 {
-  if (gnutls_brotlidec_ensure_library (BROTLIDEC_LIBRARY_SONAME, RTLD_LAZY | RTLD_LOCAL) < 0)
+  if (gnutls_brotlidec_ensure_library (BROTLIDEC_LIBRARY_SONAME_UNUSED, RTLD_LAZY | RTLD_LOCAL) < 0)
     abort ();
 }
 
@@ -47,11 +47,11 @@ static pthread_once_t dlopen_once = PTHREAD_ONCE_INIT;
 
 #endif /* !GNUTLS_BROTLIDEC_ENABLE_PTHREAD */
 
-#else /* BROTLIDEC_LIBRARY_SONAME */
+#else /* BROTLIDEC_LIBRARY_SONAME_UNUSED */
 
 #define ENSURE_LIBRARY do {} while (0)
 
-#endif /* !BROTLIDEC_LIBRARY_SONAME */
+#endif /* !BROTLIDEC_LIBRARY_SONAME_UNUSED */
 
 static void *gnutls_brotlidec_dlhandle;
 
@@ -147,7 +147,10 @@ void
 gnutls_brotlidec_unload_library (void)
 {
   if (gnutls_brotlidec_dlhandle)
-    dlclose (gnutls_brotlidec_dlhandle);
+    {
+      dlclose (gnutls_brotlidec_dlhandle);
+      gnutls_brotlidec_dlhandle = NULL;
+    }
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-macros"
@@ -160,8 +163,6 @@ gnutls_brotlidec_unload_library (void)
 #undef FUNC
 
 #pragma GCC diagnostic pop
-
-#undef RESET_SYMBOL
 }
 
 #else /* GNUTLS_BROTLIDEC_ENABLE_DLOPEN */
index 9dd8ff37c636f58025db80142861c8a3f8597e1a..1deff747e212362daae440fc48a351f88a97fa75 100644 (file)
 #include <errno.h>
 #include <stdlib.h>
 
-/* If BROTLIENC_LIBRARY_SONAME is defined, dlopen handle can be automatically
+/* If BROTLIENC_LIBRARY_SONAME_UNUSED is defined, dlopen handle can be automatically
  * set; otherwise, the caller needs to call
  * gnutls_brotlienc_ensure_library with soname determined at run time.
  */
-#ifdef BROTLIENC_LIBRARY_SONAME
+#ifdef BROTLIENC_LIBRARY_SONAME_UNUSED
 
 static void
 ensure_library (void)
 {
-  if (gnutls_brotlienc_ensure_library (BROTLIENC_LIBRARY_SONAME, RTLD_LAZY | RTLD_LOCAL) < 0)
+  if (gnutls_brotlienc_ensure_library (BROTLIENC_LIBRARY_SONAME_UNUSED, RTLD_LAZY | RTLD_LOCAL) < 0)
     abort ();
 }
 
@@ -47,11 +47,11 @@ static pthread_once_t dlopen_once = PTHREAD_ONCE_INIT;
 
 #endif /* !GNUTLS_BROTLIENC_ENABLE_PTHREAD */
 
-#else /* BROTLIENC_LIBRARY_SONAME */
+#else /* BROTLIENC_LIBRARY_SONAME_UNUSED */
 
 #define ENSURE_LIBRARY do {} while (0)
 
-#endif /* !BROTLIENC_LIBRARY_SONAME */
+#endif /* !BROTLIENC_LIBRARY_SONAME_UNUSED */
 
 static void *gnutls_brotlienc_dlhandle;
 
@@ -147,7 +147,10 @@ void
 gnutls_brotlienc_unload_library (void)
 {
   if (gnutls_brotlienc_dlhandle)
-    dlclose (gnutls_brotlienc_dlhandle);
+    {
+      dlclose (gnutls_brotlienc_dlhandle);
+      gnutls_brotlienc_dlhandle = NULL;
+    }
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-macros"
@@ -160,8 +163,6 @@ gnutls_brotlienc_unload_library (void)
 #undef FUNC
 
 #pragma GCC diagnostic pop
-
-#undef RESET_SYMBOL
 }
 
 #else /* GNUTLS_BROTLIENC_ENABLE_DLOPEN */
index d7fcc9c80c1b02feb9079dd8c8a98bbb8a60b8cc..c05f883127231a27706df106bc797701c842e9da 100644 (file)
 #include <errno.h>
 #include <stdlib.h>
 
-/* If OQS_LIBRARY_SONAME is defined, dlopen handle can be automatically
+/* If OQS_LIBRARY_SONAME_UNUSED is defined, dlopen handle can be automatically
  * set; otherwise, the caller needs to call
  * gnutls_oqs_ensure_library with soname determined at run time.
  */
-#ifdef OQS_LIBRARY_SONAME
+#ifdef OQS_LIBRARY_SONAME_UNUSED
 
 static void
 ensure_library (void)
 {
-  if (gnutls_oqs_ensure_library (OQS_LIBRARY_SONAME, RTLD_LAZY | RTLD_LOCAL) < 0)
+  if (gnutls_oqs_ensure_library (OQS_LIBRARY_SONAME_UNUSED, RTLD_LAZY | RTLD_LOCAL) < 0)
     abort ();
 }
 
@@ -47,11 +47,11 @@ static pthread_once_t dlopen_once = PTHREAD_ONCE_INIT;
 
 #endif /* !GNUTLS_OQS_ENABLE_PTHREAD */
 
-#else /* OQS_LIBRARY_SONAME */
+#else /* OQS_LIBRARY_SONAME_UNUSED */
 
 #define ENSURE_LIBRARY do {} while (0)
 
-#endif /* !OQS_LIBRARY_SONAME */
+#endif /* !OQS_LIBRARY_SONAME_UNUSED */
 
 static void *gnutls_oqs_dlhandle;
 
@@ -147,7 +147,10 @@ void
 gnutls_oqs_unload_library (void)
 {
   if (gnutls_oqs_dlhandle)
-    dlclose (gnutls_oqs_dlhandle);
+    {
+      dlclose (gnutls_oqs_dlhandle);
+      gnutls_oqs_dlhandle = NULL;
+    }
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-macros"
@@ -160,8 +163,6 @@ gnutls_oqs_unload_library (void)
 #undef FUNC
 
 #pragma GCC diagnostic pop
-
-#undef RESET_SYMBOL
 }
 
 #else /* GNUTLS_OQS_ENABLE_DLOPEN */
index 455485c63fba26980f157ebeda8adb5a4950ae52..878070c0a47cedcb43955b584bb09b5b900432ec 100644 (file)
 #include <errno.h>
 #include <stdlib.h>
 
-/* If Z_LIBRARY_SONAME is defined, dlopen handle can be automatically
+/* If Z_LIBRARY_SONAME_UNUSED is defined, dlopen handle can be automatically
  * set; otherwise, the caller needs to call
  * gnutls_zlib_ensure_library with soname determined at run time.
  */
-#ifdef Z_LIBRARY_SONAME
+#ifdef Z_LIBRARY_SONAME_UNUSED
 
 static void
 ensure_library (void)
 {
-  if (gnutls_zlib_ensure_library (Z_LIBRARY_SONAME, RTLD_LAZY | RTLD_LOCAL) < 0)
+  if (gnutls_zlib_ensure_library (Z_LIBRARY_SONAME_UNUSED, RTLD_LAZY | RTLD_LOCAL) < 0)
     abort ();
 }
 
@@ -47,11 +47,11 @@ static pthread_once_t dlopen_once = PTHREAD_ONCE_INIT;
 
 #endif /* !GNUTLS_ZLIB_ENABLE_PTHREAD */
 
-#else /* Z_LIBRARY_SONAME */
+#else /* Z_LIBRARY_SONAME_UNUSED */
 
 #define ENSURE_LIBRARY do {} while (0)
 
-#endif /* !Z_LIBRARY_SONAME */
+#endif /* !Z_LIBRARY_SONAME_UNUSED */
 
 static void *gnutls_zlib_dlhandle;
 
@@ -147,7 +147,10 @@ void
 gnutls_zlib_unload_library (void)
 {
   if (gnutls_zlib_dlhandle)
-    dlclose (gnutls_zlib_dlhandle);
+    {
+      dlclose (gnutls_zlib_dlhandle);
+      gnutls_zlib_dlhandle = NULL;
+    }
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-macros"
@@ -160,8 +163,6 @@ gnutls_zlib_unload_library (void)
 #undef FUNC
 
 #pragma GCC diagnostic pop
-
-#undef RESET_SYMBOL
 }
 
 #else /* GNUTLS_ZLIB_ENABLE_DLOPEN */
index 2ea72529754a45c816688641ad2649769f83c685..532c80b61014043bb65c8e20db8c6a79bf5e4400 100644 (file)
 #include <errno.h>
 #include <stdlib.h>
 
-/* If ZSTD_LIBRARY_SONAME is defined, dlopen handle can be automatically
+/* If ZSTD_LIBRARY_SONAME_UNUSED is defined, dlopen handle can be automatically
  * set; otherwise, the caller needs to call
  * gnutls_zstd_ensure_library with soname determined at run time.
  */
-#ifdef ZSTD_LIBRARY_SONAME
+#ifdef ZSTD_LIBRARY_SONAME_UNUSED
 
 static void
 ensure_library (void)
 {
-  if (gnutls_zstd_ensure_library (ZSTD_LIBRARY_SONAME, RTLD_LAZY | RTLD_LOCAL) < 0)
+  if (gnutls_zstd_ensure_library (ZSTD_LIBRARY_SONAME_UNUSED, RTLD_LAZY | RTLD_LOCAL) < 0)
     abort ();
 }
 
@@ -47,11 +47,11 @@ static pthread_once_t dlopen_once = PTHREAD_ONCE_INIT;
 
 #endif /* !GNUTLS_ZSTD_ENABLE_PTHREAD */
 
-#else /* ZSTD_LIBRARY_SONAME */
+#else /* ZSTD_LIBRARY_SONAME_UNUSED */
 
 #define ENSURE_LIBRARY do {} while (0)
 
-#endif /* !ZSTD_LIBRARY_SONAME */
+#endif /* !ZSTD_LIBRARY_SONAME_UNUSED */
 
 static void *gnutls_zstd_dlhandle;
 
@@ -147,7 +147,10 @@ void
 gnutls_zstd_unload_library (void)
 {
   if (gnutls_zstd_dlhandle)
-    dlclose (gnutls_zstd_dlhandle);
+    {
+      dlclose (gnutls_zstd_dlhandle);
+      gnutls_zstd_dlhandle = NULL;
+    }
 
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wunused-macros"
@@ -160,8 +163,6 @@ gnutls_zstd_unload_library (void)
 #undef FUNC
 
 #pragma GCC diagnostic pop
-
-#undef RESET_SYMBOL
 }
 
 #else /* GNUTLS_ZSTD_ENABLE_DLOPEN */