d1be1bd
d1be1bd
# Do not build the annobin plugin with annotation enabled.
d1be1bd
# This is because if we are bootstrapping a new build environment we can have
d1be1bd
# a new version of gcc installed, but without a new of annobin installed.
d1be1bd
# (ie we are building the new version of annobin to go with the new version
d1be1bd
# of gcc).  If the *old* annobin plugin is used whilst building this new
d1be1bd
# version, the old plugin will complain that version of gcc for which it
d1be1bd
# was built is different from the version of gcc that is now being used, and
d1be1bd
# then it will abort.
267ee07
%undefine _annotated_build
267ee07
35fd563
Name:    annobin
35fd563
Summary: Binary annotation plugin for GCC
4f0a7c2
Version: 5.3
a9bdd53
Release: 1%{?dist}
35fd563
d6f88f6
License: GPLv3+
35fd563
URL:     https://fedoraproject.org/wiki/Toolchain/Watermark
35fd563
e7ed178
# Use "--without tests" to disable the testsuite.  The default is to run them.
e7ed178
%bcond_without tests
e7ed178
38bf73b
# Set this to zero to disable the requirement for a specific version of gcc.
38bf73b
# This should only be needed if there is some kind of problem with the version
38bf73b
# checking logic.
38bf73b
%global with_hard_gcc_version_requirement 1
38bf73b
38bf73b
#---------------------------------------------------------------------------------
38bf73b
Source:  https://nickc.fedorapeople.org/annobin-%{version}.tar.xz
38bf73b
# For the latest sources use:  git clone git://sourceware.org/git/annobin.git
38bf73b
38bf73b
Requires(post): /sbin/install-info
38bf73b
Requires(preun): /sbin/install-info
38bf73b
38bf73b
BuildRequires: gcc-plugin-devel pkgconfig coreutils info
38bf73b
38bf73b
%description
38bf73b
A plugin for GCC that records extra information in the files that it compiles,
38bf73b
and a set of scripts that analyze the recorded information.  These scripts can
38bf73b
determine things ABI clashes in compiled binaries, or the absence of required
38bf73b
hardening options.
38bf73b
38bf73b
Note - the plugin is enabled in gcc builds via flags provided by the
38bf73b
redhat-rpm-macros package, and the analysis tools rely upon the readelf program
38bf73b
from the binutils package.
38bf73b
38bf73b
#---------------------------------------------------------------------------------
38bf73b
%if %{with tests}
38bf73b
38bf73b
%package tests
38bf73b
Summary: Test scripts and binaries for checking the behaviour and output of the annobin plugin
38bf73b
38bf73b
%description tests
38bf73b
Provides a means to test the generation of annotated binaries and the parsing
38bf73b
of the resulting files.
38bf73b
# FIXME: Does not actually do this yet...
38bf73b
38bf73b
%endif
38bf73b
#---------------------------------------------------------------------------------
38bf73b
38bf73b
%global ANNOBIN_PLUGIN_DIR %(gcc --print-file-name=plugin)
38bf73b
0078c77
# [Stolen from gcc-python-plugin]
0078c77
# GCC will only load plugins that were built against exactly that build of GCC
0078c77
# We thus need to embed the exact GCC version as a requirement within the
0078c77
# metadata.
0078c77
#
0078c77
# Define "gcc_vr", a variable to hold the VERSION-RELEASE string for the gcc
0078c77
# we are being built against.
0078c77
#
0078c77
# Unfortunately, we can't simply run:
a9bdd53
#   rpm -q --qf="%%{version}-%%{release}"
0078c77
# to determine this, as there's no guarantee of a sane rpm database within
0078c77
# the chroots created by our build system
0078c77
#
0078c77
# So we instead query the version from gcc's output.
0078c77
#
0078c77
# gcc.spec has:
fb74d1e
#   Version: %%{gcc_version}
fb74d1e
#   Release: %%{gcc_release}%%{?dist}
0078c77
#   ...snip...
fb74d1e
#   echo 'Red Hat %%{version}-%%{gcc_release}' > gcc/DEV-PHASE
fb74d1e
#
0078c77
# So, given this output:
0078c77
#
0078c77
#   $ gcc --version
0078c77
#   gcc (GCC) 4.6.1 20110908 (Red Hat 4.6.1-9)
0078c77
#   Copyright (C) 2011 Free Software Foundation, Inc.
0078c77
#   This is free software; see the source for copying conditions.  There is NO
0078c77
#   warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0078c77
#
0078c77
# we can scrape out the "4.6.1" from the version line.
0078c77
#
0078c77
# The following implements the above:
0078c77
#
0078c77
# Note - gawk will emit a warning message saying:
0078c77
#
0078c77
#  gawk: cmd. line:1: warning: escape sequence `\)' treated as plain `)'
0078c77
#
0078c77
# I have not been able to work out how to remove this message, but still provide
0078c77
# sufficient escaping for the command line to survive intact as it is passed
0078c77
# down through the sub-shell.
0078c77
0078c77
%global gcc_vr %(gcc --version | gawk 'match (\$0, ".*Red Hat \([^\\)-]*\)", a) { print a[1]; }')
0078c77
35fd563
# This is a gcc plugin, hence gcc is required.
0078c77
%if %{with_hard_gcc_version_requirement}
0078c77
Requires: gcc == %{gcc_vr}
0078c77
BuildRequires: gcc == %{gcc_vr}
38bf73b
%else
38bf73b
Requires: gcc
0078c77
%endif
0078c77
35fd563
%prep
35fd563
%autosetup -p1
35fd563
26ba227
# The plugin has to be configured with the same arcane configure
26ba227
# scripts used by gcc.  Hence we must not allow the Fedora build
26ba227
# system to regenerate any of the configure files.
26ba227
touch aclocal.m4 plugin/config.h.in
c393d68
touch configure */configure Makefile.in */Makefile.in
6b89f32
# Similarly we do not want to rebuild the documentation.
6b89f32
touch doc/annobin.info
c393d68
35fd563
%build
ceb5d85
%configure --quiet --with-gcc-plugin-dir=%{ANNOBIN_PLUGIN_DIR}
757c3b0
%make_build
757c3b0
757c3b0
%install
757c3b0
%make_install
d1be1bd
%{__rm} -f %{buildroot}%{_infodir}/dir
35fd563
e7ed178
%if %{with tests}
757c3b0
%check
e7ed178
make check
e7ed178
%endif
e7ed178
d1be1bd
%post
d1be1bd
/sbin/install-info %{_infodir}/annobin.info.gz %{_infodir} >/dev/null 2>&1 || :
d1be1bd
exit 0
d1be1bd
d1be1bd
%preun
d1be1bd
if [ $1 = 0 ]; then
d1be1bd
   /sbin/install-info --delete %{_infodir}/annobin.info.gz %{_infodir} >/dev/null 2>&1|| :
