From 19e06407eb365a2bedc9bdd29a83c1e1803e3f92 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 11 Feb 2024 19:35:05 +0100 Subject: [PATCH] build: Generate the map file from the configured ABI Some linkers require the map file definitions to contain only symbols that are present on the linked object, either in the map file or in the sym file we generate from the map file. This is preparatory work to be able to conditionally include symbols in the man and sym files depending on the ABI definitions. --- .gitignore | 1 + src/Makefile.am | 11 +++++++++-- src/{libbsd.map => libbsd.map.in} | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) rename src/{libbsd.map => libbsd.map.in} (99%) diff --git a/.gitignore b/.gitignore index 5c3a5ed..a6f6403 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ ChangeLog *.gcda *.gcno *.sym +*.map .dirstamp .deps/ .libs/ diff --git a/src/Makefile.am b/src/Makefile.am index 6f2325c..1c350b8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,7 @@ libbsd_la_included_sources = \ CLEANFILES = EXTRA_DIST = \ - libbsd.map \ + libbsd.map.in \ libbsd.pc.in \ libbsd-ctor.pc.in \ libbsd-overlay.pc.in \ @@ -53,6 +53,7 @@ endif EXTRA_libbsd_la_DEPENDENCIES = \ $(libbsd_la_included_sources) \ libbsd.map \ + libbsd.map.in \ # EOL libbsd_la_LIBADD = \ $(MD5_LIBS) \ @@ -64,7 +65,7 @@ libbsd_la_LDFLAGS = \ # EOL if HAVE_LINKER_VERSION_SCRIPT libbsd_la_LDFLAGS += \ - -Wl,--version-script=$(srcdir)/libbsd.map \ + -Wl,--version-script=libbsd.map \ # EOL else libbsd_la_LDFLAGS += \ @@ -194,12 +195,18 @@ endif DISTCLEANFILES = \ libbsd.sym \ + libbsd.map \ # EOL libbsd_ctor_a_SOURCES = \ setproctitle_ctor.c \ # EOL +# Generate the library map file with the pre-processor to selectively include +# symbols depending on the host system, otherwise some linkers might fail. +libbsd.map: libbsd.map.in + $(CPP) $(AM_CPPFLAGS) $(CPPFLAGS) -P - <$(srcdir)/libbsd.map.in >$@ + # Generate a simple libtool symbol export list to be used as a fallback if # there is no version script support. libbsd.sym: libbsd.map diff --git a/src/libbsd.map b/src/libbsd.map.in similarity index 99% rename from src/libbsd.map rename to src/libbsd.map.in index 6c61235..06550ea 100644 --- a/src/libbsd.map +++ b/src/libbsd.map.in @@ -1,3 +1,5 @@ +#include "config.h" + LIBBSD_0.0 { global: arc4random;