summaryrefslogtreecommitdiff
path: root/gold/configure.ac
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2022-08-04 17:19:52 -0700
committerCary Coutant <ccoutant@gmail.com>2022-08-04 17:37:32 -0700
commit701821154b110230f52a0367e120ecc51f490e56 (patch)
treeffbb47ef447a2cbddafa2b2bd0bc5c220771b924 /gold/configure.ac
parent1369522f36eece1b37139a81f7f2139ba3915172 (diff)
Add gold support for --package-metadata option.
Following the same format as the implementation in ld: 9e2bb0cb5e74aed4158f08495534922d7108f928 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. elfcpp/ * elfcpp.h: Add FDO_PACKAGING_METADATA note type. gold/ * Makefile.am: Add jansson flags and libraries. * configure.ac: Check for jansson library. * layout.cc (Layout::create_notes): Call create_package_metadata(). (Layout::create_package_metadata): New function. * layout.h (Layout::create_package_metadata): New function. (Layout::package_metadata_note_): New data member. * options.h (class General_options): Add --package-metadata option. * testsuite/Makefile.am (object_unittest): Add jansson libraries. (binary_unittest): Likewise. (leb128_unittest): Likewise. (overflow_unittest): Likewise. (package_metadata_test): New test. * testsuite/package_metadata_main.c: New test source.
Diffstat (limited to 'gold/configure.ac')
-rw-r--r--gold/configure.ac26
1 files changed, 26 insertions, 0 deletions
diff --git a/gold/configure.ac b/gold/configure.ac
index 4f432809b3..25fae6b998 100644
--- a/gold/configure.ac
+++ b/gold/configure.ac
@@ -591,6 +591,32 @@ if test "$threads" = "yes"; then
fi
AM_CONDITIONAL(THREADS, test "$threads" = "yes")
+# 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
+
dnl We have to check these in C, not C++, because autoconf generates
dnl tests which have no type information, and current glibc provides
dnl multiple declarations of functions like basename when compiling