d1be1bd
fi
d1be1bd
exit 0
d1be1bd
35fd563
%files
35fd563
%{ANNOBIN_PLUGIN_DIR}
35fd563
%{_bindir}/built-by.sh
35fd563
%{_bindir}/check-abi.sh
35fd563
%{_bindir}/hardened.sh
8a3889e
%{_bindir}/run-on-binaries-in.sh
35fd563
%license COPYING3 LICENSE
35fd563
%exclude %{_datadir}/doc/annobin-plugin/COPYING3
35fd563
%exclude %{_datadir}/doc/annobin-plugin/LICENSE
35fd563
%doc %{_datadir}/doc/annobin-plugin/annotation.proposal.txt
6b89f32
%doc %{_infodir}/annobin.info.gz
4f0a7c2
%doc %{_mandir}/man1/annobin.1.gz
4f0a7c2
%doc %{_mandir}/man1/built-by.1.gz
4f0a7c2
%doc %{_mandir}/man1/check-abi.1.gz
4f0a7c2
%doc %{_mandir}/man1/hardened.1.gz
4f0a7c2
%doc %{_mandir}/man1/run-on-binaries.1.gz
35fd563
e7ed178
#---------------------------------------------------------------------------------
35fd563
%changelog
4f0a7c2
* Fri Apr 20 2018 Nick Clifton <nickc@redhat.com> - 5.3-1
4f0a7c2
- Add manual pages for annobin and the scripts.
4f0a7c2
f2865c5
* Tue Apr 03 2018 Nick Clifton <nickc@redhat.com> - 5.2-1
f2865c5
- Do not record a stack protection setting of -1.  (#1563141)
f2865c5
3323867
* Tue Mar 20 2018 Nick Clifton <nickc@redhat.com> - 5.1-1
3323867
- Do not complain about a dwarf_version value of -1.  (#1557511)
3323867
0af9bb2
* Thu Mar 15 2018 Nick Clifton <nickc@redhat.com> - 5.0-1
0af9bb2
- Bias file start symbols by 2 in order to avoid them confused with function symbols.  (#1554332)
0af9bb2
- Version jump is to sync the version number with the annobin plugins internal version number.
0af9bb2
c42ae85
* Mon Mar 12 2018 Nick Clifton <nickc@redhat.com> - 3.6-1
c42ae85
- Add --ignore-gaps option to check-abi.sh script.
c42ae85
- Use this option in the abi-test check.
c42ae85
- Tweak hardening test to skip pic and stack protection checks.
c42ae85
a9bdd53
* Tue Mar 06 2018 Nick Clifton <nickc@redhat.com> - 3.5-1
a9bdd53
- Handle functions with specific assembler names.  (#1552018)
a9bdd53
0078c77
* Fri Feb 23 2018 Nick Clifton <nickc@redhat.com> - 3.4-2
0078c77
- Add an explicit requirement on the version of gcc used to built the plugin.  (#1547260)
0078c77
8a3889e
* Fri Feb 09 2018 Nick Clifton <nickc@redhat.com> - 3.4-1
8a3889e
- Change type and size of symbols to STT_NOTYPE/0 so that they do not confuse GDB.  (#1539664)
8a3889e
- Add run-on-binaries-in.sh script to allow the other scripts to be run over a repository.
8a3889e
b42c748
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 3.3-2
b42c748
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
b42c748
cfbd038
* Tue Jan 30 2018 Nick Clifton <nickc@redhat.com> - 3.3-1
cfbd038
- Rebase on 3.3 release, which adds support for recording -mcet and -fcf-protection.
cfbd038
ccd5e04
* Mon Jan 29 2018 Florian Weimer <fweimer@redhat.com> - 3.2-3
ccd5e04
- Rebuild for GCC 8
ccd5e04
d1be1bd
* Fri Jan 26 2018 Nick Clifton <nickc@redhat.com> - 3.2-2
d1be1bd
- Fix the installation of the annobin.info file.
d1be1bd
6b89f32
* Fri Jan 26 2018 Nick Clifton <nickc@redhat.com> - 3.2-1
6b89f32
- Rebase on 3.2 release, which now contains documentation!
6b89f32
3f1d08f
* Fri Jan 26 2018 Richard W.M. Jones <rjones@redhat.com> - 3.1-3
3f1d08f
- Rebuild against GCC 7.3.1.
3f1d08f
ceb5d85
* Tue Jan 16 2018 Nick Clifton <nickc@redhat.com> - 3.1-2
ceb5d85
- Add --with-gcc-plugin-dir option to the configure command line.
ceb5d85
26ba227
* Thu Jan 04 2018 Nick Clifton <nickc@redhat.com> - 3.1-1
26ba227
- Rebase on version 3.1 sources.
26ba227
ecf7069
* Mon Dec 11 2017 Nick Clifton <nickc@redhat.com> - 2.5.1-5
ecf7069
- Do not generate notes when there is no output file.  (#1523875)
ecf7069
ecf7069
* Fri Dec 08 2017 Nick Clifton <nickc@redhat.com> - 2.5.1-4
3dfaaa0
- Invent an input filename when reading from a pipe.  (#1523401)
3dfaaa0
a11e44b
* Thu Nov 30 2017 Florian Weimer <fweimer@redhat.com> - 2.5.1-3
a11e44b
- Use DECL_ASSEMBLER_NAME for symbol references (#1519165)
a11e44b
6112172
* Tue Oct 03 2017 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 2.5.1-2
6112172
- Cleanups in spec
6112172
ccfd4bf
* Tue Sep 26 2017 Nick Clifton <nickc@redhat.com> - 2.5.1-1
c393d68
- Touch the auto-generated files in order to stop them from being regenerated.
c393d68
ccfd4bf
* Tue Sep 26 2017 Nick Clifton <nickc@redhat.com> - 2.5-2
31b6780
- Stop the plugin complaining about compiler datestamp mismatches.
31b6780
ccfd4bf
* Thu Sep 21 2017 Nick Clifton <nickc@redhat.com> - 2.4-1
4b489fe
- Tweak tests so that they will run on older machines.
4b489fe
ccfd4bf
* Thu Sep 21 2017 Nick Clifton <nickc@redhat.com> - 2.3-1
e7ed178
- Add annobin-tests subpackage containing some preliminary tests.
e7ed178
- Remove link-time test for unsuported targets.
e7ed178
3b2676b
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.0-3
3b2676b
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
3b2676b
f53ae1f
* Mon Jul 31 2017 Florian Weimer <fweimer@redhat.com> - 2.0-2
f53ae1f
- Rebuild with binutils fix for ppc64le (#1475636)
f53ae1f
ccfd4bf
* Wed Jun 28 2017 Nick Clifton <nickc@redhat.com> - 2.0-1
35fd563
- Fixes for problems reported by the package submission review:
35fd563
   * Add %%license entry to %%file section.
35fd563
   * Update License and BuildRequires tags.
35fd563
   * Add Requires tag.
35fd563
   * Remove %%clean.
35fd563
   * Add %%check.
35fd563
   * Clean up the %%changelog.
35fd563
- Update to use version 2 of the specification and sources.
35fd563
ccfd4bf
* Thu May 11 2017 Nick Clifton <nickc@redhat.com> - 1.0-1
35fd563
- Initial submission.