From 57edf0cad7b089ed0193965b9a144aa4cfd7c25d Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Jan 17 2022 08:20:00 +0000 Subject: Inject linker script to generate package notes https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects Macros are used only if defined. Definitions are provided in the package-notes-srpm-macros, which is now Required (on Fedora). --- diff --git a/buildflags.md b/buildflags.md index 121694e..ba0310a 100644 --- a/buildflags.md +++ b/buildflags.md @@ -246,6 +246,22 @@ it is possible to add `-fcommon` to the flags by defining `%_legacy_common_suppo Properly fixing the failure is always preferred! +### Package note on ELF objects + +A note that describes the package name, version, and architecture is +inserted via a linker script (`%_package_note_file`). The script is +generated when `%set_build_flags` is called. The linker option that +injects the linker script is added to `%{build_ldflags}` via the +`%{_package_note_flags}` macro. + +To opt out of the use of the linker script, include this in the spec file: + + %undefine _package_note_flags + +To opt out of generation of the linker script, include this in the spec file: + + %undefine _generate_package_note_file + ### Post-build ELF object processing By default, DWARF debugging information is separated from installed diff --git a/macros b/macros index 3e3c8e4..6049699 100644 --- a/macros +++ b/macros @@ -72,7 +72,7 @@ # When clang is used as a linker driver, it does not auto-detect the LTO # bytecode and neither does bfd, so we need to explicitly pass the -flto # flag when linking. -%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_lto_cflags}" : "" ] %{_build_id_flags} +%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_lto_cflags}" : "" ] %{_build_id_flags} %{?_package_note_flags} # Expands to shell code to set the compiler/linker environment # variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have @@ -80,6 +80,7 @@ # been set implicitly at the start of the %%build section. # LT_SYS_LIBRARY_PATH is used by libtool script. %set_build_flags \ + %{?_generate_package_note_file} ; \ CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \ CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \ FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \ diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index e6d2ea0..97e620b 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 208 +Version: 209 Release: 1%{?dist} # No version specified. License: GPL+ @@ -102,6 +102,7 @@ Requires: rpmautospec-rpm-macros Requires: fpc-srpm-macros Requires: gnat-srpm-macros Requires: nim-srpm-macros +Requires: package-notes-srpm-macros %endif Requires: rpm >= 4.11.0 @@ -190,6 +191,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %doc buildflags.md %changelog +* Thu Jan 13 2022 Zbigniew Jędrzejewski-Szmek - 209-1 +- Add package ELF note to the default LDFLAGS + * Tue Jan 04 2022 Tom Stellard - 208-1 - Call %%set_build_flags before %%build, %%check, and %%install stages