From 9670a38d08c1d842f16ef7811080808f2c147898 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Fri, 17 May 2024 21:23:33 -0400 Subject: [PATCH] tools/elfutils: use conditional to block build of shared objects Add a potentially upstream-friendly conditional using the libtool configure variable "enable_shared" in order to block building and installing of shared objects and adjust the build of static libraries instead of directly patching lines in or out. Signed-off-by: Michael Pratt Link: https://github.com/openwrt/openwrt/pull/15690 Signed-off-by: Robert Marko --- tools/elfutils/patches/100-portability.patch | 140 ++++++++++--------- 1 file changed, 76 insertions(+), 64 deletions(-) diff --git a/tools/elfutils/patches/100-portability.patch b/tools/elfutils/patches/100-portability.patch index b3bddd0c8802..788695fcc09a 100644 --- a/tools/elfutils/patches/100-portability.patch +++ b/tools/elfutils/patches/100-portability.patch @@ -30,16 +30,19 @@ AC_CACHE_CHECK([whether gcc supports __attribute__((visibility()))], ac_cv_visibility, [dnl save_CFLAGS="$CFLAGS" -@@ -415,7 +421,7 @@ AS_HELP_STRING([--enable-install-elfh],[ +@@ -415,7 +421,10 @@ AS_HELP_STRING([--enable-install-elfh],[ AM_CONDITIONAL(INSTALL_ELFH, test "$install_elfh" = yes) AM_CONDITIONAL(BUILD_STATIC, [dnl -test "$use_gprof" = yes -o "$use_gcov" = yes]) +test "$use_gprof" = yes -o "$use_gcov" = yes -o "$enable_static" = yes]) ++ ++AM_CONDITIONAL(BUILD_SHARED, [dnl ++test "$enable_shared" = yes]) AC_ARG_ENABLE([tests-rpath], AS_HELP_STRING([--enable-tests-rpath],[build $ORIGIN-using rpath into tests]), -@@ -635,6 +641,8 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], +@@ -635,6 +644,8 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], CFLAGS="$old_CFLAGS"]) AS_IF([test "x$ac_cv_fno_addrsig" = "xyes"], CFLAGS="$CFLAGS -fno-addrsig") @@ -90,34 +93,31 @@ # define INTDEF(name) _INTDEF(name) --- a/libelf/Makefile.am +++ b/libelf/Makefile.am -@@ -35,8 +35,6 @@ endif +@@ -35,8 +35,11 @@ endif VERSION = 1 lib_LIBRARIES = libelf.a --noinst_LIBRARIES = libelf_pic.a --noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so) ++if BUILD_SHARED + noinst_LIBRARIES = libelf_pic.a + noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so) ++endif ++ include_HEADERS = libelf.h gelf.h nlist.h noinst_HEADERS = abstract.h common.h exttypes.h gelf_xlate.h libelfP.h \ -@@ -111,6 +109,8 @@ if USE_LOCKS - libelf_so_LDLIBS += -lpthread - endif - -+libelf_a_LIBADD = $(foreach dep,$(libelf_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep))) -+ - libelf_so_LIBS = libelf_pic.a - libelf.so: $(srcdir)/libelf.map $(libelf_so_LIBS) $(libelf_so_DEPS) - $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -@@ -122,11 +122,8 @@ libelf.so: $(srcdir)/libelf.map $(libelf +@@ -122,11 +125,15 @@ libelf.so: $(srcdir)/libelf.map $(libelf @$(textrel_check) $(AM_V_at)ln -fs $@ $@.$(VERSION) --install: install-am libelf.so -+install: install-am ++if BUILD_SHARED + install: install-am libelf.so $(mkinstalldirs) $(DESTDIR)$(libdir) -- $(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so -- ln -fs libelf-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libelf.so.$(VERSION) -- ln -fs libelf.so.$(VERSION) $(DESTDIR)$(libdir)/libelf.so + $(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so + ln -fs libelf-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libelf.so.$(VERSION) + ln -fs libelf.so.$(VERSION) $(DESTDIR)$(libdir)/libelf.so ++else ++libelf_a_LIBADD = $(foreach dep,$(libelf_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep))) ++endif uninstall: uninstall-am rm -f $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so @@ -265,25 +265,28 @@ --- a/libdw/Makefile.am +++ b/libdw/Makefile.am -@@ -35,8 +35,6 @@ AM_CPPFLAGS += -I$(srcdir)/../libebl -I$ +@@ -35,8 +35,10 @@ AM_CPPFLAGS += -I$(srcdir)/../libebl -I$ VERSION = 1 lib_LIBRARIES = libdw.a --noinst_LIBRARIES = libdw_pic.a --noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so) ++if BUILD_SHARED + noinst_LIBRARIES = libdw_pic.a + noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so) ++endif include_HEADERS = dwarf.h pkginclude_HEADERS = libdw.h known-dwarf.h -@@ -121,11 +119,8 @@ libdw.so: $(srcdir)/libdw.map $(libdw_so +@@ -121,11 +123,13 @@ libdw.so: $(srcdir)/libdw.map $(libdw_so @$(textrel_check) $(AM_V_at)ln -fs $@ $@.$(VERSION) --install: install-am libdw.so -+install: install-am ++if BUILD_SHARED + install: install-am libdw.so $(mkinstalldirs) $(DESTDIR)$(libdir) -- $(INSTALL_PROGRAM) libdw.so $(DESTDIR)$(libdir)/libdw-$(PACKAGE_VERSION).so -- ln -fs libdw-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdw.so.$(VERSION) -- ln -fs libdw.so.$(VERSION) $(DESTDIR)$(libdir)/libdw.so + $(INSTALL_PROGRAM) libdw.so $(DESTDIR)$(libdir)/libdw-$(PACKAGE_VERSION).so + ln -fs libdw-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdw.so.$(VERSION) + ln -fs libdw.so.$(VERSION) $(DESTDIR)$(libdir)/libdw.so ++endif uninstall: uninstall-am rm -f $(DESTDIR)$(libdir)/libdw-$(PACKAGE_VERSION).so @@ -311,7 +314,9 @@ +libcpu_objects = $(shell cat ../libcpu/libcpu.manifest) libdw_a_LIBADD += $(addprefix ../libcpu/,$(libcpu_objects)) ++if !BUILD_SHARED +libdw_a_LIBADD += $(foreach dep,$(libdw_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep))) ++endif + noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \ dwarf_sig8_hash.h cfi.h encoded-value.h @@ -407,34 +412,31 @@ +MOSTLYCLEANFILES = $(EXTRA_libeu_a_DEPENDENCIES) --- a/libasm/Makefile.am +++ b/libasm/Makefile.am -@@ -33,8 +33,6 @@ AM_CPPFLAGS += -I$(top_srcdir)/libelf -I +@@ -33,8 +33,11 @@ AM_CPPFLAGS += -I$(top_srcdir)/libelf -I VERSION = 1 lib_LIBRARIES = libasm.a --noinst_LIBRARIES = libasm_pic.a --noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so) ++if BUILD_SHARED + noinst_LIBRARIES = libasm_pic.a + noinst_DATA = $(noinst_LIBRARIES:_pic.a=.so) ++endif ++ pkginclude_HEADERS = libasm.h libasm_a_SOURCES = asm_begin.c asm_abort.c asm_end.c asm_error.c \ -@@ -60,6 +58,8 @@ if USE_LOCKS - libasm_so_LDLIBS += -lpthread - endif - -+libasm_a_LIBADD = $(foreach dep,$(libasm_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep))) -+ - libasm_so_LIBS = libasm_pic.a - libasm.so: $(srcdir)/libasm.map $(libasm_so_LIBS) $(libasm_so_DEPS) - $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -@@ -71,11 +71,8 @@ libasm.so: $(srcdir)/libasm.map $(libasm +@@ -71,11 +74,15 @@ libasm.so: $(srcdir)/libasm.map $(libasm @$(textrel_check) $(AM_V_at)ln -fs $@ $@.$(VERSION) --install: install-am libasm.so -+install: install-am ++if BUILD_SHARED + install: install-am libasm.so $(mkinstalldirs) $(DESTDIR)$(libdir) -- $(INSTALL_PROGRAM) libasm.so $(DESTDIR)$(libdir)/libasm-$(PACKAGE_VERSION).so -- ln -fs libasm-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libasm.so.$(VERSION) -- ln -fs libasm.so.$(VERSION) $(DESTDIR)$(libdir)/libasm.so + $(INSTALL_PROGRAM) libasm.so $(DESTDIR)$(libdir)/libasm-$(PACKAGE_VERSION).so + ln -fs libasm-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libasm.so.$(VERSION) + ln -fs libasm.so.$(VERSION) $(DESTDIR)$(libdir)/libasm.so ++else ++libasm_a_LIBADD = $(foreach dep,$(libasm_so_DEPS:.so=.a) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep))) ++endif uninstall: uninstall-am rm -f $(DESTDIR)$(libdir)/libasm-$(PACKAGE_VERSION).so @@ -451,33 +453,31 @@ CLEANFILES += $(am_libasm_pic_a_OBJECTS) libasm.so libasm.so.$(VERSION) --- a/debuginfod/Makefile.am +++ b/debuginfod/Makefile.am -@@ -77,7 +77,6 @@ debuginfod_find_LDADD = $(libdw) $(libel +@@ -77,8 +77,10 @@ debuginfod_find_LDADD = $(libdw) $(libel if LIBDEBUGINFOD noinst_LIBRARIES = libdebuginfod.a --noinst_LIBRARIES += libdebuginfod_pic.a ++if BUILD_SHARED + noinst_LIBRARIES += libdebuginfod_pic.a endif ++endif libdebuginfod_a_SOURCES = debuginfod-client.c -@@ -98,6 +97,7 @@ if DUMMY_LIBDEBUGINFOD - libdebuginfod_so_LDLIBS = - else - libdebuginfod_so_LDLIBS = -lpthread $(libcurl_LIBS) $(fts_LIBS) $(libelf) -+libdebuginfod_a_LIBADD = $(foreach dep,$(wildcard $(libdebuginfod_so_LDLIBS:.so=.a)) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep))) - endif - $(LIBDEBUGINFOD_SONAME): $(srcdir)/libdebuginfod.map $(libdebuginfod_so_LIBS) - $(AM_V_CCLD)$(LINK) $(dso_LDFLAGS) -o $@ \ -@@ -111,12 +111,8 @@ $(LIBDEBUGINFOD_SONAME): $(srcdir)/libde + libdebuginfod_pic_a_SOURCES = debuginfod-client.c +@@ -111,12 +113,16 @@ $(LIBDEBUGINFOD_SONAME): $(srcdir)/libde libdebuginfod.so: $(LIBDEBUGINFOD_SONAME) ln -fs $< $@ --install: install-am libdebuginfod.so -+install: install-am ++if BUILD_SHARED + install: install-am libdebuginfod.so $(mkinstalldirs) $(DESTDIR)$(libdir) -- $(INSTALL_PROGRAM) $(LIBDEBUGINFOD_SONAME) \ -- $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so -- ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME) -- ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so + $(INSTALL_PROGRAM) $(LIBDEBUGINFOD_SONAME) \ + $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so + ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/$(LIBDEBUGINFOD_SONAME) + ln -fs libdebuginfod-$(PACKAGE_VERSION).so $(DESTDIR)$(libdir)/libdebuginfod.so ++else ++libdebuginfod_a_LIBADD = $(foreach dep,$(wildcard $(libdebuginfod_so_LDLIBS:.so=.a)) $(LIBS:.so=.a),$(if $(findstring a,$(suffix $(dep))),$(addprefix $(dir $(dep)),$(shell cat $(basename $(dep)).manifest)),$(dep))) ++endif uninstall: uninstall-am rm -f $(DESTDIR)$(libdir)/libdebuginfod-$(PACKAGE_VERSION).so @@ -516,6 +516,18 @@ run-linkmap-cut.sh run-aggregate-size.sh run-peel-type.sh \ vdsosyms run-readelf-A.sh \ run-getsrc-die.sh run-strptr.sh newdata elfstrtab dwfl-proc-attach \ +@@ -284,6 +284,11 @@ funcretval_test__11_SOURCES = funcretval + TESTS += run-funcretval++11.sh + endif + ++if BUILD_SHARED ++check_PROGRAMS += deleted deleted-lib.so ++TESTS += run-deleted.sh ++endif ++ + EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ + run-ar-N.sh \ + run-show-die-info.sh run-get-files.sh run-get-lines.sh \ --- a/config/libelf.pc.in +++ b/config/libelf.pc.in @@ -8,7 +8,7 @@ Description: elfutils libelf library to -- 2.30.2