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
d3e4501
Version: 8.14
c760726
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
4656334
# Use "--without annocheck" to disable the installation of the annocheck program.
4656334
%bcond_without annocheck
4656334
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
9d8fe91
# Insert patches here, if needed.
9d8fe91
# Patch01: annobin-xxx.patch
9d8fe91
9d8fe91
e8e22cc
BuildRequires: gcc-plugin-devel gcc-c++
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
38bf73b
%endif
4656334
4656334
#---------------------------------------------------------------------------------
4656334
%if %{with annocheck}
4656334
4656334
%package annocheck
4656334
Summary: A tool for checking the security hardening status of binaries
4656334
cb01155
BuildRequires: gcc elfutils elfutils-devel elfutils-libelf-devel rpm-devel binutils-devel
4656334
4656334
%description annocheck
4656334
Installs the annocheck program which uses the notes generated by annobin to
4656334
check that the specified files were compiled with the correct security
4656334
hardening options.
4656334
4656334
%endif
4656334
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
967f47d
#---------------------------------------------------------------------------------
967f47d
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
967f47d
#---------------------------------------------------------------------------------
967f47d
35fd563
%build
ceb5d85
%configure --quiet --with-gcc-plugin-dir=%{ANNOBIN_PLUGIN_DIR}
757c3b0
%make_build
f45ff6b
# Rebuild the plugin, this time using the plugin itself!  This
f45ff6b
# ensures that the plugin works, and that it contains annotations
f45ff6b
# of its own.  This could mean that we end up with a plugin with
f45ff6b
# double annotations in it.  (If the build system enables annotations
967f47d
# for plugins by default).  I have not tested this yet, but I think
967f47d
# that it should be OK.
f45ff6b
cp plugin/.libs/annobin.so.0.0.0 %{_tmppath}/tmp-annobin.so
f45ff6b
make -C plugin clean
f45ff6b
make -C plugin CXXFLAGS="%{optflags} -fplugin=%{_tmppath}/tmp-annobin.so"
f45ff6b
rm %{_tmppath}/tmp-annobin.so
f45ff6b
967f47d
#---------------------------------------------------------------------------------
757c3b0
757c3b0
%install
757c3b0
%make_install
d1be1bd
%{__rm} -f %{buildroot}%{_infodir}/dir
35fd563
967f47d
#---------------------------------------------------------------------------------
967f47d
e7ed178
%if %{with tests}
757c3b0
%check
e7ed178
make check
e7ed178
%endif
e7ed178
967f47d
#---------------------------------------------------------------------------------
967f47d
35fd563
%files
35fd563
%{ANNOBIN_PLUGIN_DIR}
db2c4ce
%{_bindir}/built-by
db2c4ce
%{_bindir}/check-abi
db2c4ce
%{_bindir}/hardened
db2c4ce
%{_bindir}/run-on-binaries-in
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
4656334
%if %{with annocheck}
4656334
%{_bindir}/annocheck
4656334
%doc %{_mandir}/man1/annocheck.1.gz
4656334
%endif
4656334
e7ed178
#---------------------------------------------------------------------------------
967f47d
35fd563
%changelog
d3e4501
* Thu Jul 19 2018 Nick Clifton <nickc@redhat.com> - 8.14-1
d3e4501
- Fix section conflict problem.  (#1603071)
d3e4501
c4f43f0
* Wed Jul 18 2018 Nick Clifton <nickc@redhat.com> - 8.13-1
c4f43f0
- Fix for building with gcc version 4.
c4f43f0
- Fix symbol placement in functions with local assembler.
c4f43f0
cc6b631
* Tue Jul 17 2018 Nick Clifton <nickc@redhat.com> - 8.12-1
cc6b631
- Fix assertions in rnage checking code.  Add detection of -U options.
cc6b631
c760726
* Tue Jul 17 2018 Nick Clifton <nickc@redhat.com> - 8.11-1
c760726
- Handle function sections properly.  Handle .text.startup and .text.unlikely sections.  Improve gap detection and reporting.  (#1601055)
c760726
accc579
* Thu Jul 12 2018 Fedora Release Engineering <releng@fedoraproject.org> - 8.10-2
accc579
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
accc579
5a7b2e9
* Thu Jul 12 2018 Nick Clifton <nickc@redhat.com> - 8.10-1
5a7b2e9
- Fix construction of absolute versions of --dwarf-dir and --debug-rpm options.
5a7b2e9
4efcfc9
* Tue Jul 10 2018 Nick Clifton <nickc@redhat.com> - 8.9-1
4efcfc9
- Fix buffer overrun when very long symbol names are encountered.
4efcfc9
be50c56
* Tue Jul 10 2018 Nick Clifton <nickc@redhat.com> - 8.8-1
be50c56
- Do not force the generation of function notes when -ffunction-sections is active.  (#1598961)
be50c56
a231425
* Mon Jul 09 2018 Nick Clifton <nickc@redhat.com> - 8.7-1
a231425
- Skip the .annobin_ prfix when reporting symbols.  (#1599315)
a231425
0342042
* Mon Jul 09 2018 Nick Clifton <nickc@redhat.com> - 8.6-1
0342042
- Use the assembler (c++ mangled) version of function names when switching sections.  (#1598579)
0342042
efaf793
* Mon Jul 09 2018 Nick Clifton <nickc@redhat.com> - 8.5-1
efaf793
- Do not call function_section.  (#1598961)
efaf793
326c603
* Fri Jul 06 2018 Nick Clifton <nickc@redhat.com> - 8.4-1
326c603
- Ignore cross-section gaps.  (#1598551)
326c603
ce5f9d5
* Thu Jul 05 2018 Nick Clifton <nickc@redhat.com> - 8.3-1
5a7b2e9
- Do not skip empty range notes in object files.  (#1598361)
ce5f9d5
a1b8a53
* Mon Jul 02 2018 Nick Clifton <nickc@redhat.com> - 8.2-1
a1b8a53
- Create the start symbol at the start of the function and the end symbol at the end.  (#1596823)
a1b8a53
7fa87a2
* Mon Jul 02 2018 Nick Clifton <nickc@redhat.com> - 8.1-1
7fa87a2
- Fix --debug-rpm when used inside a directory.
7fa87a2
f4130c1
* Thu Jun 28 2018 Nick Clifton <nickc@redhat.com> - 8.0-1
f4130c1
- Use a prefix for all annobin generated symbols, and make them hidden.
f4130c1
- Only generate weak symbol definitions for linkonce sections.
f4130c1
ae10117
* Wed Jun 27 2018 Nick Clifton <nickc@redhat.com> - 7.1-1
ae10117
- Skip some checks for relocatable object files, and dynamic objects.
ae10117
- Stop bogus complaints about stackrealignment not being enabled.
ae10117
a55d84f
* Mon Jun 25 2018 Nick Clifton <nickc@redhat.com> - 7.0-1
a55d84f
- Add -debug-rpm= option to annocheck.
a55d84f
- Only use a 2 byte offset for the initial symbol on PowerPC.
a55d84f
ec37d82
* Fri Jun 22 2018 Nick Clifton <nickc@redhat.com> - 6.6-1
ec37d82
- Use --dwarf-path when looking for build-id based debuginfo files.
ec37d82
4a3f774
* Fri Jun 22 2018 Nick Clifton <nickc@redhat.com> - 6.5-1
4a3f774
- Fix premature closing of dwarf handle.
4a3f774
25bca4e
* Fri Jun 22 2018 Nick Clifton <nickc@redhat.com> - 6.4-1
25bca4e
- Fix scoping bug computing the name of a separate debuginfo file.
25bca4e
9a6d845
* Tue Jun 19 2018 Nick Clifton <nickc@redhat.com> - 6.3-1
9a6d845
- Fix file descriptor leak.
9a6d845
b8b6c86
* Tue Jun 19 2018 Nick Clifton <nickc@redhat.com> - 6.2-1
b8b6c86
- Add command line options to annocheck to disable individual tests.
b8b6c86
9657bbe
* Fri Jun 08 2018 Nick Clifton <nickc@redhat.com> - 6.1-1
9657bbe
- Remove C99-ism from annocheck sources.
9657bbe
4656334
* Wed Jun 06 2018 Nick Clifton <nickc@redhat.com> - 6.0-1
4656334
- Add the annocheck program.
4656334
a47a7d3
* Fri Jun 01 2018 Nick Clifton <nickc@redhat.com> - 5.11-1
a47a7d3
- Do not use the SHF_GNU_BUILD_NOTE section flag.
a47a7d3
db2c4ce
* Thu May 31 2018 Nick Clifton <nickc@redhat.com> - 5.10-1
db2c4ce
- Remove .sh extension from shell scripts.
db2c4ce
78f88fb
* Wed May 30 2018 Nick Clifton <nickc@redhat.com> - 5.9-1
78f88fb
- Record the setting of the -mstackrealign option for i686 binaries.
78f88fb
29f42b4
* Mon May 14 2018 Nick Clifton <nickc@redhat.com> - 5.8-1
29f42b4
- Hide the annobin start of file symbol.
29f42b4
7a683bb
* Tue May 08 2018 Nick Clifton <nickc@redhat.com> - 5.7-1
7a683bb
- Fix script bug in hardended.sh.  (Thanks to: Stefan Sørensen <stefan.sorensen@spectralink.com>)
7a683bb
967f47d
* Thu May 03 2018 Nick Clifton <nickc@redhat.com> - 5.6-3
967f47d
- Version number bump so that the plugin can be rebuilt with the latest version of GCC.
967f47d
f45ff6b
* Mon Apr 30 2018 Nick Clifton <nickc@redhat.com> - 5.6-2
f45ff6b
- Rebuild the plugin with the newly created plugin enabled.  (#1573082)
f45ff6b
9d8fe91
* Mon Apr 30 2018 Nick Clifton <nickc@redhat.com> - 5.6-1
9d8fe91
- Skip the isa_flags check in the ABI test because the crt[in].o files are compiled with different flags from the test files.
9d8fe91
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.