From 9e2bb0cb5e74aed4158f08495534922d7108f928 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Wed, 25 May 2022 14:41:47 +0100 Subject: ld: add --package-metadata Generate a .note.package FDO package metadata ELF note, following the spec: https://systemd.io/ELF_PACKAGE_METADATA/ If the jansson library is available at build time (and it is explicitly enabled), link ld to it, and use it to validate that the input is correct JSON, to avoid writing garbage to the file. The configure option --enable-jansson has to be used to explicitly enable it (error out when not found). This allows bootstrappers (or others who are not interested) to seamlessly skip it without issues. --- ld/configure.ac | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'ld/configure.ac') diff --git a/ld/configure.ac b/ld/configure.ac index 0112148..4331d6b 100644 --- a/ld/configure.ac +++ b/ld/configure.ac @@ -289,6 +289,32 @@ fi AM_CONDITIONAL(ENABLE_LIBCTF, test "${enable_libctf}" = yes) AC_SUBST(enable_libctf) +# Used to validate --package-metadata= input. Disabled by default. +AC_ARG_ENABLE([jansson], + [AS_HELP_STRING([--enable-jansson], + [enable jansson [default=no]])], + [enable_jansson=$enableval], + [enable_jansson="no"]) + +if test "x$enable_jansson" != "xno"; then + PKG_PROG_PKG_CONFIG + AS_IF([test -n "$PKG_CONFIG"], + [ + PKG_CHECK_MODULES(JANSSON, [jansson], + [ + AC_DEFINE(HAVE_JANSSON, 1, [The jansson library is to be used]) + AC_SUBST([JANSSON_CFLAGS]) + AC_SUBST([JANSSON_LIBS]) + ], + [ + AC_MSG_ERROR([Cannot find jansson library]) + ]) + ], + [ + AC_MSG_ERROR([Cannot find pkg-config]) + ]) +fi + AM_BINUTILS_WARNINGS AM_LC_MESSAGES -- cgit v1.1