Import fix for PR 21884 which stops a seg-fault in the linker when changing output format to binary during a final link.

Relates: #1491023

- Annotate patches with reason and lifetime expectances.
- Retire: binutils-2.24-ldforcele.patch
- Retire: binutils-2.25-set-long-long.patch
- Retire: binutils-2.25.1-cleansweep.patch
- Retire: binutils-2.26-fix-compile-warnings.patch
- Retire: binutils-2.28-ignore-gold-duplicates.patch
This commit is contained in:
Nick Clifton 2017-11-17 11:02:53 +00:00
parent b4e0b0f1cb
commit 747b48ebf0

View File

@ -1,19 +1,14 @@
# rpmbuild parameters:
# Binutils SPEC file. Can be invoked with the following parameters:
# --define "binutils_target arm-linux-gnu" to create arm-linux-gnu-binutils.
# --with=bootstrap: Build with minimal dependencies.
# --with=debug: Build without optimizations and without splitting the debuginfo.
# --without=docs: Skip building documentation.
# --without=testsuite: Do not run the testsuite.
# --without=testsuite: Do not run the testsuite. Default is to run it.
# --with=testsuite: Run the testsuite. Default when --with=debug is not to run it.
#---Start of Configure Options-----------------------------------------------------------------------
%if 0%{!?binutils_target:1}
%define binutils_target %{_target_platform}
%define isnative 1
%define enable_shared 1
%else
%define cross %{binutils_target}-
%define isnative 0
%define enable_shared 0
%endif
# BZ 1124342: Provide a way to enable deterministic archives.
# BZ 1195883: But do not do this by default.
%define enable_deterministic_archives 0
@ -21,6 +16,8 @@
%define enable_lto 1
# Disable the default generation of compressed debug sections.
%define default_compress_debug 0
# Default to read-only-relocations (relro) in shared binaries.
%define default_relro 1
# Default: Not bootstrapping.
%bcond_with bootstrap
@ -40,10 +37,24 @@
%undefine with_testsuite
%endif
#----End of Configure Options-----------------------------------------------------------------------
%if 0%{!?binutils_target:1}
%define binutils_target %{_target_platform}
%define isnative 1
%define enable_shared 1
%else
%define cross %{binutils_target}-
%define isnative 0
%define enable_shared 0
%endif
#---------------------------------------------------------------------------------
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.29
Release: 6%{?dist}
Release: 7%{?dist}
License: GPLv3+
Group: Development/Tools
URL: http://sources.redhat.com/binutils
@ -56,35 +67,74 @@ Source: http://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.xz
Source2: binutils-2.19.50.0.1-output-format.sed
# Purpose: Use /lib64 and /usr/lib64 instead of /lib and /usr/lib in the
# default library search path of 64-bit targets.
# Lifetime: Permanent, but it should not be. This is a bug in the libtool
# sources used in both binutils and gcc, (specifically the libtool.m4
# file). These are based on a version released in 2009 (2.2.6?) rather
# than the latest version. (Definitely fixed in libtool version 2.4.6).
Patch01: binutils-2.20.51.0.2-libtool-lib64.patch
# Purpose: Appends a RHEL or Fedora release string to the generic binutils version string.
# Lifetime: Permanent. This is a RHEL/Fedora specific patch.
Patch02: binutils-2.25-version.patch
Patch03: binutils-2.25-set-long-long.patch
Patch04: binutils-2.20.51.0.10-sec-merge-emit.patch
# Enable -zrelro by default: BZ #621983
Patch05: binutils-2.22.52.0.1-relro-on-by-default.patch
# Local patch - export demangle.h with the binutils-devel rpm.
Patch06: binutils-2.22.52.0.1-export-demangle.h.patch
# Disable checks that config.h has been included before system headers. BZ #845084
Patch07: binutils-2.22.52.0.4-no-config-h-check.patch
# Fix detections little endian PPC shared libraries
Patch08: binutils-2.24-ldforcele.patch
Patch09: binutils-2.25.1-cleansweep.patch
Patch10: binutils-2.26-fix-compile-warnings.patch
# Import H.J.Lu's Kernel LTO patch.
Patch11: binutils-2.26-lto.patch
# Skip PR14918 linker test for ARM native targets.
Patch12: binutils-2.29-skip-rp14918-test-for-arm.patch
# Include the filename concerned in readelf error messages.
Patch13: binutils-2.29-filename-in-error-messages.patch
# Ignore duplicate indirect symbols generated by GOLD.
Patch14: binutils-2.28-ignore-gold-duplicates.patch
# Do not enable the PPC64 plt-localentry0 linker optimization by default.
Patch15: binutils-2.29-ppc64-plt-localentry0-disable.patch
# Purpose: Prevent a seg-fault when attempting to pad a section with a NULL padding pointer.
# Lifetime: Permanent - but should be contributed upstream and fixed.
# FIXME: Need a test case to reproduce the potential bug so
# that the patch can be contributes.
Patch03: binutils-2.20.51.0.10-sec-merge-emit.patch
# Purpose: Exports the demangle.h header file (associated with the libiberty sources) with
# the binutils-devel rpm.
# Lifetime: Permanent. This is a RHEL/Fedora specific patch.
Patch04: binutils-2.22.52.0.1-export-demangle.h.patch
# Purpose: Disables the check in the BFD library's header file that config.h has been
# included before the bfd.h header. See BZ #845084 for more details.
# Lifetime: Permanent - but it should not be. The bfd.h header defines various types that
# are dependent upon configuration options, so he order of inclusion is important.
# FIXME: It would be better if the packages using the BFD header were fixed so
# that they do include the header files in the correct order. It may also be
# necessary to add a way for a package to tell the bfd.h header that this check
# is not necessary.
Patch05: binutils-2.22.52.0.4-no-config-h-check.patch
# Purpose: Import H.J.Lu's Kernel LTO patch.
# Lifetime: Permanent, but needs continual updating.
# FIXME: Try removing....
Patch06: binutils-2.26-lto.patch
# Purpose: Skip PR14918 linker test for ARM native targets.
# Lifetime: Permanent - but it should not be.
# FIXME: This patch should be contributed upstream.
Patch07: binutils-2.29-skip-rp14918-test-for-arm.patch
# Purpose: Include the filename concerned in readelf error messages.
# Lifetime: Permanent. This patch changes the format of readelf's output, making it
# better (IMHO) but also potentially breaking tools that depend upon readelf's
# current format. Hence it remains a local patch.
Patch08: binutils-2.29-filename-in-error-messages.patch
# Purpose: Do not enable the PPC64 plt-localentry0 linker optimization by default.
# Lifetime: Fixed in 2.29.1.
Patch09: binutils-2.29-ppc64-plt-localentry0-disable.patch
# Purpose: Prevent a seg-fault in the linker by not attempting to place orphan ELF
# sections into a non-ELF output section.
# Lifetime: Fixed in 2.29.1.
Patch10: binutils-2.29-non-elf-orphan-skip.patch
# Purpose: Ignore duplicate indirect symbols generated by GOLD.
# sections into a non-ELF output section.
# Lifetime: Fixed in 2.29.1.
Patch11: binutils-2.28-ignore-gold-duplicates.patch
#---------------------------------------------------------------------------------
Provides: bundled(libiberty)
# BZ 1173780: Building GOLD for PPC is not working at the moment.
# %define gold_arches %ix86 x86_64 %arm aarch64 ppc* %{power64}
%define gold_arches %ix86 x86_64 %arm aarch64
%if %{with bootstrap}
@ -155,6 +205,8 @@ Requires(preun): %{_sbindir}/alternatives
%define _gnu %{nil}
%endif
#---------------------------------------------------------------------------------
%description
Binutils is a collection of binary utilities, including ar (for
creating, modifying and extracting from archives), as (a family of GNU
@ -168,6 +220,8 @@ of an object or archive file), strings (for listing printable strings
from files), strip (for discarding symbols), and addr2line (for
converting addresses to file and line).
#---------------------------------------------------------------------------------
%package devel
Summary: BFD and opcodes static and dynamic libraries and header files
Group: System Environment/Libraries
@ -195,25 +249,21 @@ dynamic libraries.
Developers starting new projects are strongly encouraged to consider
using libelf instead of BFD.
#---------------------------------------------------------------------------------
%prep
%setup -q -n binutils-%{version}
%patch01 -p1 -b .libtool-lib64~
%patch02 -p1 -b .version~
%patch03 -p1 -b .set-long-long~
%patch04 -p1 -b .sec-merge-emit~
%patch05 -p1 -b .relro~
%patch06 -p1 -b .export-demangle-h~
%patch07 -p1 -b .no-config-h-check~
%ifarch ppc64le
%patch08 -p1 -b .ldforcele~
%endif
%patch09 -p0
%patch01 -p1
%patch02 -p1
%patch03 -p1
%patch04 -p1
%patch05 -p1
%patch06 -p1
%patch07 -p1
%patch08 -p1
%patch09 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -251,15 +301,17 @@ touch */configure
%define _target_platform %{_arch}-%{_vendor}-%{_host_os}
%endif
#---------------------------------------------------------------------------------
%build
echo target is %{binutils_target}
%ifarch %{power64}
#CFLAGS=`echo $RPM_OPT_FLAGS | sed -e -s "s/-Werror//g"`
#export CFLAGS
export CFLAGS="$RPM_OPT_FLAGS -Wno-error"
%else
export CFLAGS="$RPM_OPT_FLAGS"
%endif
CARGS=
case %{binutils_target} in i?86*|sparc*|ppc*|s390*|sh*|arm*|aarch64*)
@ -300,6 +352,7 @@ CFLAGS="$CFLAGS -O0 -ggdb2 -Wno-error -D_FORTIFY_SOURCE=0"
# We could optimize the cross builds size by --enable-shared but the produced
# binaries may be less convenient in the embedded environment.
%configure \
--quiet \
--build=%{_target_platform} --host=%{_target_platform} \
--target=%{binutils_target} \
%ifarch %gold_arches
@ -333,6 +386,11 @@ CFLAGS="$CFLAGS -O0 -ggdb2 -Wno-error -D_FORTIFY_SOURCE=0"
--enable-compressed-debug-sections=all \
%else
--enable-compressed-debug-sections=none \
%endif
%if %{default_relro}
--enable-relro=yes \
%else
--enable-relro=no \
%endif
$CARGS \
--enable-plugins \
@ -363,6 +421,8 @@ uuencode binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}.tar.b
rm -f binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}-*.{sum,log}
%endif
#---------------------------------------------------------------------------------
%install
rm -rf %{buildroot}
%if %{with docs}
@ -372,7 +432,7 @@ make install DESTDIR=%{buildroot} MAKEINFO=true
%endif
%if %{isnative}
%if %{with info}
%if %{with docs}
make prefix=%{buildroot}%{_prefix} infodir=%{buildroot}%{_infodir} install-info
%endif
@ -453,14 +513,14 @@ $OUTPUT_FORMAT
INPUT ( %{_libdir}/libopcodes.a -lbfd )
EOH
%else # !%{isnative}
%else # !isnative
# For cross-binutils we drop the documentation.
rm -rf %{buildroot}%{_infodir}
# We keep these as one can have native + cross binutils of different versions.
#rm -rf %{buildroot}%{_prefix}/share/locale
#rm -rf %{buildroot}%{_mandir}
#rm -rf {buildroot}{_prefix}/share/locale
#rm -rf {buildroot}{_mandir}
rm -rf %{buildroot}%{_libdir}/libiberty.a
%endif # !%{isnative}
%endif # !isnative
# This one comes from gcc
rm -f %{buildroot}%{_infodir}/dir
@ -485,9 +545,13 @@ if [ -x gold/ld-new ]; then
cat %{?cross}gold.lang >> %{?cross}binutils.lang
fi
#---------------------------------------------------------------------------------
%clean
rm -rf %{buildroot}
#---------------------------------------------------------------------------------
%post
%if "%{build_gold}" == "both"
%__rm -f %{_bindir}/%{?cross}ld
@ -497,6 +561,7 @@ rm -rf %{buildroot}
%{_bindir}/%{?cross}ld.gold %{ld_gold_priority}
%{_sbindir}/alternatives --auto %{?cross}ld
%endif
%if %{isnative}
/sbin/ldconfig
%if %{with docs}
@ -505,9 +570,12 @@ rm -rf %{buildroot}
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/gprof.info.gz
/sbin/install-info --info-dir=%{_infodir} %{_infodir}/ld.info.gz
%endif # with docs
%endif # %{isnative}
%endif # isnative
exit 0
#---------------------------------------------------------------------------------
%preun
%if "%{build_gold}" == "both"
if [ $1 = 0 ]; then
@ -515,6 +583,7 @@ if [ $1 = 0 ]; then
%{_sbindir}/alternatives --remove %{?cross}ld %{_bindir}/%{?cross}ld.gold
fi
%endif
%if %{isnative}
if [ $1 = 0 ]; then
if [ -e %{_infodir}/binutils.info.gz ]
@ -526,8 +595,11 @@ if [ $1 = 0 ]; then
fi
fi
%endif
exit 0
#---------------------------------------------------------------------------------
%if %{isnative}
%postun
/sbin/ldconfig
@ -538,24 +610,31 @@ exit 0
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/gprof.info.gz
/sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/ld.info.gz
fi
%endif # %{isnative}
%endif # isnative
#---------------------------------------------------------------------------------
%files -f %{?cross}binutils.lang
%defattr(-,root,root,-)
%license COPYING COPYING3 COPYING3.LIB COPYING.LIB
%doc README
%{_bindir}/%{?cross}[!l]*
%if "%{build_gold}" == "both"
%{_bindir}/%{?cross}ld.*
%ghost %{_bindir}/%{?cross}ld
%else
%{_bindir}/%{?cross}ld*
%endif
%if %{with docs}
%{_mandir}/man1/*
%{_infodir}/as.info.gz
%{_infodir}/binutils.info.gz
%{_infodir}/gprof.info.gz
%{_infodir}/ld.info.gz
%endif # with docs
%if %{enable_shared}
%{_libdir}/lib*.so
%exclude %{_libdir}/libbfd.so
@ -577,9 +656,21 @@ exit 0
%if %{with docs}
%{_infodir}/bfd*info*
%endif # with docs
%endif # %{isnative}
%endif # isnative
#---------------------------------------------------------------------------------
%changelog
* Fri Nov 17 2017 Nick Clifton <nickc@redhat.com> 2.29-7
- Import fix for PR 21884 which stops a seg-fault in the linker when changing output format to binary during a final link.
(#1491023)
- Annotate patches with reason and lifetime expectances.
- Retire: binutils-2.24-ldforcele.patch
- Retire: binutils-2.25-set-long-long.patch
- Retire: binutils-2.25.1-cleansweep.patch
- Retire: binutils-2.26-fix-compile-warnings.patch
- Retire: binutils-2.28-ignore-gold-duplicates.patch
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 2.29-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
@ -1018,7 +1109,7 @@ exit 0
- Fix compiling using gcc 4.9 (#1087374)
* Thu Mar 27 2014 Nick Clifton <nickc@redhat.com> - 2.24-11
- Use %{version} in Source string. Delete unused patches.
- Use {version} in Source string. Delete unused patches.
* Tue Jan 28 2014 Nick Clifton <nickc@redhat.com> - 2.24-10
- Fix decoding of abbrevs using a DW_FORM_ref_addr attribute. (#1056797)
@ -1233,10 +1324,8 @@ exit 0
* Fri Apr 27 2012 Nick Clifton <nickc@redhat.com> - 2.22.52.0.1-12
- Include demangle.h in the devel rpm.
%if 0%{?rhel} >= 7
* Tue Apr 03 2012 Nick Clifton <nickc@redhat.com> - 2.22.52.0.1-11
- Enable -zrelro by default for RHEL 7+. (#807831)
%endif
* Fri Mar 16 2012 Jakub Jelinek <jakub@redhat.com> - 2.22.52.0.1-10
- Fix up handling of hidden ifunc relocs on i?86
@ -1248,10 +1337,8 @@ exit 0
- Fix up handling of hidden ifunc relocs on x86_64
- Add Intel TSX support
%if 0%{?fedora} >= 18
* Tue Mar 06 2012 Nick Clifton <nickc@redhat.com> - 2.22.52.0.1-7
- Enable -zrelro by default. (#621983 #807831)
%endif
* Mon Feb 27 2012 Jeff Law <law@redhat.com> - 2.22.52.0.1-6
- Fix c++filt docs (#797752)
@ -2608,4 +2695,3 @@ exit 0
* Wed Oct 22 1997 Erik Troan <ewt@redhat.com>
- added 2.8.1.0.1 patch from hj
- added patch for alpha palcode form rth