[packages/cross-binutils: 1/5] new package build all cross target from single source version 2.25

glen glen at pld-linux.org
Wed Jan 7 20:49:34 CET 2015


commit 59e455fe561a05015dd12cb133aef7441770a342
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Wed Jan 7 09:59:10 2015 +0200

    new package
    build all cross target from single source
    version 2.25
    
    based on fedora package 8000c8f

 binutils-2.19.50.0.1-output-format.sed         |   38 +
 binutils-2.20.51.0.10-copy-osabi.patch         |   17 +
 binutils-2.20.51.0.10-ppc64-pie.patch          |   12 +
 binutils-2.20.51.0.10-sec-merge-emit.patch     |   20 +
 binutils-2.20.51.0.2-ia64-lib64.patch          |   21 +
 binutils-2.20.51.0.2-libtool-lib64.patch       |  236 +++
 binutils-2.22.52.0.1-export-demangle.h.patch   |   33 +
 binutils-2.22.52.0.1-relro-on-by-default.patch |   58 +
 binutils-2.22.52.0.4-no-config-h-check.patch   |   28 +
 binutils-2.23.2-aarch64-em.patch               |   26 +
 binutils-2.23.52.0.1-addr2line-dynsymtab.patch |   38 +
 binutils-2.24-ldforcele.patch                  |   54 +
 binutils-2.25-kernel-ld-r.patch                | 2362 ++++++++++++++++++++++++
 binutils-2.25-set-long-long.patch              |   38 +
 binutils-2.25-version.patch                    |   47 +
 cross-binutils.spec                            |  617 +++++++
 16 files changed, 3645 insertions(+)
---
diff --git a/cross-binutils.spec b/cross-binutils.spec
new file mode 100644
index 0000000..16b2673
--- /dev/null
+++ b/cross-binutils.spec
@@ -0,0 +1,617 @@
+
+%define cross cross
+%define rpmprefix %{nil}
+
+%define build_all		1
+%define build_alpha		%{build_all}
+%define build_arm		%{build_all}
+%define build_aarch64		%{build_all}
+%define build_avr32		%{build_all}
+%define build_blackfin		%{build_all}
+%define build_c6x		%{build_all}
+%define build_cris		%{build_all}
+%define build_frv		%{build_all}
+%define build_h8300		%{build_all}
+%define build_hppa		%{build_all}
+%define build_hppa64		%{build_all}
+%define build_ia64		%{build_all}
+%define build_m32r		%{build_all}
+%define build_m68k		%{build_all}
+%define build_metag		%{build_all}
+%define build_microblaze	%{build_all}
+%define build_mips64		%{build_all}
+%define build_mn10300		%{build_all}
+%define build_nios2		%{build_all}
+%define build_openrisc		%{build_all}
+%define build_powerpc64		%{build_all}
+%define build_s390x		%{build_all}
+%define build_score		%{build_all}
+%define build_sh		%{build_all}
+%define build_sh64		%{build_all}
+%define build_sparc64		%{build_all}
+%define build_tile		%{build_all}
+%define build_x86_64		%{build_all}
+%define build_xtensa		%{build_all}
+
+# 32-bit packages we don't build as we can use the 64-bit package instead
+%define build_i386		0
+%define build_mips		0
+%define build_powerpc		0
+%define build_s390		0
+%define build_sparc		0
+%define build_sh4		0
+
+# not available in binutils-2.24
+%define build_hexagon		0
+%define build_unicore32		0
+
+Summary:	A GNU collection of cross-compilation binary utilities
+Name:		%{cross}-binutils
+Version:	2.25
+Release:	0.2
+License:	GPL v3+
+Group:		Development/Tools
+URL:		http://sources.redhat.com/binutils
+# Note - the Linux Kernel binutils releases are too unstable and contain too
+# many controversial patches so we stick with the official FSF version
+# instead.
+Source0:	http://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.bz2
+# Source0-md5:	d9f3303f802a5b6b0bb73a335ab89d66
+Source2:	binutils-2.19.50.0.1-output-format.sed
+# Bring up to date with what's in the git release branch
+#Patch00: binutils-2.24-cde98f8566e14f52b896abc92c357cdd14717505.patch
+Patch01:	binutils-2.20.51.0.2-libtool-lib64.patch
+Patch02:	binutils-2.20.51.0.10-ppc64-pie.patch
+Patch03:	binutils-2.20.51.0.2-ia64-lib64.patch
+Patch04:	binutils-2.25-version.patch
+Patch05:	binutils-2.25-set-long-long.patch
+Patch06:	binutils-2.20.51.0.10-copy-osabi.patch
+Patch07:	binutils-2.20.51.0.10-sec-merge-emit.patch
+# Enable -zrelro by default: BZ #621983
+Patch08:	binutils-2.22.52.0.1-relro-on-by-default.patch
+# Local patch - export demangle.h with the binutils-devel rpm.
+Patch09:	binutils-2.22.52.0.1-export-demangle.h.patch
+# Disable checks that config.h has been included before system headers.  BZ #845084
+Patch10:	binutils-2.22.52.0.4-no-config-h-check.patch
+# Fix addr2line to use the dynamic symbol table if it could not find any ordinary symbols.
+Patch11:	binutils-2.23.52.0.1-addr2line-dynsymtab.patch
+Patch12:	binutils-2.25-kernel-ld-r.patch
+# Correct bug introduced by patch 12
+Patch13:	binutils-2.23.2-aarch64-em.patch
+# Fix detections little endian PPC shared libraries
+Patch14:	binutils-2.24-ldforcele.patch
+BuildRequires:	bison
+BuildRequires:	flex
+BuildRequires:	gettext
+BuildRequires:	texinfo >= 4.0
+BuildRequires:	zlib-devel
+# BZ 920545: We need pod2man in order to build the manual pages.
+BuildRequires:	/usr/bin/pod2man
+# Required for: ld-bootstrap/bootstrap.exp bootstrap with --static
+# It should not be required for: ld-elf/elf.exp static {preinit,init,fini} array
+Conflicts:	gcc-c++ < 4.0.0
+%ifarch ia64
+Obsoletes:	gnupro <= 1117-1
+%endif
+Provides:	bundled(libiberty)
+BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+# Where the binaries aimed at gcc will live (ie. /usr/<target>/bin/)
+%define auxbin_prefix %{_exec_prefix}
+%define srcdir binutils-%{version}
+
+%description
+Binutils is a collection of binary utilities, including ar (for
+creating, modifying and extracting from archives), as (a family of GNU
+assemblers), gprof (for displaying call graph profile data), ld (the
+GNU linker), nm (for listing symbols from object files), objcopy (for
+copying and translating object files), objdump (for displaying
+information from object files), ranlib (for generating an index for
+the contents of an archive), readelf (for displaying detailed
+information about binary files), size (for listing the section sizes
+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 -n %{cross}-binutils-common
+Summary:	Cross-build binary utility documentation and translation files
+Group:		Development/Tools
+%if "%{_rpmversion}" >= "5"
+BuildArch:	noarch
+%endif
+
+%description -n %{cross}-binutils-common
+Documentation, manual pages and translation files for cross-build
+binary image generation, manipulation and query tools.
+
+%define do_package() \
+%package -n %{rpmprefix}binutils-%1 \
+Summary:	Cross-build binary utilities for %1 \
+Group:		Development/Tools \
+Requires:	%{cross}-binutils-common = %{version}-%{release}\
+\
+%description -n %{rpmprefix}binutils-%1 \
+Cross-build binary image generation, manipulation and query tools. \
+
+%define do_symlink() \
+%package -n %{rpmprefix}binutils-%1 \
+Summary:	Cross-build binary utilities for %1 \
+Group:		Development/Tools \
+Requires:	binutils-%3 = %{version}-%{release}\
+\
+%description -n %{rpmprefix}binutils-%1 \
+Cross-build binary image generation, manipulation and query tools. \
+
+%do_package alpha-linux-gnu	%{build_alpha}
+%do_package arm-linux-gnu	%{build_arm}
+%do_package aarch64-linux-gnu	%{build_aarch64}
+%do_package avr32-linux-gnu	%{build_avr32}
+%do_package bfin-linux-gnu	%{build_blackfin}
+%do_package c6x-linux-gnu	%{build_c6x}
+%do_package cris-linux-gnu	%{build_cris}
+%do_package frv-linux-gnu	%{build_frv}
+%do_package h8300-linux-gnu	%{build_h8300}
+%do_package hexagon-linux-gnu	%{build_hexagon}
+%do_package hppa-linux-gnu	%{build_hppa}
+%do_package hppa64-linux-gnu	%{build_hppa64}
+%do_package i386-linux-gnu	%{build_i386}
+%do_package ia64-linux-gnu	%{build_ia64}
+%do_package m32r-linux-gnu	%{build_m32r}
+%do_package m68k-linux-gnu	%{build_m68k}
+%do_package metag-linux-gnu	%{build_metag}
+%do_package microblaze-linux-gnu %{build_microblaze}
+%do_package mips-linux-gnu	%{build_mips}
+%do_package mips64-linux-gnu	%{build_mips64}
+%do_package mn10300-linux-gnu	%{build_mn10300}
+%do_package nios2-linux-gnu	%{build_nios2}
+%do_package openrisc-linux-gnu	%{build_openrisc}	or1k-linux-gnu
+%do_package powerpc-linux-gnu	%{build_powerpc}
+%do_package powerpc64-linux-gnu	%{build_powerpc64}
+%do_symlink ppc-linux-gnu	%{build_powerpc}	powerpc-linux-gnu
+%do_symlink ppc64-linux-gnu	%{build_powerpc64}	powerpc64-linux-gnu
+%do_package s390-linux-gnu	%{build_s390}
+%do_package s390x-linux-gnu	%{build_s390x}
+%do_package score-linux-gnu	%{build_score}
+%do_package sh-linux-gnu	%{build_sh}
+%do_package sh4-linux-gnu	%{build_sh4}
+%do_package sh64-linux-gnu	%{build_sh64}
+%do_package sparc-linux-gnu	%{build_sparc}
+%do_package sparc64-linux-gnu	%{build_sparc64}
+%do_package tile-linux-gnu	%{build_tile}
+%do_package unicore32-linux-gnu	%{build_unicore32}
+%do_package x86_64-linux-gnu	%{build_x86_64}
+%do_package xtensa-linux-gnu	%{build_xtensa}
+
+%prep
+%setup -qc
+cd %{srcdir}
+%if 1
+#%patch00 -p1 -b .latest-git~
+%patch01 -p1
+%patch02 -p1
+%ifarch ia64
+%if "%{_lib}" == "lib64"
+%patch03 -p1
+%endif
+%endif
+%patch04 -p1
+%patch05 -p1
+%patch06 -p1
+%patch07 -p1
+%patch08 -p1
+%patch09 -p1
+%patch10 -p1
+%patch11 -p1
+%patch12 -p1
+%patch13 -p1
+%patch14 -p1
+%endif
+
+# We cannot run autotools as there is an exact requirement of autoconf-2.59.
+
+# On ppc64 we might use 64KiB pages
+sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*ppc.c
+# LTP sucks
+perl -pi -e 's/i\[3-7\]86/i[34567]86/g' */conf*
+sed -i -e 's/%''{release}/%{release}/g' bfd/Makefile{.am,.in}
+sed -i -e '/^libopcodes_la_\(DEPENDENCIES\|LIBADD\)/s,$, ../bfd/libbfd.la,' opcodes/Makefile.{am,in}
+# Build libbfd.so and libopcodes.so with -Bsymbolic-functions if possible.
+if gcc %{optflags} -v --help 2>&1 | grep -q -- -Bsymbolic-functions; then
+	sed -i -e 's/^libbfd_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' bfd/Makefile.{am,in}
+	sed -i -e 's/^libopcodes_la_LDFLAGS = /&-Wl,-Bsymbolic-functions /' opcodes/Makefile.{am,in}
+fi
+
+# $PACKAGE is used for the gettext catalog name.
+sed -i -e 's/^ PACKAGE=/ PACKAGE=%{cross}-/' */configure
+# Undo the name change to run the testsuite.
+for tool in binutils gas ld; do
+	sed -i -e "2aDEJATOOL = $tool" $tool/Makefile.am
+	sed -i -e "s/^DEJATOOL = .*/DEJATOOL = $tool/" $tool/Makefile.in
+done
+touch */configure
+
+function prep_target () {
+    target=$1
+    cond=$2
+
+    if [ $cond != 0 ]; then
+		echo $1 >&5
+    fi
+}
+
+cd ..
+(
+	prep_target alpha-linux-gnu		%{build_alpha}
+	prep_target arm-linux-gnu		%{build_arm}
+	prep_target aarch64-linux-gnu	%{build_aarch64}
+	prep_target avr32-linux-gnu		%{build_avr32}
+	prep_target bfin-linux-gnu		%{build_blackfin}
+	prep_target c6x-linux-gnu		%{build_c6x}
+	prep_target cris-linux-gnu		%{build_cris}
+	prep_target frv-linux-gnu		%{build_frv}
+	prep_target h8300-linux-gnu		%{build_h8300}
+	prep_target hexagon-linux-gnu	%{build_hexagon}
+	prep_target hppa-linux-gnu		%{build_hppa}
+	prep_target hppa64-linux-gnu	%{build_hppa64}
+	prep_target i386-linux-gnu		%{build_i386}
+	prep_target ia64-linux-gnu		%{build_ia64}
+	prep_target m32r-linux-gnu		%{build_m32r}
+	prep_target m68k-linux-gnu		%{build_m68k}
+	prep_target metag-linux-gnu		%{build_metag}
+	prep_target microblaze-linux-gnu	%{build_microblaze}
+	prep_target mips-linux-gnu		%{build_mips}
+	prep_target mips64-linux-gnu	%{build_mips64}
+	prep_target mn10300-linux-gnu	%{build_mn10300}
+	prep_target nios2-linux-gnu		%{build_nios2}
+	prep_target openrisc-linux-gnu	%{build_openrisc}
+	prep_target powerpc-linux-gnu	%{build_powerpc}
+	prep_target powerpc64-linux-gnu	%{build_powerpc64}
+	prep_target s390-linux-gnu		%{build_s390}
+	prep_target s390x-linux-gnu		%{build_s390x}
+	prep_target score-linux-gnu		%{build_score}
+	prep_target sh-linux-gnu		%{build_sh}
+	prep_target sh4-linux-gnu		%{build_sh4}
+	prep_target sh64-linux-gnu		%{build_sh64}
+	prep_target sparc-linux-gnu		%{build_sparc}
+	prep_target sparc64-linux-gnu	%{build_sparc64}
+	prep_target tile-linux-gnu		%{build_tile}
+	prep_target unicore32-linux-gnu	%{build_unicore32}
+	prep_target x86_64-linux-gnu	%{build_x86_64}
+	prep_target xtensa-linux-gnu	%{build_xtensa}
+) 5>target.list
+
+n=0
+for target in $(cat target.list); do
+	n=1
+	break
+done
+if [ $n = 0 ]; then
+	echo >&2 "No targets selected"
+	exit 8
+fi
+
+%build
+
+config_target() {
+	arch=$1
+	prefix=$arch-
+	build_dir=${1%%%%-*}
+
+	case $arch in
+	arm-*)		target=arm-linux-gnueabi;;
+	aarch64-*)	target=aarch64-linux-gnu;;
+	avr32-*)	target=avr-linux;;
+	bfin-*)		target=bfin-uclinux;;
+	c6x-*)		target=c6x-uclinux;;
+	h8300-*)	target=h8300-elf;;
+	m32r-*)		target=m32r-elf;;
+	mn10300-*)	target=am33_2.0-linux;;
+	m68knommu-*)	target=m68k-linux;;
+	openrisc-*)	target=or1k-linux-gnu;;
+	parisc-*)	target=hppa-linux;;
+	score-*)	target=score-elf;;
+	sh64-*)		target=sh64-linux;;
+	tile-*)		target=tilegx-linux;;
+	v850-*)		target=v850e-linux;;
+	x86-*)		target=x86_64-linux;;
+	*)		target=$arch;;
+	esac
+
+	echo $arch: target is $target
+	export CFLAGS="$RPM_OPT_FLAGS"
+	CARGS=
+
+	case $target in i?86*|sparc*|ppc*|s390*|sh*|arm*)
+		CARGS="$CARGS --enable-64-bit-bfd"
+		;;
+	esac
+
+	case $target in ia64*)
+		CARGS="$CARGS --enable-targets=i386-linux"
+		;;
+	esac
+
+	case $target in ppc*|ppc64*)
+		CARGS="$CARGS --enable-targets=spu"
+		;;
+	esac
+
+	case $target in sh-*)
+		CARGS="$CARGS --enable-targets=sh4-linux"
+		;;
+	esac
+
+	case $target in sh64*)
+		CARGS="$CARGS --enable-targets=sh64-linux,sh-elf,sh-linux,sh4-linux"
+		;;
+	esac
+
+	mkdir $build_dir
+	cd $build_dir
+
+	# We could optimize the cross builds size by --enable-shared but the produced
+	# binaries may be less convenient in the embedded environment.
+	LDFLAGS="-Wl,-z,relro " \
+	../%{srcdir}/configure \
+	--disable-dependency-tracking \
+	--disable-silent-rules \
+	--enable-checking \
+	--prefix=%{_prefix} \
+	--exec-prefix=%{auxbin_prefix} \
+	--bindir=%{_bindir} \
+	--sbindir=%{_sbindir} \
+	--sysconfdir=%{_sysconfdir} \
+	--datadir=%{_datadir} \
+	--includedir=%{_includedir} \
+	--libdir=%{_libdir} \
+	--libexecdir=%{_libexecdir} \
+	--localstatedir=%{_localstatedir} \
+	--sharedstatedir=%{_sharedstatedir} \
+	--mandir=%{_mandir} \
+	--infodir=%{_infodir} \
+	--build=%{_target_platform} \
+	--host=%{_target_platform} \
+	--target=$target \
+	--program-prefix=$prefix \
+	--disable-shared \
+	--disable-install_libbfd \
+	--with-sysroot=%{_prefix}/$arch/sys-root \
+	$CARGS \
+	--with-bugurl="http://bugs.pld-linux.org"
+	cd ..
+}
+
+for target in $(cat target.list); do
+	config_target $target
+done
+
+build_target() {
+	build_dir=${1%%%%-*}
+	make -C $build_dir %{_smp_mflags} tooldir=%{_prefix} all
+}
+
+for target in $(cat target.list); do
+	build_target $target
+done
+
+# for documentation purposes only
+mkdir %{cross}-binutils
+cd %{cross}-binutils
+../%{srcdir}/configure \
+	--disable-dependency-tracking \
+	--disable-silent-rules \
+	--prefix=%{_prefix} \
+	--exec-prefix=%{auxbin_prefix} \
+	--bindir=%{_bindir} \
+	--sbindir=%{_sbindir} \
+	--sysconfdir=%{_sysconfdir} \
+	--datadir=%{_datadir} \
+	--includedir=%{_includedir} \
+	--libdir=%{_libdir} \
+	--libexecdir=%{_libexecdir} \
+	--localstatedir=%{_localstatedir} \
+	--sharedstatedir=%{_sharedstatedir} \
+	--mandir=%{_mandir} \
+	--infodir=%{_infodir} \
+	--program-prefix=%{cross}- \
+	--disable-shared \
+	--with-bugurl="http://bugs.pld-linux.org"
+
+%{__make} tooldir=%{_prefix} all
+cd ..
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+install_bin() {
+	cpu=${1%%%%-*}
+	build_dir=$cpu
+	%{__make} install -C $build_dir DESTDIR=$RPM_BUILD_ROOT
+
+	# We want links for ppc and ppc64 also if we make powerpc or powerpc64
+	case $cpu in
+	powerpc*)
+		cd $RPM_BUILD_ROOT%{_bindir}
+			for i in $cpu-*; do
+				ln -s $i ppc${i#powerpc}
+			done
+		cd -
+		cd $RPM_BUILD_ROOT%{_prefix}
+		for i in $cpu-*; do
+			ln -s $i ppc${i#powerpc}
+		done
+		cd -
+		cd $RPM_BUILD_ROOT%{_mandir}/man1
+		for i in $cpu-*; do
+			ln -s $i ppc${i#powerpc}
+		done
+		cd -
+		;;
+	esac
+}
+
+for target in $(cat target.list); do
+	echo "=== INSTALL target $target ==="
+	install -d $RPM_BUILD_ROOT%{_prefix}/$target/sys-root
+	install_bin $target
+
+	if [ $target = sh64-linux-gnu ]; then
+		ln -s %{auxbin_prefix}/sh64-elf $RPM_BUILD_ROOT%{auxbin_prefix}/sh64-linux
+	fi
+done
+
+echo "=== INSTALL man targets ==="
+%{__make} install-man1 -C %{cross}-binutils/binutils/doc DESTDIR=$RPM_BUILD_ROOT
+%{__make} install-man1 -C %{cross}-binutils/gas/doc DESTDIR=$RPM_BUILD_ROOT
+%{__make} install-man1 -C %{cross}-binutils/ld DESTDIR=$RPM_BUILD_ROOT
+%{__make} install-man1 -C %{cross}-binutils/gprof DESTDIR=$RPM_BUILD_ROOT
+
+echo "=== INSTALL po targets ==="
+%{__make} install -C %{cross}-binutils/binutils/po DESTDIR=$RPM_BUILD_ROOT
+%{__make} install -C %{cross}-binutils/gas/po DESTDIR=$RPM_BUILD_ROOT
+%{__make} install -C %{cross}-binutils/ld/po DESTDIR=$RPM_BUILD_ROOT
+%{__make} install -C %{cross}-binutils/gprof/po DESTDIR=$RPM_BUILD_ROOT
+%{__make} install -C %{cross}-binutils/bfd/po DESTDIR=$RPM_BUILD_ROOT
+%{__make} install -C %{cross}-binutils/opcodes/po DESTDIR=$RPM_BUILD_ROOT
+
+# Add the additional symlink-only targets
+grep ^powerpc target.list | sed -e s/powerpc/ppc/ > symlink-target.list
+cat symlink-target.list >> target.list
+
+# For cross-binutils we drop the documentation.
+echo "=== REMOVE documentation ==="
+rm -rf $RPM_BUILD_ROOT%{_infodir}
+rm -f $RPM_BUILD_ROOT%{_infodir}/dir
+
+echo "=== REMOVE libraries and scripts ==="
+rm -rf $RPM_BUILD_ROOT%{_libdir}/libiberty.a
+rm -rf $RPM_BUILD_ROOT%{auxbin_prefix}/*/lib/ldscripts
+rmdir $RPM_BUILD_ROOT%{auxbin_prefix}/*/lib || :
+
+echo "=== BUILD file lists ==="
+build_file_list() {
+	arch=$1
+	cpu=${arch%%%%-*}
+
+	case $cpu in
+	avr32)		target_cpu=avr;;
+	bfin)		target_cpu=bfin;;
+	h8300)		target_cpu=h8300;;
+	mn10300)	target_cpu=am33_2.0;;
+	openrisc)	target_cpu=or1k;;
+	score)		target_cpu=score;;
+	tile)		target_cpu=tilegx;;
+	v850)		target_cpu=v850e;;
+	*)		target_cpu=$cpu;;
+	esac
+
+	(
+	echo '%%defattr(-,root,root,-)'
+	echo %{_bindir}/$arch-[!l]\*
+	echo %{_bindir}/$arch-ld\*
+	if [ -L $RPM_BUILD_ROOT%{auxbin_prefix}/$target_cpu-* ]; then
+		echo %{auxbin_prefix}/$target_cpu-*
+	else
+		echo %{auxbin_prefix}/$target_cpu-*/bin/\*
+	fi
+	echo %{_mandir}/man1/$arch-\*
+	echo %{_prefix}/$arch/sys-root
+	) > files.$arch
+}
+
+for target in $(cat target.list); do
+	build_file_list $target
+done
+
+# All the installed manual pages and translation files for each program are the
+# same, so symlink them to the core package
+echo "=== CROSSLINK man pages ==="
+cd $RPM_BUILD_ROOT%{_mandir}/man1
+	for i in %{cross}-*.1*; do
+		j=${i#%{cross}-}
+
+		for k in *-$j; do
+			if [ $k != $i ]; then
+				ln -sf $i $k
+			fi
+		done
+	done
+
+	# Add ld.bfd manual pages
+	find * -name "*ld.1*" -a ! -name "%{cross}-ld.1*" -print |
+	while read x; do
+		y=$(echo $x | sed -e s/ld[.]1/ld.bfd.1/)
+		ln -s $x $y
+	done
+cd -
+
+# Find the language files which only exist in the common package
+%find_lang %{cross}-binutils
+%find_lang %{cross}-opcodes
+%find_lang %{cross}-bfd
+%find_lang %{cross}-gas
+%find_lang %{cross}-ld
+%find_lang %{cross}-gprof
+cat \
+%{cross}-binutils.lang \
+%{cross}-opcodes.lang \
+%{cross}-bfd.lang \
+%{cross}-gas.lang \
+%{cross}-ld.lang \
+%{cross}-gprof.lang \
+ > files.cross
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files -n %{cross}-binutils-common -f files.cross
+%defattr(644,root,root,755)
+%doc %{srcdir}/README
+%doc %{srcdir}/COPYING*
+%{_mandir}/man1/%{cross}-*
+
+%define do_files() \
+%if %2 \
+%files -n %{rpmprefix}binutils-%1 -f files.%1 \
+%defattr(644,root,root,755) \
+%endif
+
+%do_files alpha-linux-gnu	%{build_alpha}
+%do_files arm-linux-gnu		%{build_arm}
+%do_files aarch64-linux-gnu	%{build_aarch64}
+%do_files avr32-linux-gnu	%{build_avr32}
+%do_files bfin-linux-gnu	%{build_blackfin}
+%do_files c6x-linux-gnu		%{build_c6x}
+%do_files cris-linux-gnu	%{build_cris}
+%do_files frv-linux-gnu		%{build_frv}
+%do_files h8300-linux-gnu	%{build_h8300}
+%do_files hexagon-linux-gnu	%{build_hexagon}
+%do_files hppa-linux-gnu	%{build_hppa}
+%do_files hppa64-linux-gnu	%{build_hppa64}
+%do_files i386-linux-gnu	%{build_i386}
+%do_files ia64-linux-gnu	%{build_ia64}
+%do_files m32r-linux-gnu	%{build_m32r}
+%do_files m68k-linux-gnu	%{build_m68k}
+%do_files metag-linux-gnu	%{build_metag}
+%do_files microblaze-linux-gnu	%{build_microblaze}
+%do_files mips-linux-gnu	%{build_mips}
+%do_files mips64-linux-gnu	%{build_mips64}
+%do_files mn10300-linux-gnu	%{build_mn10300}
+%do_files nios2-linux-gnu	%{build_nios2}
+%do_files openrisc-linux-gnu	%{build_openrisc}
+%do_files powerpc-linux-gnu	%{build_powerpc}
+%do_files powerpc64-linux-gnu	%{build_powerpc64}
+%do_files ppc-linux-gnu		%{build_powerpc}
+%do_files ppc64-linux-gnu	%{build_powerpc64}
+%do_files s390-linux-gnu	%{build_s390}
+%do_files s390x-linux-gnu	%{build_s390x}
+%do_files score-linux-gnu	%{build_score}
+%do_files sh-linux-gnu		%{build_sh}
+%do_files sh4-linux-gnu		%{build_sh4}
+%do_files sh64-linux-gnu	%{build_sh64}
+%do_files sparc-linux-gnu	%{build_sparc}
+%do_files sparc64-linux-gnu	%{build_sparc64}
+%do_files tile-linux-gnu	%{build_tile}
+%do_files unicore32-linux-gnu	%{build_unicore32}
+%do_files x86_64-linux-gnu	%{build_x86_64}
+%do_files xtensa-linux-gnu	%{build_xtensa}
diff --git a/binutils-2.19.50.0.1-output-format.sed b/binutils-2.19.50.0.1-output-format.sed
new file mode 100644
index 0000000..fd770cb
--- /dev/null
+++ b/binutils-2.19.50.0.1-output-format.sed
@@ -0,0 +1,38 @@
+# Generate OUTPUT_FORMAT line for .so files from the system linker output.
+# Imported from glibc/Makerules.
+
+/ld.*[ 	]-E[BL]/b f
+/collect.*[ 	]-E[BL]/b f
+/OUTPUT_FORMAT[^)]*$/{N
+s/\n[	 ]*/ /
+}
+t o
+: o
+s/^.*OUTPUT_FORMAT(\([^,]*\), \1, \1).*$/OUTPUT_FORMAT(\1)/
+t q
+s/^.*OUTPUT_FORMAT(\([^,]*\), \([^,]*\), \([^,]*\)).*$/\1,\2,\3/
+t s
+s/^.*OUTPUT_FORMAT(\([^,)]*\).*$)/OUTPUT_FORMAT(\1)/
+t q
+d
+: s
+s/"//g
+G
+s/\n//
+s/^\([^,]*\),\([^,]*\),\([^,]*\),B/OUTPUT_FORMAT(\2)/p
+s/^\([^,]*\),\([^,]*\),\([^,]*\),L/OUTPUT_FORMAT(\3)/p
+s/^\([^,]*\),\([^,]*\),\([^,]*\)/OUTPUT_FORMAT(\1)/p
+/,/s|^|*** BUG in libc/scripts/output-format.sed *** |p
+q
+: q
+s/"//g
+p
+q
+: f
+s/^.*[ 	]-E\([BL]\)[ 	].*$/,\1/
+t h
+s/^.*[ 	]-E\([BL]\)$/,\1/
+t h
+d
+: h
+h
diff --git a/binutils-2.20.51.0.10-copy-osabi.patch b/binutils-2.20.51.0.10-copy-osabi.patch
new file mode 100644
index 0000000..55831ca
--- /dev/null
+++ b/binutils-2.20.51.0.10-copy-osabi.patch
@@ -0,0 +1,17 @@
+--- a/bfd/elf.c	2010-08-10 15:04:55.000000000 +0100
++++ b/bfd/elf.c	2010-08-10 15:05:42.000000000 +0100
+@@ -1074,6 +1074,14 @@
+ 
+   /* Copy object attributes.  */
+   _bfd_elf_copy_obj_attributes (ibfd, obfd);
++
++  /* If the input BFD has the OSABI field set and the
++     output BFD does not, then copy the value.  */
++  if (elf_elfheader (ibfd)->e_ident [EI_OSABI] != ELFOSABI_NONE
++      && elf_elfheader (obfd)->e_ident [EI_OSABI] == ELFOSABI_NONE)
++    elf_elfheader (obfd)->e_ident [EI_OSABI] =
++      elf_elfheader (ibfd)->e_ident [EI_OSABI];
++
+   return TRUE;
+ }
+ 
diff --git a/binutils-2.20.51.0.10-ppc64-pie.patch b/binutils-2.20.51.0.10-ppc64-pie.patch
new file mode 100644
index 0000000..740c071
--- /dev/null
+++ b/binutils-2.20.51.0.10-ppc64-pie.patch
@@ -0,0 +1,12 @@
+--- a/bfd/elf64-ppc.c	2012-09-11 12:13:00.637448573 +0100
++++ b/bfd/elf64-ppc.c	2012-09-11 12:13:17.922449052 +0100
+@@ -13523,6 +13523,9 @@
+ 		{
+ 		  BFD_ASSERT (h->elf.dynindx != -1);
+ 		  outrel.r_info = ELF64_R_INFO (h->elf.dynindx, r_type);
++		  if (h->elf.dynindx == -1
++		      && h->elf.root.type == bfd_link_hash_undefweak)
++		    memset (&outrel, 0, sizeof outrel);
+ 		}
+ 	      else
+ 		{
diff --git a/binutils-2.20.51.0.10-sec-merge-emit.patch b/binutils-2.20.51.0.10-sec-merge-emit.patch
new file mode 100644
index 0000000..d099143
--- /dev/null
+++ b/binutils-2.20.51.0.10-sec-merge-emit.patch
@@ -0,0 +1,20 @@
+--- a/bfd/merge.c	2010-08-20 12:19:33.000000000 +0100
++++ b/bfd/merge.c	2010-08-20 12:18:01.000000000 +0100
+@@ -307,6 +307,9 @@
+       len = -off & (entry->alignment - 1);
+       if (len != 0)
+ 	{
++	  /* We should never have an entry with an alignment
++	     greater than the section's alignment.  */
++	  BFD_ASSERT (len <= (bfd_size_type) (1 << alignment_power));
+ 	  if (bfd_bwrite (pad, len, abfd) != len)
+ 	    goto err;
+ 	  off += len;
+@@ -324,6 +327,7 @@
+   /* Trailing alignment needed?  */
+   off = sec->size - off;
+   if (off != 0
++      && alignment_power
+       && bfd_bwrite (pad, off, abfd) != off)
+     goto err;
+ 
diff --git a/binutils-2.20.51.0.2-ia64-lib64.patch b/binutils-2.20.51.0.2-ia64-lib64.patch
new file mode 100644
index 0000000..c1241ac
--- /dev/null
+++ b/binutils-2.20.51.0.2-ia64-lib64.patch
@@ -0,0 +1,21 @@
+2004-05-14  Jakub Jelinek  <jakub at redhat.com>
+
+	* emulparams/elf64_ia64.sh (LIBPATH_SUFFIX): Use */lib64 paths on
+	ia64-linux if /lib64 tree is present.
+
+--- a/ld/emulparams/elf64_ia64.sh	2008-11-21 16:45:00.000000000 +0000
++++ b/ld/emulparams/elf64_ia64.sh	2008-11-21 16:55:46.000000000 +0000
+@@ -38,3 +38,13 @@ OTHER_READONLY_SECTIONS="${OTHER_READONL
+ SMALL_DATA_CTOR=" "
+ SMALL_DATA_DTOR=" "
+ SHARABLE_SECTIONS=yes
++
++# For Linux modify the default library search path
++# to first include a 64-bit specific directory.
++case "$target" in
++  ia64*-linux*)
++    case "$EMULATION_NAME" in
++      *64*) test -d /lib64 && LIBPATH_SUFFIX=64 ;;
++    esac
++    ;;
++esac
diff --git a/binutils-2.20.51.0.2-libtool-lib64.patch b/binutils-2.20.51.0.2-libtool-lib64.patch
new file mode 100644
index 0000000..142fc7e
--- /dev/null
+++ b/binutils-2.20.51.0.2-libtool-lib64.patch
@@ -0,0 +1,236 @@
+diff -rcp ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure
+--- a/bfd/configure	2010-04-08 14:53:48.000000000 +0100
++++ b/bfd/configure	2010-04-08 14:56:50.000000000 +0100
+@@ -10762,10 +10762,34 @@
+   # before this can be enabled.
+   hardcode_into_libs=yes
+ 
++  # find out which ABI we are using
++  libsuff=
++  case "$host_cpu" in
++  x86_64*|s390*|powerpc*|ppc*|sparc*)
++    echo 'int i;' > conftest.$ac_ext
++    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); }; then
++      case `/usr/bin/file conftest.$ac_objext` in
++      *64-bit*)
++        libsuff=64
++        if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
++          sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
++        fi
++        sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
++        ;;
++      esac
++    fi
++    rm -rf conftest*
++    ;;
++  esac
++
+   # Append ld.so.conf contents to the search path
+   if test -f /etc/ld.so.conf; then
+     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+   fi
+ 
+   # We used to test for /lib/ld.so.1 and disable shared libraries on
+diff -rcp ../binutils-2.20.51.0.7.original/binutils/configure ./binutils/configure
+--- a/binutils/configure	2010-04-08 14:53:45.000000000 +0100
++++ b/binutils/configure	2010-04-08 14:56:21.000000000 +0100
+@@ -10560,10 +10560,34 @@
+   # before this can be enabled.
+   hardcode_into_libs=yes
+ 
++  # find out which ABI we are using
++  libsuff=
++  case "$host_cpu" in
++  x86_64*|s390*|powerpc*|ppc*|sparc*)
++    echo 'int i;' > conftest.$ac_ext
++    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); }; then
++      case `/usr/bin/file conftest.$ac_objext` in
++      *64-bit*)
++        libsuff=64
++        if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
++          sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
++        fi
++        sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
++        ;;
++      esac
++    fi
++    rm -rf conftest*
++    ;;
++  esac
++
+   # Append ld.so.conf contents to the search path
+   if test -f /etc/ld.so.conf; then
+     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+   fi
+ 
+   # We used to test for /lib/ld.so.1 and disable shared libraries on
+diff -rcp ../binutils-2.20.51.0.7.original/gas/configure ./gas/configure
+--- a/gas/configure	2010-04-08 14:53:47.000000000 +0100
++++ b/gas/configure	2010-04-08 14:57:24.000000000 +0100
+@@ -10547,10 +10547,34 @@
+   # before this can be enabled.
+   hardcode_into_libs=yes
+ 
++  # find out which ABI we are using
++  libsuff=
++  case "$host_cpu" in
++  x86_64*|s390*|powerpc*|ppc*|sparc*)
++    echo 'int i;' > conftest.$ac_ext
++    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); }; then
++      case `/usr/bin/file conftest.$ac_objext` in
++      *64-bit*)
++        libsuff=64
++        if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
++          sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
++        fi
++        sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
++        ;;
++      esac
++    fi
++    rm -rf conftest*
++    ;;
++  esac
++
+   # Append ld.so.conf contents to the search path
+   if test -f /etc/ld.so.conf; then
+     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+   fi
+ 
+   # We used to test for /lib/ld.so.1 and disable shared libraries on
+diff -rcp ../binutils-2.20.51.0.7.original/gprof/configure ./gprof/configure
+--- a/gprof/configure	2010-04-08 14:53:45.000000000 +0100
++++ b/gprof/configure	2010-04-08 14:57:50.000000000 +0100
+@@ -10485,10 +10485,34 @@
+   # before this can be enabled.
+   hardcode_into_libs=yes
+ 
++  # find out which ABI we are using
++  libsuff=
++  case "$host_cpu" in
++  x86_64*|s390*|powerpc*|ppc*|sparc*)
++    echo 'int i;' > conftest.$ac_ext
++    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); }; then
++      case `/usr/bin/file conftest.$ac_objext` in
++      *64-bit*)
++        libsuff=64
++        if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
++          sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
++        fi
++        sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
++        ;;
++      esac
++    fi
++    rm -rf conftest*
++    ;;
++  esac
++
+   # Append ld.so.conf contents to the search path
+   if test -f /etc/ld.so.conf; then
+     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+   fi
+ 
+   # We used to test for /lib/ld.so.1 and disable shared libraries on
+diff -rcp ../binutils-2.20.51.0.7.original/ld/configure ./ld/configure
+--- a/ld/configure	2010-04-08 14:53:44.000000000 +0100
++++ b/ld/configure	2010-04-08 14:58:21.000000000 +0100
+@@ -10966,10 +10966,34 @@
+   # before this can be enabled.
+   hardcode_into_libs=yes
+ 
++  # find out which ABI we are using
++  libsuff=
++  case "$host_cpu" in
++  x86_64*|s390*|powerpc*|ppc*|sparc*)
++    echo 'int i;' > conftest.$ac_ext
++    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); }; then
++      case `/usr/bin/file conftest.$ac_objext` in
++      *64-bit*)
++        libsuff=64
++        if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
++          sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
++        fi
++        sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
++        ;;
++      esac
++    fi
++    rm -rf conftest*
++    ;;
++  esac
++
+   # Append ld.so.conf contents to the search path
+   if test -f /etc/ld.so.conf; then
+     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+   fi
+ 
+   # We used to test for /lib/ld.so.1 and disable shared libraries on
+Only in .: .#libtool.m4
+Only in .: #libtool.m4#
+diff -rcp ../binutils-2.20.51.0.7.original/opcodes/configure ./opcodes/configure
+--- a/opcodes/configure	2010-04-08 14:53:45.000000000 +0100
++++ b/opcodes/configure	2010-04-08 14:59:10.000000000 +0100
+@@ -10496,10 +10496,34 @@
+   # before this can be enabled.
+   hardcode_into_libs=yes
+ 
++  # find out which ABI we are using
++  libsuff=
++  case "$host_cpu" in
++  x86_64*|s390*|powerpc*|ppc*|sparc*)
++    echo 'int i;' > conftest.$ac_ext
++    if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++  (eval $ac_compile) 2>&5
++  ac_status=$?
++  echo "$as_me:$LINENO: \$? = $ac_status" >&5
++  (exit $ac_status); }; then
++      case `/usr/bin/file conftest.$ac_objext` in
++      *64-bit*)
++        libsuff=64
++        if test x"$sys_lib_search_path_spec" = x"/lib /usr/lib /usr/local/lib"; then
++          sys_lib_search_path_spec="/lib${libsuff} /usr/lib${libsuff} /usr/local/lib${libsuff}"
++        fi
++        sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff}"
++        ;;
++      esac
++    fi
++    rm -rf conftest*
++    ;;
++  esac
++
+   # Append ld.so.conf contents to the search path
+   if test -f /etc/ld.so.conf; then
+     lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
++    sys_lib_dlsearch_path_spec="/lib${libsuff} /usr/lib${libsuff} $lt_ld_extra"
+   fi
+ 
+   # We used to test for /lib/ld.so.1 and disable shared libraries on
diff --git a/binutils-2.22.52.0.1-export-demangle.h.patch b/binutils-2.22.52.0.1-export-demangle.h.patch
new file mode 100644
index 0000000..cbd7eed
--- /dev/null
+++ b/binutils-2.22.52.0.1-export-demangle.h.patch
@@ -0,0 +1,33 @@
+--- a/bfd/Makefile.am	2012-03-06 14:00:33.229957572 +0000
++++ b/bfd/Makefile.am	2012-04-27 16:46:05.410974817 +0100
+@@ -18,7 +18,7 @@
+ bfdlibdir = @bfdlibdir@
+ bfdincludedir = @bfdincludedir@
+ bfdlib_LTLIBRARIES = libbfd.la
+-bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h
++bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h
+ else !INSTALL_LIBBFD
+ # Empty these so that the respective installation directories will not be created.
+ bfdlibdir =
+--- a/bfd/Makefile.in	2012-03-06 14:00:32.952957600 +0000
++++ b/bfd/Makefile.in	2012-04-27 16:46:19.718975214 +0100
+@@ -138,7 +138,8 @@
+ 	installcheck-recursive installdirs-recursive pdf-recursive \
+ 	ps-recursive uninstall-recursive
+ am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \
+-	$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h
++	$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h \
++	$(INCDIR)/demangle.h
+ HEADERS = $(bfdinclude_HEADERS)
+ RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+   distclean-recursive maintainer-clean-recursive
+@@ -331,7 +332,8 @@
+ @INSTALL_LIBBFD_FALSE at bfdinclude_HEADERS = $(am__append_2)
+ @INSTALL_LIBBFD_TRUE at bfdinclude_HEADERS = $(BFD_H) \
+ @INSTALL_LIBBFD_TRUE@	$(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
+- at INSTALL_LIBBFD_TRUE@	$(INCDIR)/bfdlink.h $(am__append_2)
++ at INSTALL_LIBBFD_TRUE@	$(INCDIR)/bfdlink.h $(INCDIR)/demangle.h \
++ at INSTALL_LIBBFD_TRUE@	$(am__append_2)
+ @INSTALL_LIBBFD_FALSE at rpath_bfdlibdir = @bfdlibdir@
+ @INSTALL_LIBBFD_FALSE at noinst_LTLIBRARIES = libbfd.la
+ AM_CFLAGS = $(WARN_CFLAGS)
diff --git a/binutils-2.22.52.0.1-relro-on-by-default.patch b/binutils-2.22.52.0.1-relro-on-by-default.patch
new file mode 100644
index 0000000..177b48a
--- /dev/null
+++ b/binutils-2.22.52.0.1-relro-on-by-default.patch
@@ -0,0 +1,58 @@
+diff -upr ../binutils-2.22.52.0.1.orig/ld/testsuite/config/default.exp ld/testsuite/config/default.exp
+--- a/ld/testsuite/config/default.exp	2012-03-06 14:00:31.141957656 +0000
++++ b/ld/testsuite/config/default.exp	2012-03-06 14:09:33.492940503 +0000
+@@ -23,7 +23,7 @@
+ #
+ 
+ if ![info exists ld] then {
+-    set ld [findfile $base_dir/ld-new $base_dir/ld-new [transform ld]]
++    set ld "[findfile $base_dir/ld-new $base_dir/ld-new [transform ld]] -znorelro"
+ }
+ 
+ if ![info exists as] then {
+@@ -60,7 +60,7 @@ if {![file isdirectory tmpdir/ld]} then
+     catch "exec ln -s ld tmpdir/ld/collect-ld" status
+     catch "exec ln -s ../../../gas/as-new tmpdir/ld/as" status
+ }
+-set gcc_B_opt "-B[pwd]/tmpdir/ld/"
++set gcc_B_opt "-B[pwd]/tmpdir/ld/ -Wl,-z,norelro"
+ 
+ # load the linker path
+ set ld_L_opt ""
+@@ -279,7 +279,7 @@
+ }
+ 
+ if ![info exists LD] then {
+-    set LD [findfile $base_dir/ld-new ./ld-new [transform ld]]
++    set LD "[findfile $base_dir/ld-new ./ld-new [transform ld]] -znorelro"
+ }
+ 
+ if ![info exists LDFLAGS] then {
+diff -cpr ../binutils-2.22.52.0.1.orig/ld/testsuite/ld-bootstrap/bootstrap.exp ld/testsuite/ld-bootstrap/bootstrap.exp
+--- a/ld/testsuite/ld-bootstrap/bootstrap.exp	2012-03-06 14:00:30.503957676 +0000
++++ b/ld/testsuite/ld-bootstrap/bootstrap.exp	2012-03-06 15:03:33.949837926 +0000
+@@ -71,7 +71,13 @@
+ 
+     # This test can only be run if we have the ld build directory,
+     # since we need the object files.
+-    if {$ld != "$objdir/ld-new"} {
++    set ldexe $ld
++    set ldparm [string first " " $ld]
++    if { $ldparm > 0 } then {
++	set ldparm [expr $ldparm - 1]
++	set ldexe [string range $ld 0 $ldparm]
++    }
++    if {$ldexe != "$objdir/ld-new"} {
+ 	untested $testname
+ 	continue
+     }
+--- a/ld/emultempl/elf32.em	2013-04-24 11:06:47.777176887 +0100
++++ b/ld/emultempl/elf32.em	2013-04-24 11:07:22.405177847 +0100
+@@ -105,6 +105,7 @@
+   input_flags.dynamic = ${DYNAMIC_LINK-TRUE};
+   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
+   config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`;
++  link_info.relro = TRUE;
+ }
+ 
+ EOF
diff --git a/binutils-2.22.52.0.4-no-config-h-check.patch b/binutils-2.22.52.0.4-no-config-h-check.patch
new file mode 100644
index 0000000..c89195a
--- /dev/null
+++ b/binutils-2.22.52.0.4-no-config-h-check.patch
@@ -0,0 +1,28 @@
+--- a/bfd/bfd-in.h	2012-08-02 10:56:34.561769686 +0100
++++ b/bfd/bfd-in.h	2012-08-02 11:13:27.134797755 +0100
+@@ -25,11 +25,6 @@
+ #ifndef __BFD_H_SEEN__
+ #define __BFD_H_SEEN__
+ 
+-/* PR 14072: Ensure that config.h is included first.  */
+-#if !defined PACKAGE && !defined PACKAGE_VERSION
+-#error config.h must be included before this header
+-#endif
+-
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+--- a/bfd/bfd-in2.h	2012-08-02 10:56:34.349769680 +0100
++++ b/bfd/bfd-in2.h	2012-08-02 11:13:40.015798113 +0100
+@@ -32,11 +32,6 @@
+ #ifndef __BFD_H_SEEN__
+ #define __BFD_H_SEEN__
+ 
+-/* PR 14072: Ensure that config.h is included first.  */
+-#if !defined PACKAGE && !defined PACKAGE_VERSION
+-#error config.h must be included before this header
+-#endif
+-
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
diff --git a/binutils-2.23.2-aarch64-em.patch b/binutils-2.23.2-aarch64-em.patch
new file mode 100644
index 0000000..73043da
--- /dev/null
+++ b/binutils-2.23.2-aarch64-em.patch
@@ -0,0 +1,26 @@
+--- a/ld/emultempl/aarch64elf.em	2013-06-05 09:46:17.499278813 +0100
++++ b/ld/emultempl/aarch64elf.em	2013-06-05 09:54:36.981292659 +0100
+@@ -264,7 +264,7 @@
+ }
+ 
+ static void
+-gld${EMULATION_NAME}_finish (void)
++gld${EMULATION_NAME}_local_finish (void)
+ {
+   if (! link_info.relocatable)
+     {
+@@ -276,7 +276,7 @@
+ 	}
+     }
+ 
+-  finish_default ();
++  gld${EMULATION_NAME}_finish ();
+ }
+ 
+ /* This is a convenient point to tell BFD about target specific flags.
+@@ -413,4 +413,4 @@
+ LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
+ 
+ # Call the extra arm-elf function
+-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
++LDEMUL_FINISH=gld${EMULATION_NAME}_local_finish
diff --git a/binutils-2.23.52.0.1-addr2line-dynsymtab.patch b/binutils-2.23.52.0.1-addr2line-dynsymtab.patch
new file mode 100644
index 0000000..944f4fd
--- /dev/null
+++ b/binutils-2.23.52.0.1-addr2line-dynsymtab.patch
@@ -0,0 +1,38 @@
+--- a/bfd/opncls.c	2013-03-14 11:25:30.338306122 +0000
++++ b/bfd/opncls.c	2013-03-14 12:20:21.686397360 +0000
+@@ -1297,6 +1297,8 @@
+       bfd_malloc (strlen (debug_file_directory) + 1
+                   + (canon_dirlen > dirlen ? canon_dirlen : dirlen)
+                   + strlen (".debug/")
++#define FEDORA_LIB_DEBUG_DIR "/usr/lib/debug/"
++		  + strlen (FEDORA_LIB_DEBUG_DIR) + strlen ("usr/")
+                   + strlen (base)
+                   + 1);
+   if (debugfile == NULL)
+@@ -1332,6 +1334,26 @@
+   if (check_func (debugfile, crc32))
+     goto found;
+ 
++  /* Then try in the global debug dir for Fedora libraries.  */
++  sprintf (debugfile, "%s%s%s", FEDORA_LIB_DEBUG_DIR, dir, base);
++  if (separate_debug_file_exists (debugfile, crc32))
++    {
++      free (base);
++      free (dir);
++      free (canon_dir);
++      return debugfile;
++    }
++
++  /* Then try in the usr subdirectory of the global debug dir for Fedora libraries.  */
++  sprintf (debugfile, "%s/usr%s%s", FEDORA_LIB_DEBUG_DIR, dir, base);
++  if (separate_debug_file_exists (debugfile, crc32))
++    {
++      free (base);
++      free (dir);
++      free (canon_dir);
++      return debugfile;
++    }
++  
+   /* Then try in the global debugfile directory.  */
+   strcpy (debugfile, debug_file_directory);
+   dirlen = strlen (debug_file_directory) - 1;
diff --git a/binutils-2.24-ldforcele.patch b/binutils-2.24-ldforcele.patch
new file mode 100644
index 0000000..194cf1e
--- /dev/null
+++ b/binutils-2.24-ldforcele.patch
@@ -0,0 +1,54 @@
+Common subdirectories: ../binutils-2.24.orig/ld/emulparams and ld/emulparams
+Common subdirectories: ../binutils-2.24.orig/ld/emultempl and ld/emultempl
+diff -up ../binutils-2.24.orig/ld/ldlang.c ld/ldlang.c
+--- a/ld/ldlang.c	2014-05-09 10:35:04.589504928 +0100
++++ b/ld/ldlang.c	2014-05-09 10:35:55.515661478 +0100
+@@ -7096,6 +7096,18 @@
+ 	       && little != NULL)
+ 	format = little;
+ 
++      if (getenv ("LD_FORCE_LE") != NULL)
++	{
++	  if (strcmp (format, "elf64-powerpc") == 0)
++	    format = "elf64-powerpcle";
++	  else if (strcmp (format, "elf32-powerpc") == 0)
++	    format = "elf32-powerpcle";
++	  else if (strcmp (format, "elf64-big") == 0)
++	    format = "elf64-little";
++	  else if (strcmp (format, "elf32-big") == 0)
++	    format = "elf32-little";
++	}
++
+       output_target = format;
+     }
+ }
+Only in ld: ldlang.c.orig
+diff -up ../binutils-2.24.orig/ld/ldmain.c ld/ldmain.c
+--- a/ld/ldmain.c	2014-05-09 10:35:04.593504941 +0100
++++ b/ld/ldmain.c	2014-05-09 10:35:55.515661478 +0100
+@@ -603,6 +603,18 @@
+ 	}
+     }
+ 
++  if ((strncmp (emulation, "elf64ppc", 8) == 0
++       || strncmp (emulation, "elf32ppc", 8) == 0)
++      && getenv ("LD_FORCE_LE") != NULL)
++    {
++      size_t len = strlen (emulation);
++      char *le = xmalloc (len + 2);
++      memcpy (le, emulation, 5);
++      le[5] = 'l';
++      memcpy (le + 6, emulation + 5, len - 4);
++      emulation = le;
++    }
++
+   return emulation;
+ }
+ 
+Only in ld: ldmain.c.orig
+Common subdirectories: ../binutils-2.24.orig/ld/ldscripts and ld/ldscripts
+Common subdirectories: ../binutils-2.24.orig/ld/.libs and ld/.libs
+Common subdirectories: ../binutils-2.24.orig/ld/po and ld/po
+Common subdirectories: ../binutils-2.24.orig/ld/scripttempl and ld/scripttempl
+Common subdirectories: ../binutils-2.24.orig/ld/testsuite and ld/testsuite
+Common subdirectories: ../binutils-2.24.orig/ld/tmpdir and ld/tmpdir
diff --git a/binutils-2.25-kernel-ld-r.patch b/binutils-2.25-kernel-ld-r.patch
new file mode 100644
index 0000000..8fc6c27
--- /dev/null
+++ b/binutils-2.25-kernel-ld-r.patch
@@ -0,0 +1,2362 @@
+diff -rup binutils-2.25.orig/bfd/bfd.c binutils-2.25/bfd/bfd.c
+--- binutils-2.25.orig/bfd/bfd.c	2014-12-24 10:46:27.893435026 +0000
++++ binutils-2.25/bfd/bfd.c	2014-12-24 10:48:25.666096395 +0000
+@@ -44,6 +44,14 @@ CODE_FRAGMENT
+ .    both_direction = 3
+ .  };
+ .
++.enum bfd_lto_object_type
++.  {
++.    lto_non_object,
++.    lto_non_ir_object,
++.    lto_ir_object,
++.    lto_mixed_object
++.  };
++.
+ .struct bfd
+ .{
+ .  {* The filename the application opened the BFD with.  *}
+@@ -221,6 +229,9 @@ CODE_FRAGMENT
+ .  {* The last section on the section list.  *}
+ .  struct bfd_section *section_last;
+ .
++.  {* The object-only section on the section list.  *}
++.  struct bfd_section *object_only_section;
++.
+ .  {* The number of sections.  *}
+ .  unsigned int section_count;
+ .
+@@ -310,6 +321,9 @@ CODE_FRAGMENT
+ .     struct objalloc *, but we use void * to avoid requiring the inclusion
+ .     of objalloc.h.  *}
+ .  void *memory;
++.
++.  {* LTO object type.  *}
++.  unsigned int lto_type : 2;
+ .};
+ .
+ .{* See note beside bfd_set_section_userdata.  *}
+@@ -1923,3 +1937,36 @@ bfd_demangle (bfd *abfd, const char *nam
+ 
+   return res;
+ }
++
++/*
++FUNCTION
++	bfd_group_signature
++
++SYNOPSIS
++	asymbol *bfd_group_signature (asection *group, asymbol **isympp);
++
++DESCRIPTION
++	Return a pointer to the symbol used as a signature for GROUP.
++*/
++
++asymbol *
++bfd_group_signature (asection *group, asymbol **isympp)
++{
++  bfd *abfd = group->owner;
++  Elf_Internal_Shdr *ghdr;
++
++  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
++    return NULL;
++
++  ghdr = &elf_section_data (group)->this_hdr;
++  if (ghdr->sh_link < elf_numsections (abfd))
++    {
++      const struct elf_backend_data *bed = get_elf_backend_data (abfd);
++      Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link];
++
++      if (symhdr->sh_type == SHT_SYMTAB
++	  && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
++	return isympp[ghdr->sh_info - 1];
++    }
++  return NULL;
++}
+Only in binutils-2.25/bfd: bfd.c.orig
+Only in binutils-2.25/bfd: bfd.c.rej
+diff -rup binutils-2.25.orig/bfd/bfd-in2.h binutils-2.25/bfd/bfd-in2.h
+--- binutils-2.25.orig/bfd/bfd-in2.h	2014-12-24 10:46:27.890435009 +0000
++++ binutils-2.25/bfd/bfd-in2.h	2014-12-24 10:54:21.498104097 +0000
+@@ -1078,6 +1078,9 @@ struct bfd_section *bfd_create_gnu_debug
+ bfd_boolean bfd_fill_in_gnu_debuglink_section
+    (bfd *abfd, struct bfd_section *sect, const char *filename);
+ 
++const char *bfd_extract_object_only_section
++   (bfd *abfd);
++
+ /* Extracted from libbfd.c.  */
+ 
+ /* Byte swapping macros for user section data.  */
+@@ -1650,6 +1653,9 @@ extern asection _bfd_std_section[4];
+   || ((SEC) == bfd_com_section_ptr)            \
+   || ((SEC) == bfd_ind_section_ptr))
+ 
++/* GNU object-only section name.  */
++#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
++
+ /* Macros to handle insertion and deletion of a bfd's sections.  These
+    only handle the list pointers, ie. do not adjust section_count,
+    target_index etc.  */
+@@ -6269,6 +6275,14 @@ enum bfd_direction
+     both_direction = 3
+   };
+ 
++enum bfd_lto_object_type
++  {
++    lto_non_object,
++    lto_non_ir_object,
++    lto_ir_object,
++    lto_mixed_object
++  };
++
+ struct bfd
+ {
+   /* The filename the application opened the BFD with.  */
+@@ -6446,6 +6460,9 @@ struct bfd
+   /* The last section on the section list.  */
+   struct bfd_section *section_last;
+ 
++  /* The object-only section on the section list.  */
++  struct bfd_section *object_only_section;
++
+   /* The number of sections.  */
+   unsigned int section_count;
+ 
+@@ -6535,6 +6552,9 @@ struct bfd
+      struct objalloc *, but we use void * to avoid requiring the inclusion
+      of objalloc.h.  */
+   void *memory;
++
++  /* LTO object type.  */
++  unsigned int lto_type : 2;
+ };
+ 
+ /* See note beside bfd_set_section_userdata.  */
+@@ -6747,6 +6767,8 @@ void bfd_emul_set_commonpagesize (const
+ 
+ char *bfd_demangle (bfd *, const char *, int);
+ 
++asymbol *bfd_group_signature (asection *group, asymbol **isympp);
++
+ /* Extracted from archive.c.  */
+ symindex bfd_get_next_mapent
+    (bfd *abfd, symindex previous, carsym **sym);
+Only in binutils-2.25/bfd: bfd-in2.h.orig
+Only in binutils-2.25/bfd: bfd-in2.h.rej
+diff -rup binutils-2.25.orig/bfd/elf.c binutils-2.25/bfd/elf.c
+--- binutils-2.25.orig/bfd/elf.c	2014-12-24 10:46:27.884434975 +0000
++++ binutils-2.25/bfd/elf.c	2014-12-24 10:47:06.954654379 +0000
+@@ -2208,6 +2208,7 @@ static const struct bfd_elf_special_sect
+   { STRING_COMMA_LEN (".gnu.linkonce.b"), -2, SHT_NOBITS,      SHF_ALLOC + SHF_WRITE },
+   { STRING_COMMA_LEN (".gnu.lto_"),       -1, SHT_PROGBITS,    SHF_EXCLUDE },
+   { STRING_COMMA_LEN (".got"),             0, SHT_PROGBITS,    SHF_ALLOC + SHF_WRITE },
++  { STRING_COMMA_LEN (".gnu_object_only"), 0, SHT_GNU_OBJECT_ONLY, SHF_EXCLUDE },
+   { STRING_COMMA_LEN (".gnu.version"),     0, SHT_GNU_versym,  0 },
+   { STRING_COMMA_LEN (".gnu.version_d"),   0, SHT_GNU_verdef,  0 },
+   { STRING_COMMA_LEN (".gnu.version_r"),   0, SHT_GNU_verneed, 0 },
+diff -rup binutils-2.25.orig/bfd/format.c binutils-2.25/bfd/format.c
+--- binutils-2.25.orig/bfd/format.c	2014-12-24 10:46:27.897435048 +0000
++++ binutils-2.25/bfd/format.c	2014-12-24 10:47:06.961654419 +0000
+@@ -94,6 +94,33 @@ bfd_check_format (bfd *abfd, bfd_format
+   return bfd_check_format_matches (abfd, format, NULL);
+ }
+ 
++/* Set lto_type in ABFD.  */
++
++static void
++bfd_set_lto_type (bfd *abfd)
++{
++  if (abfd->format == bfd_object
++      && abfd->lto_type == lto_non_object
++      && (abfd->flags & (DYNAMIC | EXEC_P)) == 0)
++    {
++      asection *sec;
++      enum bfd_lto_object_type type = lto_non_ir_object;
++      for (sec = abfd->sections; sec != NULL; sec = sec->next)
++	{
++	  if (strcmp (sec->name, GNU_OBJECT_ONLY_SECTION_NAME) == 0)
++	    {
++	      type = lto_mixed_object;
++	      abfd->object_only_section = sec;
++	      break;
++	    }
++	  else if (type != lto_ir_object
++		   && strncmp (sec->name, ".gnu.lto_", 9) == 0)
++	    type = lto_ir_object;
++	}
++      abfd->lto_type = type;
++    }
++}
++
+ struct bfd_preserve
+ {
+   void *marker;
+@@ -221,7 +248,10 @@ bfd_check_format_matches (bfd *abfd, bfd
+     }
+ 
+   if (abfd->format != bfd_unknown)
+-    return abfd->format == format;
++    {
++      bfd_set_lto_type (abfd);
++      return abfd->format == format;
++    }
+ 
+   if (matching != NULL || *bfd_associated_vector != NULL)
+     {
+@@ -449,6 +479,9 @@ bfd_check_format_matches (bfd *abfd, bfd
+       if (matching_vector)
+ 	free (matching_vector);
+ 
++      bfd_set_lto_type (abfd);
++
++
+       /* File position has moved, BTW.  */
+       return TRUE;
+     }
+Only in binutils-2.25/bfd: format.c.orig
+diff -rup binutils-2.25.orig/bfd/opncls.c binutils-2.25/bfd/opncls.c
+--- binutils-2.25.orig/bfd/opncls.c	2014-12-24 10:46:27.903435082 +0000
++++ binutils-2.25/bfd/opncls.c	2014-12-24 10:47:06.962654424 +0000
+@@ -1711,3 +1711,69 @@ bfd_fill_in_gnu_debuglink_section (bfd *
+ 
+   return TRUE;
+ }
++
++/*
++FUNCTION
++	bfd_extract_object_only_section
++
++SYNOPSIS
++	const char *bfd_extract_object_only_section
++	  (bfd *abfd);
++
++DESCRIPTION
++
++	Takes a @var{ABFD} and extract the .gnu_object_only section into
++	a temporary file.
++
++RETURNS
++	The name of the temporary file is returned if all is ok.
++	Otherwise <<NULL>> is returned and bfd_error is set.
++*/
++
++const char *
++bfd_extract_object_only_section (bfd *abfd)
++{
++  asection *sec = abfd->object_only_section;
++  const char *name;
++  FILE *file;
++  bfd_byte *memhunk = NULL;
++  size_t off, size;
++  bfd_error_type err;
++
++  /* Get a temporary object-only file.  */
++  name = make_temp_file (".obj-only.o");
++
++  /* Open the object-only file.  */
++  file = real_fopen (name, FOPEN_WB);
++  if (!bfd_get_full_section_contents (abfd, sec, &memhunk))
++    {
++      err = bfd_get_error ();
++
++loser:
++      free (memhunk);
++      fclose (file);
++      unlink (name);
++      bfd_set_error (err);
++      return NULL;
++    }
++
++  off = 0;
++  size = sec->size;
++  while (off != size)
++    {
++      size_t written, nwrite = size - off;
++
++      written = fwrite (memhunk + off, 1, nwrite, file);
++      if (written < nwrite && ferror (file))
++	{
++	  err = bfd_error_system_call;
++	  goto loser;
++	}
++
++      off += written;
++    }
++
++  free (memhunk);
++  fclose (file);
++  return name;
++}
+Only in binutils-2.25/bfd: opncls.c.orig
+diff -rup binutils-2.25.orig/bfd/plugin.c binutils-2.25/bfd/plugin.c
+--- binutils-2.25.orig/bfd/plugin.c	2014-12-24 10:46:27.898435054 +0000
++++ binutils-2.25/bfd/plugin.c	2014-12-24 10:47:06.963654430 +0000
+@@ -129,6 +129,139 @@ register_claim_file (ld_plugin_claim_fil
+   return LDPS_OK;
+ }
+ 
++static asection bfd_plugin_fake_text_section
++  = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0);
++static asection bfd_plugin_fake_common_section
++  = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0,
++		      NULL, 0);
++
++/* Get symbols from object only section.  */
++
++static void
++bfd_plugin_get_symbols_in_object_only (bfd *abfd)
++{
++  struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
++  const char *object_only_file;
++  bfd *nbfd;
++  long storage;
++  long object_only_nsyms, added_nsyms, i;
++  asymbol **object_only_syms, **added_syms;
++
++  plugin_data->object_only_syms = NULL;
++  plugin_data->object_only_nsyms = 0;
++
++  if (abfd->sections == NULL && abfd->my_archive == NULL)
++    {
++      nbfd = bfd_openr (abfd->filename, NULL);
++      if (nbfd == NULL || !bfd_check_format (nbfd, bfd_object))
++	{
++	  (*_bfd_error_handler)
++	    (_("%s: failed to open to extract object only section: %s"),
++	     abfd->filename, bfd_errmsg (bfd_get_error ()));
++	  bfd_close (nbfd);
++	  return;
++	}
++    }
++  else
++    {
++      if (!bfd_check_format (abfd, bfd_object))
++	{
++	  (*_bfd_error_handler)
++	    (_("%B: invalid file to extract object only section: %s"),
++	     abfd, bfd_errmsg (bfd_get_error ()));
++	  return;
++	}
++      nbfd = abfd;
++    }
++
++  if (nbfd->lto_type == lto_mixed_object
++      && (nbfd->flags & HAS_SYMS) != 0)
++    {
++      object_only_file = bfd_extract_object_only_section (nbfd);
++      if (object_only_file == NULL)
++	(*_bfd_error_handler)
++	  (_("%B: failed to extract object only section: %s"),
++	   abfd, bfd_errmsg (bfd_get_error ()));
++    }
++  else
++    object_only_file = NULL;
++
++  /* Close the new bfd we just opened.  */
++  if (nbfd != abfd)
++    bfd_close (nbfd);
++
++  /* Return if there is no object only section or there is no
++     symbol in object only section.  */
++  if (!object_only_file)
++    return;
++
++  /* Open the file containing object only section.  */
++  nbfd = bfd_openr (object_only_file, NULL);
++  if (!bfd_check_format (nbfd, bfd_object))
++    {
++      (*_bfd_error_handler)
++	(_("%B: failed to open object only section: %s"),
++	 abfd, bfd_errmsg (bfd_get_error ()));
++      goto quit;
++    }
++
++  storage = bfd_get_symtab_upper_bound (nbfd);
++  if (storage <= 0)
++    {
++      if (storage < 0)
++	(*_bfd_error_handler)
++	  (_("%B: failed to get symbol table in object only section: %s"),
++	   abfd, bfd_errmsg (bfd_get_error ()));
++
++      goto quit;
++    }
++
++  object_only_syms = (asymbol **) bfd_malloc (storage);
++  object_only_nsyms = bfd_canonicalize_symtab (nbfd, object_only_syms);
++
++  /* FIXME: We waste some spaces if not all symbols are copied.  */
++  added_syms = (asymbol **) bfd_alloc (abfd, storage);
++  added_nsyms = 0;
++
++  /* Copy only global symbols from object only section.  */
++  for (i = 0; i < object_only_nsyms; i++)
++    {
++      asection *sec = object_only_syms[i]->section;
++      flagword flags = object_only_syms[i]->flags;
++      asymbol *s;
++
++      if (bfd_is_com_section (sec))
++	sec = &bfd_plugin_fake_common_section;
++      else if (bfd_is_und_section (sec))
++	;
++      else if ((flags & (BSF_GLOBAL | BSF_WEAK | BSF_GNU_UNIQUE)) != 0)
++	sec = &bfd_plugin_fake_text_section;
++      else
++	continue;
++
++      s = bfd_alloc (abfd, sizeof (asymbol)); 
++      BFD_ASSERT (s);
++      added_syms[added_nsyms++] = s;
++
++      s->section = sec;
++      s->the_bfd = abfd;
++      s->name = xstrdup (object_only_syms[i]->name);
++      s->value = 0;
++      s->flags = flags;
++      s->udata.p = NULL;
++    }
++
++  plugin_data->object_only_syms = added_syms;
++  plugin_data->object_only_nsyms = added_nsyms;
++
++  free (object_only_syms);
++
++quit:
++  /* Close and remove the object only section file.  */
++  bfd_close (nbfd);
++  unlink (object_only_file);
++}
++
+ static enum ld_plugin_status
+ add_symbols (void * handle,
+ 	     int nsyms,
+@@ -141,7 +274,9 @@ add_symbols (void * handle,
+   plugin_data->nsyms = nsyms;
+   plugin_data->syms = syms;
+ 
+-  if (nsyms != 0)
++  bfd_plugin_get_symbols_in_object_only (abfd);
++
++  if ((nsyms + plugin_data->object_only_nsyms) != 0)
+     abfd->flags |= HAS_SYMS;
+ 
+   abfd->tdata.plugin_data = plugin_data;
+@@ -390,7 +525,8 @@ static long
+ bfd_plugin_get_symtab_upper_bound (bfd *abfd)
+ {
+   struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+-  long nsyms = plugin_data->nsyms;
++  /* Add symbols from object only section.  */
++  long nsyms = plugin_data->nsyms + plugin_data->object_only_nsyms;
+ 
+   BFD_ASSERT (nsyms >= 0);
+ 
+@@ -424,12 +560,7 @@ bfd_plugin_canonicalize_symtab (bfd *abf
+   struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+   long nsyms = plugin_data->nsyms;
+   const struct ld_plugin_symbol *syms = plugin_data->syms;
+-  static asection fake_section;
+-  static asection fake_common_section;
+-  int i;
+-
+-  fake_section.name = ".text";
+-  fake_common_section.flags = SEC_IS_COMMON;
++  int i, j;
+ 
+   for (i = 0; i < nsyms; i++)
+     {
+@@ -442,10 +573,11 @@ bfd_plugin_canonicalize_symtab (bfd *abf
+       s->name = syms[i].name;
+       s->value = 0;
+       s->flags = convert_flags (&syms[i]);
++      s->udata.p = NULL;
+       switch (syms[i].def)
+ 	{
+ 	case LDPK_COMMON:
+-	  s->section = &fake_common_section;
++	  s->section = &bfd_plugin_fake_common_section;
+ 	  break;
+ 	case LDPK_UNDEF:
+ 	case LDPK_WEAKUNDEF:
+@@ -453,15 +585,18 @@ bfd_plugin_canonicalize_symtab (bfd *abf
+ 	  break;
+ 	case LDPK_DEF:
+ 	case LDPK_WEAKDEF:
+-	  s->section = &fake_section;
++	  s->section = &bfd_plugin_fake_text_section;
+ 	  break;
+ 	default:
+ 	  BFD_ASSERT (0);
+ 	}
+-
+-      s->udata.p = (void *) &syms[i];
+     }
+ 
++  /* Copy symbols from object only section.  */
++  nsyms += plugin_data->object_only_nsyms;
++  for (j = 0; j < plugin_data->object_only_nsyms; j++, i++)
++    alocation[i] = plugin_data->object_only_syms[j];
++
+   return nsyms;
+ }
+ 
+Only in binutils-2.25/bfd: plugin.c.orig
+diff -rup binutils-2.25.orig/bfd/plugin.h binutils-2.25/bfd/plugin.h
+--- binutils-2.25.orig/bfd/plugin.h	2014-12-24 10:46:27.894435031 +0000
++++ binutils-2.25/bfd/plugin.h	2014-12-24 10:47:06.964654436 +0000
+@@ -30,6 +30,8 @@ typedef struct plugin_data_struct
+ {
+   int nsyms;
+   const struct ld_plugin_symbol *syms;
++  int object_only_nsyms;
++  asymbol **object_only_syms;
+ }
+ plugin_data_struct;
+ 
+diff -rup binutils-2.25.orig/bfd/section.c binutils-2.25/bfd/section.c
+--- binutils-2.25.orig/bfd/section.c	2014-12-24 10:46:27.882434964 +0000
++++ binutils-2.25/bfd/section.c	2014-12-24 10:47:07.163655553 +0000
+@@ -595,6 +595,9 @@ CODE_FRAGMENT
+ .  || ((SEC) == bfd_com_section_ptr)		\
+ .  || ((SEC) == bfd_ind_section_ptr))
+ .
++.{* GNU object-only section name.  *}
++.#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only"
++.
+ .{* Macros to handle insertion and deletion of a bfd's sections.  These
+ .   only handle the list pointers, ie. do not adjust section_count,
+ .   target_index etc.  *}
+Only in binutils-2.25/bfd: section.c.orig
+diff -rup binutils-2.25.orig/binutils/objcopy.c binutils-2.25/binutils/objcopy.c
+--- binutils-2.25.orig/binutils/objcopy.c	2014-12-24 10:46:27.917435160 +0000
++++ binutils-2.25/binutils/objcopy.c	2014-12-24 10:47:07.165655564 +0000
+@@ -1009,30 +1009,6 @@ is_specified_symbol (const char *name, h
+   return htab_find (htab, name) != NULL;
+ }
+ 
+-/* Return a pointer to the symbol used as a signature for GROUP.  */
+-
+-static asymbol *
+-group_signature (asection *group)
+-{
+-  bfd *abfd = group->owner;
+-  Elf_Internal_Shdr *ghdr;
+-
+-  if (bfd_get_flavour (abfd) != bfd_target_elf_flavour)
+-    return NULL;
+-
+-  ghdr = &elf_section_data (group)->this_hdr;
+-  if (ghdr->sh_link < elf_numsections (abfd))
+-    {
+-      const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+-      Elf_Internal_Shdr *symhdr = elf_elfsections (abfd) [ghdr->sh_link];
+-
+-      if (symhdr->sh_type == SHT_SYMTAB
+-	  && ghdr->sh_info < symhdr->sh_size / bed->s->sizeof_sym)
+-	return isympp[ghdr->sh_info - 1];
+-    }
+-  return NULL;
+-}
+-
+ /* Return TRUE if the section is a DWO section.  */
+ 
+ static bfd_boolean
+@@ -1114,7 +1090,7 @@ is_strip_section (bfd *abfd ATTRIBUTE_UN
+       /* PR binutils/3181
+ 	 If we are going to strip the group signature symbol, then
+ 	 strip the group section too.  */
+-      gsym = group_signature (sec);
++      gsym = bfd_group_signature (sec, isympp);
+       if (gsym != NULL)
+ 	gname = gsym->name;
+       else
+@@ -2823,7 +2799,7 @@ setup_section (bfd *ibfd, sec_ptr isecti
+ 
+   if ((isection->flags & SEC_GROUP) != 0)
+     {
+-      asymbol *gsym = group_signature (isection);
++      asymbol *gsym = bfd_group_signature (isection, isympp);
+ 
+       if (gsym != NULL)
+ 	{
+Only in binutils-2.25/binutils: objcopy.c.orig
+diff -rup binutils-2.25.orig/binutils/readelf.c binutils-2.25/binutils/readelf.c
+--- binutils-2.25.orig/binutils/readelf.c	2014-12-24 10:46:27.916435155 +0000
++++ binutils-2.25/binutils/readelf.c	2014-12-24 10:47:07.170655592 +0000
+@@ -3624,6 +3624,7 @@ get_section_type_name (unsigned int sh_t
+     case 0x7ffffffd:		return "AUXILIARY";
+     case 0x7fffffff:		return "FILTER";
+     case SHT_GNU_LIBLIST:	return "GNU_LIBLIST";
++    case SHT_GNU_OBJECT_ONLY:	return "GNU_OBJECT_ONLY";
+ 
+     default:
+       if ((sh_type >= SHT_LOPROC) && (sh_type <= SHT_HIPROC))
+Only in binutils-2.25/binutils: readelf.c.orig
+diff -rup binutils-2.25.orig/include/bfdlink.h binutils-2.25/include/bfdlink.h
+--- binutils-2.25.orig/include/bfdlink.h	2014-12-24 10:46:27.704433964 +0000
++++ binutils-2.25/include/bfdlink.h	2014-12-24 10:47:07.170655592 +0000
+@@ -389,6 +389,12 @@ struct bfd_link_info
+   /* TRUE if ok to have multiple definition.  */
+   unsigned int allow_multiple_definition: 1;
+ 
++  /* TRUE if .gnu_object_only section should be created.  */
++  unsigned int emit_gnu_object_only: 1;
++
++  /* TRUE if .gnu_object_only section is being created.  */
++  unsigned int emitting_gnu_object_only: 1;
++
+   /* TRUE if ok to have version with no definition.  */
+   unsigned int allow_undefined_version: 1;
+ 
+Only in binutils-2.25/include: bfdlink.h.orig
+diff -rup binutils-2.25.orig/include/elf/common.h binutils-2.25/include/elf/common.h
+--- binutils-2.25.orig/include/elf/common.h	2014-12-24 10:46:27.698433930 +0000
++++ binutils-2.25/include/elf/common.h	2014-12-24 10:47:07.171655598 +0000
+@@ -472,6 +472,7 @@
+ #define SHT_GNU_ATTRIBUTES 0x6ffffff5	/* Object attributes */
+ #define SHT_GNU_HASH	0x6ffffff6	/* GNU style symbol hash table */
+ #define SHT_GNU_LIBLIST	0x6ffffff7	/* List of prelink dependencies */
++#define SHT_GNU_OBJECT_ONLY 0x6ffffff8	/* Object only */
+ 
+ /* The next three section types are defined by Solaris, and are named
+    SHT_SUNW*.  We use them in GNU code, so we also define SHT_GNU*
+diff -rup binutils-2.25.orig/ld/emultempl/alphaelf.em binutils-2.25/ld/emultempl/alphaelf.em
+--- binutils-2.25.orig/ld/emultempl/alphaelf.em	2014-12-24 10:46:27.717434037 +0000
++++ binutils-2.25/ld/emultempl/alphaelf.em	2014-12-24 10:47:07.172655604 +0000
+@@ -100,7 +100,7 @@ alpha_finish (void)
+   if (limit_32bit)
+     elf_elfheader (link_info.output_bfd)->e_flags |= EF_ALPHA_32BIT;
+ 
+-  finish_default ();
++  gld${EMULATION_NAME}_finish ();
+ }
+ EOF
+ 
+diff -rup binutils-2.25.orig/ld/emultempl/armelf.em binutils-2.25/ld/emultempl/armelf.em
+--- binutils-2.25.orig/ld/emultempl/armelf.em	2014-12-24 10:46:27.718434043 +0000
++++ binutils-2.25/ld/emultempl/armelf.em	2014-12-24 10:47:07.172655604 +0000
+@@ -370,7 +370,7 @@ gld${EMULATION_NAME}_after_allocation (v
+ }
+ 
+ static void
+-gld${EMULATION_NAME}_finish (void)
++arm_finish (void)
+ {
+   struct bfd_link_hash_entry * h;
+ 
+@@ -393,7 +393,7 @@ gld${EMULATION_NAME}_finish (void)
+ 	}
+     }
+ 
+-  finish_default ();
++  gld${EMULATION_NAME}_finish ();
+ 
+   if (thumb_entry_symbol)
+     {
+@@ -702,4 +702,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=
+ LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME}"_before_parse
+ 
+ # Call the extra arm-elf function
+-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
++LDEMUL_FINISH=arm_finish
+Only in binutils-2.25/ld/emultempl: armelf.em.orig
+diff -rup binutils-2.25.orig/ld/emultempl/elf32.em binutils-2.25/ld/emultempl/elf32.em
+--- binutils-2.25.orig/ld/emultempl/elf32.em	2014-12-24 10:46:27.717434037 +0000
++++ binutils-2.25/ld/emultempl/elf32.em	2014-12-24 10:47:07.174655615 +0000
+@@ -65,6 +65,7 @@ static void gld${EMULATION_NAME}_before_
+ static void gld${EMULATION_NAME}_after_allocation (void);
+ static lang_output_section_statement_type *gld${EMULATION_NAME}_place_orphan
+   (asection *, const char *, int);
++static void gld${EMULATION_NAME}_finish (void);
+ EOF
+ 
+ if [ "x${USE_LIBPATH}" = xyes ] ; then
+@@ -1730,6 +1731,8 @@ output_rel_find (asection *sec, int isdy
+   return last;
+ }
+ 
++static int orphan_init_done = 0;
++
+ /* Place an orphan section.  We use this to put random SHF_ALLOC
+    sections in the right segment.  */
+ 
+@@ -1738,7 +1741,7 @@ gld${EMULATION_NAME}_place_orphan (asect
+ 				   const char *secname,
+ 				   int constraint)
+ {
+-  static struct orphan_save hold[] =
++  static struct orphan_save orig_hold[] =
+     {
+       { ".text",
+ 	SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE,
+@@ -1768,6 +1771,7 @@ gld${EMULATION_NAME}_place_orphan (asect
+ 	SEC_HAS_CONTENTS,
+ 	0, 0, 0, 0 },
+     };
++  static struct orphan_save hold[ARRAY_SIZE (orig_hold)];
+   enum orphan_save_index
+     {
+       orphan_text = 0,
+@@ -1780,7 +1784,6 @@ gld${EMULATION_NAME}_place_orphan (asect
+       orphan_sdata,
+       orphan_nonalloc
+     };
+-  static int orphan_init_done = 0;
+   struct orphan_save *place;
+   lang_output_section_statement_type *after;
+   lang_output_section_statement_type *os;
+@@ -1857,15 +1860,22 @@ gld${EMULATION_NAME}_place_orphan (asect
+ 
+   if (!orphan_init_done)
+     {
+-      struct orphan_save *ho;
++      struct orphan_save *ho, *horig;
+ 
+       for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho)
++      for (ho = hold, horig = orig_hold;
++	   ho < hold + ARRAY_SIZE (hold);
++	   ++ho, ++horig)
++	{
++	  *ho = *horig;
++	  if (ho->name != NULL)
+ 	if (ho->name != NULL)
+ 	  {
+ 	    ho->os = lang_output_section_find (ho->name);
+ 	    if (ho->os != NULL && ho->os->flags == 0)
+ 	      ho->os->flags = ho->flags;
+ 	  }
++	}
+       orphan_init_done = 1;
+     }
+ 
+@@ -1937,6 +1947,27 @@ gld${EMULATION_NAME}_place_orphan (asect
+ EOF
+ fi
+ 
++fragment <<EOF
++
++/* Final emulation specific call.  */
++
++static void
++gld${EMULATION_NAME}_finish (void)
++{
++EOF
++if test x"$LDEMUL_PLACE_ORPHAN" != xgld"$EMULATION_NAME"_place_orphan; then
++fragment <<EOF
++  /* Support the object-only output.  */
++  if (link_info.emit_gnu_object_only)
++    orphan_init_done = 0;
++
++EOF
++fi
++fragment <<EOF
++  finish_default ();
++}
++EOF
++
+ if test x"$LDEMUL_AFTER_ALLOCATION" != xgld"$EMULATION_NAME"_after_allocation; then
+ fragment <<EOF
+ 
+@@ -2505,7 +2536,7 @@ struct ld_emulation_xfer_struct ld_${EMU
+   ${LDEMUL_GET_SCRIPT-gld${EMULATION_NAME}_get_script},
+   "${EMULATION_NAME}",
+   "${OUTPUT_FORMAT}",
+-  ${LDEMUL_FINISH-finish_default},
++  ${LDEMUL_FINISH-gld${EMULATION_NAME}_finish},
+   ${LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS-NULL},
+   ${LDEMUL_OPEN_DYNAMIC_ARCHIVE-gld${EMULATION_NAME}_open_dynamic_archive},
+   ${LDEMUL_PLACE_ORPHAN-gld${EMULATION_NAME}_place_orphan},
+Only in binutils-2.25/ld/emultempl: elf32.em.orig
+diff -rup binutils-2.25.orig/ld/emultempl/ppc64elf.em binutils-2.25/ld/emultempl/ppc64elf.em
+--- binutils-2.25.orig/ld/emultempl/ppc64elf.em	2014-12-24 10:46:27.717434037 +0000
++++ binutils-2.25/ld/emultempl/ppc64elf.em	2014-12-24 10:47:07.174655615 +0000
+@@ -522,7 +522,7 @@ gld${EMULATION_NAME}_after_allocation (v
+ /* Final emulation specific call.  */
+ 
+ static void
+-gld${EMULATION_NAME}_finish (void)
++ppc_finish (void)
+ {
+   char *msg = NULL;
+   char *line, *endline;
+@@ -554,7 +554,7 @@ gld${EMULATION_NAME}_finish (void)
+     free (msg);
+ 
+   ppc64_elf_restore_symbols (&link_info);
+-  finish_default ();
++  gld${EMULATION_NAME}_finish ();
+ }
+ 
+ 
+@@ -876,6 +876,6 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LI
+ #
+ LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation
+ LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
+-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
++LDEMUL_FINISH=ppc_finish
+ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
+ LDEMUL_NEW_VERS_PATTERN=gld${EMULATION_NAME}_new_vers_pattern
+Only in binutils-2.25/ld/emultempl: ppc64elf.em.orig
+diff -rup binutils-2.25.orig/ld/emultempl/spuelf.em binutils-2.25/ld/emultempl/spuelf.em
+--- binutils-2.25.orig/ld/emultempl/spuelf.em	2014-12-24 10:46:27.716434032 +0000
++++ binutils-2.25/ld/emultempl/spuelf.em	2014-12-24 10:47:07.175655620 +0000
+@@ -416,7 +416,7 @@ spu_elf_relink (void)
+ /* Final emulation specific call.  */
+ 
+ static void
+-gld${EMULATION_NAME}_finish (void)
++spu_finish (void)
+ {
+   if (is_spu_target ())
+     {
+@@ -432,7 +432,7 @@ gld${EMULATION_NAME}_finish (void)
+ 	einfo ("%P: --auto-overlay ignored with zero local store range\n");
+     }
+ 
+-  finish_default ();
++  gld${EMULATION_NAME}_finish ();
+ }
+ 
+ static char *
+@@ -832,5 +832,5 @@ PARSE_AND_LIST_ARGS_CASES='
+ 
+ LDEMUL_AFTER_OPEN=spu_after_open
+ LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
+-LDEMUL_FINISH=gld${EMULATION_NAME}_finish
++LDEMUL_FINISH=spu_finish
+ LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
+diff -rup binutils-2.25.orig/ld/ldfile.c binutils-2.25/ld/ldfile.c
+--- binutils-2.25.orig/ld/ldfile.c	2014-12-24 10:46:27.708433987 +0000
++++ binutils-2.25/ld/ldfile.c	2014-12-24 10:57:43.021241971 +0000
+@@ -317,7 +317,9 @@ success:
+ 	  plugin_maybe_claim (&file, entry);
+ 	}
+     }
++  else
+ #endif /* ENABLE_PLUGINS */
++    cmdline_check_object_only_section (entry->the_bfd, FALSE);
+ 
+   /* It opened OK, the format checked out, and the plugins have had
+      their chance to claim it, so this is success.  */
+Only in binutils-2.25/ld: ldfile.c.orig
+diff -rup binutils-2.25.orig/ld/ldlang.c binutils-2.25/ld/ldlang.c
+--- binutils-2.25.orig/ld/ldlang.c	2014-12-24 10:46:27.712434009 +0000
++++ binutils-2.25/ld/ldlang.c	2014-12-24 11:00:13.328090658 +0000
+@@ -36,6 +36,7 @@
+ #include "ldctor.h"
+ #include "ldfile.h"
+ #include "ldemul.h"
++#include "ldwrite.h"
+ #include "fnmatch.h"
+ #include "demangle.h"
+ #include "hashtab.h"
+@@ -45,6 +46,9 @@
+ #include "plugin.h"
+ #endif /* ENABLE_PLUGINS */
+ 
++/* FIXME: Put it here to avoid NAME conflict from ldgram.h.  */
++#include "elf-bfd.h"
++
+ #ifndef offsetof
+ #define offsetof(TYPE, MEMBER) ((size_t) & (((TYPE*) 0)->MEMBER))
+ #endif
+@@ -69,6 +73,9 @@ static lang_statement_list_type *stat_sa
+ static lang_statement_list_type **stat_save_ptr = &stat_save[0];
+ static struct unique_sections *unique_section_list;
+ static struct asneeded_minfo *asneeded_list_head;
++static cmdline_list_type cmdline_object_only_file_list;
++static cmdline_list_type cmdline_object_only_archive_list;
++static cmdline_list_type cmdline_temp_object_only_list;
+ 
+ /* Forward declarations.  */
+ static void exp_init_os (etree_type *);
+@@ -88,6 +95,10 @@ static void lang_record_phdrs (void);
+ static void lang_do_version_exports_section (void);
+ static void lang_finalize_version_expr_head
+   (struct bfd_elf_version_expr_head *);
++static void cmdline_lists_init (void);
++static void cmdline_get_object_only_input_files (void);
++static void print_cmdline_list (cmdline_union_type *);
++static bfd_boolean cmdline_on_object_only_archive_list_p (bfd *);
+ 
+ /* Exported variables.  */
+ const char *output_target;
+@@ -1221,14 +1232,17 @@ output_section_statement_table_free (voi
+ /* Build enough state so that the parser can build its tree.  */
+ 
+ void
+-lang_init (void)
++lang_init (bfd_boolean object_only)
+ {
+-  obstack_begin (&stat_obstack, 1000);
++  if (!object_only)
++    obstack_begin (&stat_obstack, 1000);
+ 
+   stat_ptr = &statement_list;
+ 
+   output_section_statement_table_init ();
+ 
++  cmdline_lists_init ();
++
+   lang_list_init (stat_ptr);
+ 
+   lang_list_init (&input_file_chain);
+@@ -1243,10 +1257,11 @@ lang_init (void)
+ 
+   /* The value "13" is ad-hoc, somewhat related to the expected number of
+      assignments in a linker script.  */
+-  if (!bfd_hash_table_init_n (&lang_definedness_table,
+-			      lang_definedness_newfunc,
+-			      sizeof (struct lang_definedness_hash_entry),
+-			      13))
++  if (!object_only
++      && !bfd_hash_table_init_n (&lang_definedness_table,
++				 lang_definedness_newfunc,
++				 sizeof (struct lang_definedness_hash_entry),
++				 13))
+     einfo (_("%P%F: can not create hash table: %E\n"));
+ 
+   asneeded_list_head = NULL;
+@@ -2839,6 +2854,12 @@ load_symbols (lang_input_statement_type
+ 		  loaded = FALSE;
+ 		}
+ 
++	      if (link_info.emitting_gnu_object_only)
++		{
++		  if (!cmdline_on_object_only_archive_list_p (member))
++		    continue;
++		}
++
+ 	      subsbfd = member;
+ 	      if (!(*link_info.callbacks
+ 		    ->add_archive_element) (&link_info, member,
+@@ -6740,7 +6761,37 @@ lang_process (void)
+ 	  open_input_bfds (statement_list.head, OPEN_BFD_RESCAN);
+ 	}
+     }
++  else
+ #endif /* ENABLE_PLUGINS */
++    if (link_info.relocatable)
++    {
++      /* Check if .gnu_object_only section should be created.  */
++      bfd *p;
++      int object_type;
++
++      object_type = 0;
++      for (p = link_info.input_bfds; p != (bfd *) NULL; p = p->link.next)
++	{
++	  object_type |= 1 << p->lto_type;
++	  if ((object_type & (1 << lto_mixed_object)) != 0
++	      || ((object_type
++		   & (1 << lto_non_ir_object
++		      | 1 << lto_ir_object))
++		  == (1 << lto_non_ir_object | 1 << lto_ir_object)))
++	    {
++	      link_info.emit_gnu_object_only = TRUE;
++	      break;
++	    }
++	}
++
++      if (trace_files
++	  && (cmdline_object_only_file_list.head
++	      || cmdline_object_only_archive_list.head))
++	{
++	  print_cmdline_list (cmdline_object_only_file_list.head);
++	  print_cmdline_list (cmdline_object_only_archive_list.head);
++	}
++    }
+ 
+   link_info.gc_sym_list = &entry_symbol;
+   if (entry_symbol.name == NULL)
+@@ -8142,3 +8193,961 @@ lang_ld_feature (char *str)
+       p = q;
+     }
+ }
++
++static void
++cmdline_lists_init (void)
++{
++  cmdline_object_only_file_list.tail
++    = &cmdline_object_only_file_list.head;
++  cmdline_object_only_archive_list.tail
++    = &cmdline_object_only_archive_list.head;
++  cmdline_temp_object_only_list.tail
++    = &cmdline_temp_object_only_list.head;
++}
++
++/* Allocate an item with TYPE and DATA.  */
++
++static cmdline_union_type *
++cmdline_list_new (cmdline_enum_type type, void *data)
++{
++  cmdline_union_type *new_opt;
++
++  new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
++  new_opt->header.type = type;
++  switch (type)
++    {
++    default:
++      break;
++    case cmdline_is_file_enum:
++      new_opt->file.filename = (const char *) data;
++      break;
++    case cmdline_is_bfd_enum:
++      new_opt->abfd.abfd = (bfd *) data;
++      break;
++    }
++  return new_opt;
++}
++
++/* Append an item with TYPE and DATA to LIST.  */
++
++static void
++cmdline_list_append (cmdline_list_type *list, cmdline_enum_type type,
++		     void *data)
++{
++  cmdline_union_type *new_opt = cmdline_list_new (type, data);
++  new_opt->header.next = NULL;
++  *list->tail = new_opt;
++  list->tail = &new_opt->header.next;
++}
++
++static void
++print_cmdline_list (cmdline_union_type *c)
++{
++  for (; c != NULL; c = c->header.next)
++    switch (c->header.type)
++      {
++      default:
++	abort ();
++      case cmdline_is_file_enum:
++	info_msg (" %s", c->file.filename);
++	break;
++      case cmdline_is_bfd_enum:
++	info_msg (" [%B]", c->abfd.abfd);
++	break;
++      }
++
++  info_msg ("\n");
++}
++
++/* Return TRUE if ABFD is on cmdline_object_only_archive_list.  */
++
++static bfd_boolean
++cmdline_on_object_only_archive_list_p (bfd *abfd)
++{
++  cmdline_union_type *c, *next;
++  bfd *archive, *obfd, *oarchive;
++  ufile_ptr origin = abfd->origin;
++
++  archive = bfd_my_archive (abfd);
++  for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
++    {
++      if (c->header.type != cmdline_is_bfd_enum)
++	abort ();
++
++      next = c->header.next;
++      obfd = c->abfd.abfd;
++      oarchive = bfd_my_archive (obfd);
++
++      /* The list is grouped by archive file name and sorted by member
++	 origin.  */
++      if (strcmp (archive->filename, oarchive->filename) != 0)
++	continue;
++
++      if (origin == obfd->origin)
++	return TRUE;
++      else if (origin < obfd->origin)
++	return FALSE;
++    }
++
++  return FALSE;
++}
++
++/* Append an item with TYPE and DATA to cmdline_object_only_file_list
++   or cmdline_object_only_archive_list if needed.  */
++
++static void
++cmdline_object_only_list_append (cmdline_enum_type type, void *data)
++{
++  cmdline_union_type *c;
++  cmdline_union_type *new_opt, *next, **prev;
++  bfd *abfd, *archive;
++  bfd *obfd, *oarchive;
++  bfd *nbfd, *narchive;
++  ufile_ptr origin, norigin;
++
++  /* Put it on cmdline_object_only_file_list if it isn't an archive
++     member.  */
++  switch (type)
++    {
++    default:
++      abort ();
++    case cmdline_is_bfd_enum:
++      abfd = (bfd *) data;
++      archive = bfd_my_archive (abfd);
++      if (archive)
++	break;
++    case cmdline_is_file_enum:
++      cmdline_list_append (&cmdline_object_only_file_list, type, data);
++      return;
++    }
++
++  /* Put archive member on cmdline_object_only_archive_list and sort
++     the list by archive name and archive member origin.  */
++  new_opt = (cmdline_union_type *) stat_alloc (sizeof (*new_opt));
++  new_opt->header.type = cmdline_is_bfd_enum;
++  new_opt->header.next = NULL;
++  new_opt->abfd.abfd = (bfd *) data;
++
++  c = cmdline_object_only_archive_list.head;
++  if (c == NULL)
++    {
++      cmdline_object_only_archive_list.head = new_opt;
++      cmdline_object_only_archive_list.tail = &new_opt->header.next;
++      return;
++    }
++
++  prev = NULL;
++  origin = abfd->origin;
++  for (; c != NULL; c = next)
++    {
++      if (c->header.type != cmdline_is_bfd_enum)
++	abort ();
++
++      next = c->header.next;
++
++      obfd = c->abfd.abfd;
++      oarchive = bfd_my_archive (obfd);
++
++      if (strcmp (archive->filename, oarchive->filename) == 0)
++	{
++	  bfd_boolean after;
++
++	  if (origin < obfd->origin)
++	    {
++	      /* Insert it before the current.  */
++	      new_opt->header.next = c;
++	      if (prev)
++		*prev = new_opt;
++	      else
++		cmdline_object_only_archive_list.head = new_opt;
++	      return;
++	    }
++
++	  after = TRUE;
++
++	  /* Check origin.  */
++	  while (next)
++	    {
++	      if (next->header.type != cmdline_is_bfd_enum)
++		abort ();
++
++	      nbfd = next->abfd.abfd;
++	      norigin = nbfd->origin;
++	      if (origin > norigin)
++		{
++		  /* Insert it after NEXT.  */
++		  break;
++		}
++
++	      narchive = bfd_my_archive (nbfd);
++	      if (strcmp (archive->filename, narchive->filename) != 0)
++		{
++		  /* Insert it befor NEXT.  */
++		  after = FALSE;
++		  break;
++		}
++
++	      c = next;
++	      next = next->header.next;
++	    }
++
++	  if (after && next)
++	    {
++	      c = next;
++	      next = next->header.next;
++	    }
++
++	  if (*cmdline_object_only_archive_list.tail == c->header.next)
++	    cmdline_object_only_archive_list.tail
++	      = &new_opt->header.next;
++
++	  prev = &c->header.next;
++	  new_opt->header.next = next;
++	  *prev = new_opt;
++	  return;
++	}
++
++      prev = &c->header.next;
++    }
++
++  *cmdline_object_only_archive_list.tail = new_opt;
++  cmdline_object_only_archive_list.tail = &new_opt->header.next;
++}
++
++
++static void
++cmdline_get_object_only_input_files (void)
++{
++  cmdline_union_type *c, *next;
++  bfd *abfd, *archive;
++  bfd *nbfd, *narchive;
++
++  /* Add files first.  */
++  for (c = cmdline_object_only_file_list.head;
++       c != NULL; c = c->header.next)
++    switch (c->header.type)
++      {
++      default:
++	abort ();
++      case cmdline_is_file_enum:
++	lang_add_input_file (c->file.filename,
++			     lang_input_file_is_file_enum, NULL);
++	break;
++      case cmdline_is_bfd_enum:
++	abfd = c->abfd.abfd;
++	if (bfd_my_archive (abfd))
++	  abort ();
++	lang_add_input_file (abfd->filename,
++			     lang_input_file_is_file_enum, NULL);
++	break;
++      }
++
++  /* Add archive members next.  */
++  for (c = cmdline_object_only_archive_list.head; c != NULL; c = next)
++    {
++      if (c->header.type != cmdline_is_bfd_enum)
++	abort ();
++
++      next = c->header.next;
++
++      abfd = c->abfd.abfd;
++      archive = bfd_my_archive (abfd);
++   
++      /* Add the first archive of the archive member group.  */
++      lang_add_input_file (archive->filename,
++			   lang_input_file_is_file_enum, NULL);
++
++      /* Skip the rest members in the archive member group.  */
++      do
++	{
++	  if (!next)
++	    break;
++
++	  if (next->header.type != cmdline_is_bfd_enum)
++	    abort ();
++
++	  next = next->header.next;
++	  if (!next)
++	    break;
++	  nbfd = next->abfd.abfd;
++	  narchive = bfd_my_archive (nbfd);
++	}
++      while (strcmp (archive->filename, narchive->filename) == 0);
++    }
++}
++
++struct cmdline_arg
++{
++  bfd *obfd;
++  asymbol **isympp;
++  int status;
++};
++
++/* Create a section in OBFD with the same
++   name and attributes as ISECTION in IBFD.  */
++
++static void
++setup_section (bfd *ibfd, sec_ptr isection, void *p)
++{
++  struct cmdline_arg *arg = (struct cmdline_arg *) p;
++  bfd *obfd = arg->obfd;
++  asymbol **isympp = arg->isympp;
++  const char *name = isection->name;
++  sec_ptr osection;
++  const char *err;
++
++  /* Skip the object-only section.  */
++  if (ibfd->object_only_section == isection)
++    return;
++
++  /* If we have already failed earlier on, do not keep on generating
++     complaints now.  */
++  if (arg->status)
++    return;
++
++  osection = bfd_make_section_anyway_with_flags (obfd, name,
++						 isection->flags);
++
++  if (osection == NULL)
++    {
++      err = _("failed to create output section");
++      goto loser;
++    }
++
++  osection->size = isection->size;
++  osection->vma = isection->vma;
++  osection->lma = isection->lma;
++  osection->alignment_power = isection->alignment_power;
++
++  /* Copy merge entity size.  */
++  osection->entsize = isection->entsize;
++
++  /* This used to be mangle_section; we do here to avoid using
++     bfd_get_section_by_name since some formats allow multiple
++     sections with the same name.  */
++  isection->output_section = osection;
++  isection->output_offset = 0;
++
++  if ((isection->flags & SEC_GROUP) != 0)
++    {
++      asymbol *gsym = bfd_group_signature (isection, isympp);
++
++      if (gsym != NULL)
++	{
++	  gsym->flags |= BSF_KEEP;
++	  if (ibfd->xvec->flavour == bfd_target_elf_flavour)
++	    elf_group_id (isection) = gsym;
++	}
++    }
++
++  /* Allow the BFD backend to copy any private data it understands
++     from the input section to the output section.  */
++  if (!bfd_copy_private_section_data (ibfd, isection, obfd, osection))
++    {
++      err = _("failed to copy private data");
++      goto loser;
++    }
++
++  /* All went well.  */
++  return;
++
++loser:
++  arg->status = 1;
++  einfo (_("%P%F: setup_section: %s: %s\n"), err, name);
++}
++
++/* Copy the data of input section ISECTION of IBFD
++   to an output section with the same name in OBFD.
++   If stripping then don't copy any relocation info.  */
++
++static void
++copy_section (bfd *ibfd, sec_ptr isection, void *p)
++{
++  struct cmdline_arg *arg = (struct cmdline_arg *) p;
++  bfd *obfd = arg->obfd;
++  asymbol **isympp = arg->isympp;
++  arelent **relpp;
++  long relcount;
++  sec_ptr osection;
++  bfd_size_type size;
++  long relsize;
++  flagword flags;
++  const char *err;
++
++  /* Skip the object-only section.  */
++  if (ibfd->object_only_section == isection)
++    return;
++
++  /* If we have already failed earlier on, do not keep on generating
++     complaints now.  */
++  if (arg->status)
++    return;
++
++  flags = bfd_get_section_flags (ibfd, isection);
++  if ((flags & SEC_GROUP) != 0)
++    return;
++
++  osection = isection->output_section;
++  size = bfd_get_section_size (isection);
++
++  if (size == 0 || osection == 0)
++    return;
++
++  relsize = bfd_get_reloc_upper_bound (ibfd, isection);
++
++  if (relsize < 0)
++    {
++      /* Do not complain if the target does not support relocations.  */
++      if (relsize == -1
++	  && bfd_get_error () == bfd_error_invalid_operation)
++	relsize = 0;
++      else
++	{
++	  err = bfd_errmsg (bfd_get_error ());
++	  goto loser;
++	}
++    }
++
++  if (relsize == 0)
++    bfd_set_reloc (obfd, osection, NULL, 0);
++  else
++    {
++      relpp = (arelent **) xmalloc (relsize);
++      relcount = bfd_canonicalize_reloc (ibfd, isection, relpp, isympp);
++      if (relcount < 0)
++	{
++	  err = _("relocation count is negative");
++	  goto loser;
++	}
++
++      bfd_set_reloc (obfd, osection,
++		     relcount == 0 ? NULL : relpp, relcount);
++      if (relcount == 0)
++	free (relpp);
++    }
++
++  if (bfd_get_section_flags (ibfd, isection) & SEC_HAS_CONTENTS)
++    {
++      bfd_byte *memhunk = NULL;
++
++      if (!bfd_get_full_section_contents (ibfd, isection, &memhunk))
++	{
++	  err = bfd_errmsg (bfd_get_error ());
++	  goto loser;
++	}
++
++      if (!bfd_set_section_contents (obfd, osection, memhunk, 0, size))
++	{
++	  err = bfd_errmsg (bfd_get_error ());
++	  goto loser;
++	}
++      free (memhunk);
++    }
++
++  /* All went well.  */
++  return;
++
++loser:
++  einfo (_("%P%F: copy_section: %s: %s\n"), err, isection->name);
++}
++/* Open the temporary bfd created in the same directory as PATH.  */
++
++static bfd *
++cmdline_fopen_temp (const char *path, const char *target,
++		    const char *mode)
++{
++#define template "ldXXXXXX"
++  const char *slash = strrchr (path, '/');
++  char *tmpname;
++  size_t len;
++  int fd;
++
++#ifdef HAVE_DOS_BASED_FILE_SYSTEM
++  {
++    /* We could have foo/bar\\baz, or foo\\bar, or d:bar.  */
++    char *bslash = strrchr (path, '\\');
++
++    if (slash == NULL || (bslash != NULL && bslash > slash))
++      slash = bslash;
++    if (slash == NULL && path[0] != '\0' && path[1] == ':')
++      slash = path + 1;
++  }
++#endif
++
++  if (slash != (char *) NULL)
++    {
++      len = slash - path;
++      tmpname = (char *) xmalloc (len + sizeof (template) + 2);
++      memcpy (tmpname, path, len);
++
++#ifdef HAVE_DOS_BASED_FILE_SYSTEM
++      /* If tmpname is "X:", appending a slash will make it a root
++	 directory on drive X, which is NOT the same as the current
++	 directory on drive X.  */
++      if (len == 2 && tmpname[1] == ':')
++	tmpname[len++] = '.';
++#endif
++      tmpname[len++] = '/';
++    }
++  else
++    {
++      tmpname = (char *) xmalloc (sizeof (template));
++      len = 0;
++    }
++
++  memcpy (tmpname + len, template, sizeof (template));
++#undef template
++
++#ifdef HAVE_MKSTEMP
++  fd = mkstemp (tmpname);
++#else
++  tmpname = mktemp (tmpname);
++  if (tmpname == NULL)
++    return NULL;
++  fd = open (tmpname, O_RDWR | O_CREAT | O_EXCL, 0600);
++#endif
++  if (fd == -1)
++    return NULL;
++  return bfd_fopen (tmpname, target, mode, fd);
++}
++
++/* Add the object-only section.  */
++
++static void
++cmdline_add_object_only_section (bfd_byte *contents, size_t size)
++{
++  bfd_vma start;
++  flagword flags;
++  enum bfd_architecture iarch;
++  unsigned int imach;
++  long symcount;
++  long symsize;
++  asymbol **isympp = NULL;
++  asymbol **osympp = NULL;
++  bfd *obfd = NULL, *ibfd;
++  const char *err;
++  struct arg
++    {
++      bfd *obfd;
++      asymbol **isympp;
++      int status;
++    } arg;
++  char **matching;
++  const char *ofilename = NULL;
++  asection *sec;
++
++  ibfd = bfd_openr (output_filename, output_target);
++  if (!ibfd)
++    {
++      err = bfd_errmsg (bfd_get_error ());
++      goto loser;
++    }
++
++  if (!bfd_check_format_matches (ibfd, bfd_object, &matching))
++    {
++      err = bfd_errmsg (bfd_get_error ());
++      goto loser;
++    }
++
++  obfd = cmdline_fopen_temp (output_filename, output_target, "w");
++  if (!obfd)
++    {
++      err = bfd_errmsg (bfd_get_error ());
++      goto loser;
++    }
++  ofilename = bfd_get_filename (obfd);
++
++  if (!bfd_set_format (obfd, bfd_object))
++    {
++      err = bfd_errmsg (bfd_get_error ());
++      goto loser;
++    }
++
++  /* Copy the start address, flags and architecture of input file to
++     output file.  */
++  flags = bfd_get_file_flags (ibfd);
++  start = bfd_get_start_address (ibfd);
++  iarch = bfd_get_arch (ibfd);
++  imach = bfd_get_mach (ibfd);
++  if (!bfd_set_start_address (obfd, start)
++      || !bfd_set_file_flags (obfd, flags)
++      || !bfd_set_arch_mach (obfd, iarch, imach))
++    {
++      err = bfd_errmsg (bfd_get_error ());
++      goto loser;
++    }
++	
++  symsize = bfd_get_symtab_upper_bound (ibfd);
++  if (symsize < 0)
++    {
++      err = bfd_errmsg (bfd_get_error ());
++      goto loser;
++    }
++
++  isympp = (asymbol **) xmalloc (symsize);
++  symcount = bfd_canonicalize_symtab (ibfd, isympp);
++  if (symcount < 0)
++    {
++      err = bfd_errmsg (bfd_get_error ());
++      goto loser;
++    }
++
++  arg.obfd = obfd;
++  arg.isympp = isympp;
++  arg.status = 0;
++
++  /* BFD mandates that all output sections be created and sizes set before
++     any output is done.  Thus, we traverse all sections multiple times.  */
++  bfd_map_over_sections (ibfd, setup_section, &arg);
++
++  if (arg.status)
++    {
++      err = _("error setting up sections");
++      goto loser;
++    }
++
++  /* Allow the BFD backend to copy any private data it understands
++     from the input section to the output section.  */
++  if (! bfd_copy_private_header_data (ibfd, obfd))
++    {
++      err = _("error copying private header data");
++      goto loser;
++    }
++
++  /* Create the object-only section.  */
++  sec = bfd_make_section_with_flags (obfd,
++				     GNU_OBJECT_ONLY_SECTION_NAME,
++				     (SEC_HAS_CONTENTS
++				      | SEC_READONLY
++				      | SEC_DATA
++				      | SEC_LINKER_CREATED));
++  if (sec == NULL)
++    {
++      err = _("can't create object-only section");
++      goto loser;
++    }
++
++  if (! bfd_set_section_size (obfd, sec, size))
++    {
++      err = _("can't set object-only section size");
++      goto loser;
++    }
++
++  if (ibfd->object_only_section)
++    {
++      /* Filter out the object-only section symbol.  */
++      long src_count = 0, dst_count = 0;
++      asymbol **from, **to;
++
++      osympp = (asymbol **) xmalloc (symcount * sizeof (asymbol *));
++      from = isympp;
++      to = osympp;
++      for (; src_count < symcount; src_count++)
++	{
++	  asymbol *sym = from[src_count];
++	  if (bfd_get_section (sym) != ibfd->object_only_section)
++	    to[dst_count++] = sym;
++	}
++      to[dst_count] = NULL;
++      symcount = dst_count;
++      bfd_set_symtab (obfd, osympp, symcount);
++    }
++  else
++    bfd_set_symtab (obfd, isympp, symcount);
++
++  /* This has to happen after the symbol table has been set.  */
++  bfd_map_over_sections (ibfd, copy_section, &arg);
++
++  if (arg.status)
++    {
++      err = _("error copying sections");
++      goto loser;
++    }
++
++  /* Copy the object-only section to the output.  */
++  if (! bfd_set_section_contents (obfd, sec, contents, 0, size))
++    {
++      err = _("error adding object-only section");
++      goto loser;
++    }
++
++  /* Allow the BFD backend to copy any private data it understands
++     from the input BFD to the output BFD.  This is done last to
++     permit the routine to look at the filtered symbol table, which is
++     important for the ECOFF code at least.  */
++  if (! bfd_copy_private_bfd_data (ibfd, obfd))
++    {
++      err = _("error copying private BFD data");
++      goto loser;
++    }
++
++  if (!bfd_close (obfd))
++    {
++      unlink (ofilename);
++      einfo (_("%P%F: failed to finish output with object-only section\n"));
++    }
++
++  /* Must be freed after bfd_close ().  */
++  free (isympp);
++  if (osympp)
++    free (osympp);
++
++  if (rename (ofilename, output_filename))
++    {
++      unlink (ofilename);
++      einfo (_("%P%F: failed to rename output with object-only section\n"));
++    }
++
++  return;
++
++loser:
++  if (isympp)
++    free (isympp);
++  if (osympp)
++    free (osympp);
++  if (obfd)
++    bfd_close (obfd);
++  if (ofilename)
++    unlink (ofilename);
++  einfo (_("%P%F: failed to add object-only section: %s\n"), err);
++}
++
++/* Emit the final output with object-only section.  */
++
++void
++cmdline_emit_object_only_section (void)
++{
++  const char *saved_output_filename = output_filename;
++  int fd;
++  size_t size, off;
++  bfd_byte *contents;
++  struct stat st;
++
++  /* Get a temporary object-only file.  */
++  output_filename = make_temp_file (".obj-only.o");
++
++  had_output_filename = FALSE;
++  link_info.input_bfds = NULL;
++  link_info.input_bfds_tail = &link_info.input_bfds;
++
++  lang_init (TRUE);
++
++  ld_parse_linker_script ();
++
++  /* Set up the object-only output. */
++  lang_final ();
++
++  /* Open the object-only file for output.  */
++  lang_for_each_statement (ldlang_open_output);
++
++  ldemul_create_output_section_statements ();
++
++  if (!bfd_section_already_linked_table_init ())
++    einfo (_("%P%F: Failed to create hash table\n"));
++
++  /* Call cmdline_on_object_only_archive_list_p to check which member
++     should be loaded.  */
++  input_flags.whole_archive = TRUE;
++
++  /* Set it to avoid adding more to cmdline lists.  */
++  link_info.emitting_gnu_object_only = TRUE;
++
++  cmdline_get_object_only_input_files ();
++
++  open_input_bfds (statement_list.head, FALSE);
++
++  ldemul_after_open ();
++
++  bfd_section_already_linked_table_free ();
++
++  /* Make sure that we're not mixing architectures.  We call this
++     after all the input files have been opened, but before we do any
++     other processing, so that any operations merge_private_bfd_data
++     does on the output file will be known during the rest of the
++     link.  */
++  lang_check ();
++
++  /* Size up the common data.  */
++  lang_common ();
++
++  /* Update wild statements.  */
++  update_wild_statements (statement_list.head);
++
++  /* Run through the contours of the script and attach input sections
++     to the correct output sections.  */
++  map_input_to_output_sections (statement_list.head, NULL, NULL);
++
++  /* Find any sections not attached explicitly and handle them.  */
++  lang_place_orphans ();
++
++  /* Do anything special before sizing sections.  This is where ELF
++     and other back-ends size dynamic sections.  */
++  ldemul_before_allocation ();
++
++  /* Size up the sections.  */
++  lang_size_sections (NULL, ! RELAXATION_ENABLED);
++
++  /* See if anything special should be done now we know how big
++     everything is.  This is where relaxation is done.  */
++  ldemul_after_allocation ();
++
++  ldemul_finish ();
++
++  /* Make sure that the section addresses make sense.  */
++  if (command_line.check_section_addresses)
++    lang_check_section_addresses ();
++
++  lang_end ();
++  
++  ldwrite ();
++
++  lang_finish ();
++
++  if (! bfd_close (link_info.output_bfd))
++    einfo (_("%P%F:%s: final close failed on object-only output: %E\n"),
++	   output_filename);
++
++  /* Read in the object-only file.  */
++  fd = open (output_filename, O_RDONLY | O_BINARY);
++  if (fd < 0)
++    {
++      bfd_set_error (bfd_error_system_call);
++      einfo (_("%P%F:%s: cannot open object-only output: %E"),
++	     output_filename);
++    }
++
++  /* Get the object-only file size.  */
++  if (fstat (fd, &st) != 0)
++    {
++      bfd_set_error (bfd_error_system_call);
++      einfo (_("%P%F:%s: cannot stat object-only output: %E"),
++	     output_filename);
++    }
++
++  size = st.st_size;
++  off = 0;
++  contents = (bfd_byte *) xmalloc (size);
++  while (off != size)
++    {
++      ssize_t got;
++
++      got = read (fd, contents + off, size - off);
++      if (got < 0)
++	{
++	  bfd_set_error (bfd_error_system_call);
++	  einfo (_("%P%F:%s: read failed on object-only output: %E"),
++		 output_filename);
++	}
++
++      off += got;
++    }
++
++  close (fd);
++
++  /* Remove the temporary object-only file.  */ 
++  unlink (output_filename);
++
++  output_filename = saved_output_filename;
++
++  cmdline_add_object_only_section (contents, size);
++
++  free (contents);
++}
++
++/* Extract the object-only section.  */
++
++static const char *
++cmdline_extract_object_only_section (bfd *abfd)
++{
++  const char *name = bfd_extract_object_only_section (abfd);
++
++  if (name == NULL)
++    einfo (_("%P%F: cannot extract object-only section from %B: %E"),
++	   abfd);
++
++  /* It should be removed after it is done.  */
++  cmdline_list_append (&cmdline_temp_object_only_list,
++		       cmdline_is_file_enum, (void *) name);
++
++  return name;
++}
++
++/* Check and handle the object-only section.   */
++
++void
++cmdline_check_object_only_section (bfd *abfd, bfd_boolean lto)
++{
++  const char *filename;
++
++  if (link_info.emitting_gnu_object_only
++      || abfd->format != bfd_object)
++    return;
++
++  if (lto)
++    {
++      /* For LTO link, we only need to extract object-only section
++	 from the mixed object, add it to input, and put it on LTO
++	 claimed output.  */
++      switch (abfd->lto_type)
++	{
++	default:
++	  abort ();
++	case lto_mixed_object:
++	  filename = cmdline_extract_object_only_section (abfd);
++	  lang_add_input_file (filename,
++			       lang_input_file_is_file_enum, NULL);
++	  break;
++	case lto_non_ir_object:
++	case lto_ir_object:
++	  break;
++	}
++    }
++  else if (link_info.relocatable)
++    {
++      /* For non-LTO relocatable link, we need to append non-IR object
++	 file and the object file in object-only section to the object
++	 only list.  */
++      switch (abfd->lto_type)
++	{
++	default:
++	  abort ();
++	case lto_mixed_object:
++	  filename = cmdline_extract_object_only_section (abfd);
++	  cmdline_object_only_list_append (cmdline_is_file_enum,
++					  (void *) filename);
++	  break;
++	case lto_non_ir_object:
++	  cmdline_object_only_list_append (cmdline_is_bfd_enum, abfd);
++	  break;
++	case lto_ir_object:
++	  break;
++	}
++    }
++}
++
++/* Remove temporary object-only files.  */
++
++void
++cmdline_remove_object_only_files (void)
++{
++  cmdline_union_type *c;
++
++#ifdef ENABLE_PLUGINS
++  if (plugin_save_temps)
++    return;
++#endif
++
++  c = cmdline_temp_object_only_list.head;
++  for (; c != NULL; c = c->header.next)
++    switch (c->header.type)
++      {
++      default:
++	abort ();
++      case cmdline_is_file_enum:
++	unlink (c->file.filename);
++	break;
++      }
++}
++
++
++
+Only in binutils-2.25/ld: ldlang.c.orig
+Only in binutils-2.25/ld: ldlang.c.rej
+diff -rup binutils-2.25.orig/ld/ldlang.h binutils-2.25/ld/ldlang.h
+--- binutils-2.25.orig/ld/ldlang.h	2014-12-24 10:46:27.718434043 +0000
++++ binutils-2.25/ld/ldlang.h	2014-12-24 10:47:07.181655654 +0000
+@@ -523,7 +523,7 @@ extern struct asneeded_minfo **asneeded_
+ extern void (*output_bfd_hash_table_free_fn) (struct bfd_link_hash_table *);
+ 
+ extern void lang_init
+-  (void);
++  (bfd_boolean);
+ extern void lang_finish
+   (void);
+ extern lang_memory_region_type * lang_memory_region_lookup
+@@ -698,4 +698,45 @@ ldlang_override_segment_assignment
+ extern void
+ lang_ld_feature (char *);
+ 
++typedef enum
++{
++  cmdline_is_file_enum,
++  cmdline_is_bfd_enum
++} cmdline_enum_type;
++
++typedef struct cmdline_header_struct
++{
++  union cmdline_union *next;
++  cmdline_enum_type type;
++} cmdline_header_type;
++
++typedef struct cmdline_file_struct
++{
++  cmdline_header_type header;
++  const char *filename;
++} cmdline_file_type;
++
++typedef struct cmdline_bfd_struct
++{
++  cmdline_header_type header;
++  bfd *abfd;
++} cmdline_bfd_type;
++
++typedef union cmdline_union
++{
++  cmdline_header_type header;
++  cmdline_file_type file;
++  cmdline_bfd_type abfd;
++} cmdline_union_type;
++
++typedef struct cmdline_list
++{
++  cmdline_union_type *head;
++  cmdline_union_type **tail;
++} cmdline_list_type;
++
++extern void cmdline_emit_object_only_section (void);
++extern void cmdline_check_object_only_section (bfd *, bfd_boolean);
++extern void cmdline_remove_object_only_files (void);
++
+ #endif
+Only in binutils-2.25/ld: ldlang.h.orig
+diff -rup binutils-2.25.orig/ld/ldlex.h binutils-2.25/ld/ldlex.h
+--- binutils-2.25.orig/ld/ldlex.h	2014-12-24 10:46:27.720434054 +0000
++++ binutils-2.25/ld/ldlex.h	2014-12-24 10:47:07.181655654 +0000
+@@ -133,6 +133,7 @@ enum option_values
+ #ifdef ENABLE_PLUGINS
+   OPTION_PLUGIN,
+   OPTION_PLUGIN_OPT,
++  OPTION_PLUGIN_SAVE_TEMPS,
+ #endif /* ENABLE_PLUGINS */
+   OPTION_DEFAULT_SCRIPT,
+   OPTION_PRINT_OUTPUT_FORMAT,
+diff -rup binutils-2.25.orig/ld/ldmain.c binutils-2.25/ld/ldmain.c
+--- binutils-2.25.orig/ld/ldmain.c	2014-12-24 10:46:27.715434026 +0000
++++ binutils-2.25/ld/ldmain.c	2014-12-24 11:02:55.443006018 +0000
+@@ -220,6 +220,9 @@ main (int argc, char **argv)
+ 
+   xatexit (ld_cleanup);
+ 
++  /* Remove temporary object-only files.  */
++  xatexit (cmdline_remove_object_only_files);
++
+   /* Set up the sysroot directory.  */
+   ld_sysroot = get_sysroot (argc, argv);
+   if (*ld_sysroot)
+@@ -296,7 +299,7 @@ main (int argc, char **argv)
+   default_target = ldemul_choose_target (argc, argv);
+   config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
+   config.commonpagesize = bfd_emul_get_commonpagesize (default_target);
+-  lang_init ();
++  lang_init (FALSE);
+   ldemul_before_parse ();
+   lang_has_input_file = FALSE;
+   parse_args (argc, argv);
+@@ -311,34 +314,7 @@ main (int argc, char **argv)
+ 
+   ldemul_set_symbols ();
+ 
+-  /* If we have not already opened and parsed a linker script,
+-     try the default script from command line first.  */
+-  if (saved_script_handle == NULL
+-      && command_line.default_script != NULL)
+-    {
+-      ldfile_open_command_file (command_line.default_script);
+-      parser_input = input_script;
+-      yyparse ();
+-    }
+-
+-  /* If we have not already opened and parsed a linker script
+-     read the emulation's appropriate default script.  */
+-  if (saved_script_handle == NULL)
+-    {
+-      int isfile;
+-      char *s = ldemul_get_script (&isfile);
+-
+-      if (isfile)
+-	ldfile_open_default_command_file (s);
+-      else
+-	{
+-	  lex_string = s;
+-	  lex_redirect (s, _("built in linker script"), 1);
+-	}
+-      parser_input = input_script;
+-      yyparse ();
+-      lex_string = NULL;
+-    }
++  ld_parse_linker_script ();
+ 
+   if (verbose)
+     {
+@@ -459,6 +435,8 @@ main (int argc, char **argv)
+       if (! bfd_close (link_info.output_bfd))
+ 	einfo (_("%F%B: final close failed: %E\n"), link_info.output_bfd);
+ 
++      link_info.output_bfd = NULL;
++
+       /* If the --force-exe-suffix is enabled, and we're making an
+ 	 executable file and it doesn't end in .exe, copy it to one
+ 	 which does.  */
+@@ -505,6 +483,9 @@ main (int argc, char **argv)
+ 	}
+     }
+ 
++  if (link_info.emit_gnu_object_only)
++    cmdline_emit_object_only_section ();
++
+   END_PROGRESS (program_name);
+ 
+   if (config.stats)
+@@ -814,7 +795,9 @@ add_archive_element (struct bfd_link_inf
+ 	    }
+ 	}
+     }
++  else
+ #endif /* ENABLE_PLUGINS */
++    cmdline_check_object_only_section (input->the_bfd, FALSE);
+ 
+   ldlang_add_file (input);
+ 
+@@ -1207,7 +1190,8 @@ warning_callback (struct bfd_link_info *
+     einfo ("%P: %s%s\n", _("warning: "), warning);
+   else if (symbol == NULL)
+     einfo ("%B: %s%s\n", abfd, _("warning: "), warning);
+-  else if (! symbol_warning (warning, symbol, abfd))
++  else if (((abfd->flags & BFD_PLUGIN) == 0)
++	   && ! symbol_warning (warning, symbol, abfd))
+     {
+       bfd *b;
+       /* Search all input files for a reference to SYMBOL.  */
+@@ -1493,3 +1477,38 @@ notice (struct bfd_link_info *info,
+ 
+   return TRUE;
+ }
++
++/* Parse the linker script.   */
++
++void
++ld_parse_linker_script ()
++{
++  /* If we have not already opened and parsed a linker script,
++     try the default script from command line first.  */
++  if (saved_script_handle == NULL
++      && command_line.default_script != NULL)
++    {
++      ldfile_open_command_file (command_line.default_script);
++      parser_input = input_script;
++      yyparse ();
++    }
++
++  /* If we have not already opened and parsed a linker script
++     read the emulation's appropriate default script.  */
++  if (saved_script_handle == NULL)
++    {
++      int isfile;
++      char *s = ldemul_get_script (&isfile);
++
++      if (isfile)
++	ldfile_open_default_command_file (s);
++      else
++	{
++	  lex_string = s;
++	  lex_redirect (s, _("built in linker script"), 1);
++	}
++      parser_input = input_script;
++      yyparse ();
++      lex_string = NULL;
++    }
++}
+Only in binutils-2.25/ld: ldmain.c.orig
+Only in binutils-2.25/ld: ldmain.c.rej
+diff -rup binutils-2.25.orig/ld/ldmain.h binutils-2.25/ld/ldmain.h
+--- binutils-2.25.orig/ld/ldmain.h	2014-12-24 10:46:27.715434026 +0000
++++ binutils-2.25/ld/ldmain.h	2014-12-24 10:47:07.183655665 +0000
+@@ -59,4 +59,6 @@ extern void add_wrap (const char *);
+ extern void add_ignoresym (struct bfd_link_info *, const char *);
+ extern void add_keepsyms_file (const char *);
+ 
++extern void ld_parse_linker_script (void);
++
+ #endif
+Only in binutils-2.25/ld: ldmain.h.orig
+diff -rup binutils-2.25.orig/ld/lexsup.c binutils-2.25/ld/lexsup.c
+--- binutils-2.25.orig/ld/lexsup.c	2014-12-24 10:46:27.870434896 +0000
++++ binutils-2.25/ld/lexsup.c	2014-12-24 10:47:07.184655671 +0000
+@@ -166,6 +166,9 @@ static const struct ld_option ld_options
+     '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
+   { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
+     '\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
++  { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS},
++    '\0', NULL, N_("Store plugin intermediate files permanently"),
++    ONE_DASH },
+   { {"flto", optional_argument, NULL, OPTION_IGNORE},
+     '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
+     ONE_DASH },
+@@ -978,6 +981,9 @@ parse_args (unsigned argc, char **argv)
+ 	  if (plugin_opt_plugin_arg (optarg))
+ 	    einfo(_("%P%F: bad -plugin-opt option\n"));
+ 	  break;
++	case OPTION_PLUGIN_SAVE_TEMPS:
++	  plugin_save_temps = TRUE;
++	  break;
+ #endif /* ENABLE_PLUGINS */
+ 	case 'q':
+ 	  link_info.emitrelocations = TRUE;
+Only in binutils-2.25/ld: lexsup.c.orig
+diff -rup binutils-2.25.orig/ld/plugin.c binutils-2.25/ld/plugin.c
+--- binutils-2.25.orig/ld/plugin.c	2014-12-24 10:46:27.719434048 +0000
++++ binutils-2.25/ld/plugin.c	2014-12-24 10:47:07.185655677 +0000
+@@ -39,6 +39,9 @@
+ /* Report plugin symbols.  */
+ bfd_boolean report_plugin_symbols;
+ 
++/* Store plugin intermediate files permanently.  */
++bfd_boolean plugin_save_temps;
++
+ /* The suffix to append to the name of the real (claimed) object file
+    when generating a dummy BFD to hold the IR symbols sent from the
+    plugin.  For cosmetic use only; appears in maps, crefs etc.  */
+@@ -229,6 +232,17 @@ plugin_opt_plugin_arg (const char *arg)
+ 	return 0;
+     }
+ 
++  /* Ignore -pass-through= from GCC driver.  */
++  if (*arg == '-')
++    {
++      const char *p;
++      for (p = arg + 1; p; p++)
++	if (*p != '-')
++	  break;
++      if (strncmp (p, "pass-through=", 13) == 0)
++	return 0;
++    }
++
+   newarg = xmalloc (sizeof *newarg);
+   newarg->arg = arg;
+   newarg->next = NULL;
+@@ -882,6 +896,9 @@ plugin_maybe_claim (struct ld_plugin_inp
+   close (file->fd);
+   if (claimed)
+     {
++      /* Check object only section.  */
++      cmdline_check_object_only_section (entry->the_bfd, TRUE);
++
+       /* Discard the real file's BFD and substitute the dummy one.  */
+ 
+       /* BFD archive handling caches elements so we can't call
+@@ -935,14 +952,17 @@ plugin_call_cleanup (void)
+     {
+       if (curplug->cleanup_handler && !curplug->cleanup_done)
+ 	{
+-	  enum ld_plugin_status rv;
+-	  curplug->cleanup_done = TRUE;
+-	  called_plugin = curplug;
+-	  rv = (*curplug->cleanup_handler) ();
+-	  called_plugin = NULL;
+-	  if (rv != LDPS_OK)
+-	    info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
+-		      curplug->name, rv);
++	  if (!plugin_save_temps)
++	    {
++	      enum ld_plugin_status rv;
++	      curplug->cleanup_done = TRUE;
++	      called_plugin = curplug;
++	      rv = (*curplug->cleanup_handler) ();
++	      called_plugin = NULL;
++	      if (rv != LDPS_OK)
++		info_msg (_("%P: %s: error in plugin cleanup: %d (ignored)\n"),
++			  curplug->name, rv);
++	    }
+ 	  dlclose (curplug->dlhandle);
+ 	}
+       curplug = curplug->next;
+Only in binutils-2.25/ld: plugin.c.orig
+diff -rup binutils-2.25.orig/ld/plugin.h binutils-2.25/ld/plugin.h
+--- binutils-2.25.orig/ld/plugin.h	2014-12-24 10:46:27.718434043 +0000
++++ binutils-2.25/ld/plugin.h	2014-12-24 10:47:07.185655677 +0000
+@@ -24,6 +24,9 @@
+ /* Report plugin symbols.  */
+ extern bfd_boolean report_plugin_symbols;
+ 
++/* Store plugin intermediate files permanently.  */
++extern bfd_boolean plugin_save_temps;
++
+ /* Set at all symbols read time, to avoid recursively offering the plugin
+    its own newly-added input files and libs to claim.  */
+ extern bfd_boolean no_more_claiming;
+diff -rup binutils-2.25.orig/ld/scripttempl/armbpabi.sc binutils-2.25/ld/scripttempl/armbpabi.sc
+--- binutils-2.25.orig/ld/scripttempl/armbpabi.sc	2014-12-24 10:46:27.709433992 +0000
++++ binutils-2.25/ld/scripttempl/armbpabi.sc	2014-12-24 10:47:07.400656884 +0000
+@@ -36,7 +36,7 @@ INTERP=".interp       0 : { *(.interp) }
+ PLT=".plt          ${RELOCATING-0} : { *(.plt) }"
+ RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+ DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
+-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+ if test -z "${NO_SMALL_DATA}"; then
+   SBSS=".sbss         ${RELOCATING-0} :
+   {
+Only in binutils-2.25/ld/scripttempl: armbpabi.sc.orig
+diff -rup binutils-2.25.orig/ld/scripttempl/elf32sh-symbian.sc binutils-2.25/ld/scripttempl/elf32sh-symbian.sc
+--- binutils-2.25.orig/ld/scripttempl/elf32sh-symbian.sc	2014-12-24 10:46:27.709433992 +0000
++++ binutils-2.25/ld/scripttempl/elf32sh-symbian.sc	2014-12-24 10:47:07.401656890 +0000
+@@ -88,7 +88,7 @@ fi
+     PLT=".plt            : { *(.plt) } :dynamic :dyn"
+ DYNAMIC=".dynamic        : { *(.dynamic) } :dynamic :dyn"
+  RODATA=".rodata    ALIGN(4) : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive)  *(.gnu.lto_*) }"
++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.directive)  *(.gnu.lto_*) *(.gnu_object_only) }"
+ test -z "$GOT" && GOT=".got          ${RELOCATING-0} : { *(.got.plt) *(.got) } :dynamic :dyn"
+ INIT_ARRAY=".init_array   ${RELOCATING-0} :
+   {
+Only in binutils-2.25/ld/scripttempl: elf32sh-symbian.sc.orig
+diff -rup binutils-2.25.orig/ld/scripttempl/elf64hppa.sc binutils-2.25/ld/scripttempl/elf64hppa.sc
+--- binutils-2.25.orig/ld/scripttempl/elf64hppa.sc	2014-12-24 10:46:27.711434003 +0000
++++ binutils-2.25/ld/scripttempl/elf64hppa.sc	2014-12-24 10:47:07.401656890 +0000
+@@ -132,7 +132,7 @@ fi
+ DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+ RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+ DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+ if test -z "${NO_SMALL_DATA}"; then
+   SBSS=".sbss         ${RELOCATING-0} :
+   {
+Only in binutils-2.25/ld/scripttempl: elf64hppa.sc.orig
+diff -rup binutils-2.25.orig/ld/scripttempl/elf.sc binutils-2.25/ld/scripttempl/elf.sc
+--- binutils-2.25.orig/ld/scripttempl/elf.sc	2014-12-24 10:46:27.709433992 +0000
++++ binutils-2.25/ld/scripttempl/elf.sc	2014-12-24 10:47:07.402656895 +0000
+@@ -165,7 +165,7 @@ RELA_IPLT=".rela.iplt    ${RELOCATING-0}
+ DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+ RODATA=".${RODATA_NAME}       ${RELOCATING-0} : { *(.${RODATA_NAME}${RELOCATING+ .${RODATA_NAME}.* .gnu.linkonce.r.*}) }"
+ DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }"
++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+ if test -z "${NO_SMALL_DATA}"; then
+   SBSS=".${SBSS_NAME}         ${RELOCATING-0} :
+   {
+Only in binutils-2.25/ld/scripttempl: elf.sc.orig
+diff -rup binutils-2.25.orig/ld/scripttempl/elfxtensa.sc binutils-2.25/ld/scripttempl/elfxtensa.sc
+--- binutils-2.25.orig/ld/scripttempl/elfxtensa.sc	2014-12-24 10:46:27.710433998 +0000
++++ binutils-2.25/ld/scripttempl/elfxtensa.sc	2014-12-24 10:47:07.402656895 +0000
+@@ -145,7 +145,7 @@ fi
+ DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+ RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+ DATARELRO=".data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }"
+-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+ INIT_LIT=".init.literal 0 : { *(.init.literal)	}"
+ INIT=".init         0 : { *(.init)		}"
+ FINI_LIT=".fini.literal 0 : { *(.fini.literal)	}"
+Only in binutils-2.25/ld/scripttempl: elfxtensa.sc.orig
+diff -rup binutils-2.25.orig/ld/scripttempl/mep.sc binutils-2.25/ld/scripttempl/mep.sc
+--- binutils-2.25.orig/ld/scripttempl/mep.sc	2014-12-24 10:46:27.711434003 +0000
++++ binutils-2.25/ld/scripttempl/mep.sc	2014-12-24 10:47:07.403656901 +0000
+@@ -119,7 +119,7 @@ fi
+ DYNAMIC=".dynamic      ${RELOCATING-0} : { *(.dynamic) }"
+ RODATA=".rodata       ${RELOCATING-0} : { *(.rodata${RELOCATING+ .rodata.* .gnu.linkonce.r.*}) }"
+ DATARELRO=".data.rel.ro : { *(.data.rel.ro.local) *(.data.rel.ro .data.rel.ro.*) }"
+-DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink)  *(.gnu.lto_*) }"
++DISCARDED="/DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) *(.gnu_object_only) }"
+ if test -z "${NO_SMALL_DATA}"; then
+   SBSS=".sbss         ${RELOCATING-0} :
+   {
+Only in binutils-2.25/ld/scripttempl: mep.sc.orig
+diff -rup binutils-2.25.orig/ld/scripttempl/pep.sc binutils-2.25/ld/scripttempl/pep.sc
+--- binutils-2.25.orig/ld/scripttempl/pep.sc	2014-12-24 10:46:27.709433992 +0000
++++ binutils-2.25/ld/scripttempl/pep.sc	2014-12-24 10:47:07.403656901 +0000
+@@ -170,6 +170,7 @@ SECTIONS
+     *(.drectve)
+     ${RELOCATING+ *(.note.GNU-stack)}
+     ${RELOCATING+ *(.gnu.lto_*)}
++    ${RELOCATING+ *(.gnu_object_only)}
+   }
+ 
+   .idata ${RELOCATING+BLOCK(__section_alignment__)} :
+Only in binutils-2.25/ld/scripttempl: pep.sc.orig
+diff -rup binutils-2.25.orig/ld/scripttempl/pe.sc binutils-2.25/ld/scripttempl/pe.sc
+--- binutils-2.25.orig/ld/scripttempl/pe.sc	2014-12-24 10:46:27.711434003 +0000
++++ binutils-2.25/ld/scripttempl/pe.sc	2014-12-24 10:47:07.404656906 +0000
+@@ -165,6 +165,7 @@ SECTIONS
+     *(.drectve)
+     ${RELOCATING+ *(.note.GNU-stack)}
+     ${RELOCATING+ *(.gnu.lto_*)}
++    ${RELOCATING+ *(.gnu_object_only)}
+   }
+ 
+   .idata ${RELOCATING+BLOCK(__section_alignment__)} :
+Only in binutils-2.25/ld/scripttempl: pe.sc.orig
diff --git a/binutils-2.25-set-long-long.patch b/binutils-2.25-set-long-long.patch
new file mode 100644
index 0000000..1ea7418
--- /dev/null
+++ b/binutils-2.25-set-long-long.patch
@@ -0,0 +1,38 @@
+diff -up binutils-2.25.orig/bfd/configure.ac binutils-2.25/bfd/configure.ac
+--- binutils-2.25.orig/bfd/configure.ac	2014-12-24 10:34:45.590491143 +0000
++++ binutils-2.25/bfd/configure.ac	2014-12-24 10:36:12.997981992 +0000
+@@ -183,11 +183,13 @@ if test "x${ac_cv_sizeof_long}" = "x8";
+   BFD_HOST_64BIT_LONG=1
+   test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long"
+   test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long"
+-elif test "x${ac_cv_sizeof_long_long}" = "x8"; then
++fi
++if test "x${ac_cv_sizeof_long_long}" = "x8"; then
+   BFD_HOST_64BIT_LONG_LONG=1
+   test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long"
+   test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long"
+-  if test "x${ac_cv_sizeof_void_p}" = "x8"; then
++  if test "x${ac_cv_sizeof_void_p}" = "x8" \
++          -a "x${ac_cv_sizeof_long}" != "x8"; then
+     BFD_HOSTPTR_T="unsigned long long"
+   fi
+ fi
+diff -up ../binutils-2.20.51.0.7.original/bfd/configure ./bfd/configure
+--- a/bfd/configure	2010-04-08 15:23:58.000000000 +0100
++++ b/bfd/configure	2010-04-08 15:24:06.000000000 +0100
+@@ -12819,11 +12819,13 @@
+   BFD_HOST_64BIT_LONG=1
+   test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long"
+   test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long"
+-elif test "x${ac_cv_sizeof_long_long}" = "x8"; then
++fi
++if test "x${ac_cv_sizeof_long_long}" = "x8"; then
+   BFD_HOST_64BIT_LONG_LONG=1
+   test -n "${HOST_64BIT_TYPE}" || HOST_64BIT_TYPE="long long"
+   test -n "${HOST_U_64BIT_TYPE}" || HOST_U_64BIT_TYPE="unsigned long long"
+-  if test "x${ac_cv_sizeof_void_p}" = "x8"; then
++  if test "x${ac_cv_sizeof_void_p}" = "x8" \
++          -a "x${ac_cv_sizeof_long}" != "x8"; then
+     BFD_HOSTPTR_T="unsigned long long"
+   fi
+ fi
diff --git a/binutils-2.25-version.patch b/binutils-2.25-version.patch
new file mode 100644
index 0000000..7d088ed
--- /dev/null
+++ b/binutils-2.25-version.patch
@@ -0,0 +1,47 @@
+diff -up binutils-2.25.orig/bfd/Makefile.am binutils-2.25/bfd/Makefile.am
+--- binutils-2.25.orig/bfd/Makefile.am	2014-12-24 10:28:10.546273213 +0000
++++ binutils-2.25/bfd/Makefile.am	2014-12-24 10:30:27.569042391 +0000
+@@ -1025,8 +1025,8 @@ DISTCLEANFILES = $(BUILD_CFILES) $(BUILD
+ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
+ 	@echo "creating $@"
+ 	@bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\
+-	bfd_version_string="\"$(VERSION)\"" ;\
+-	bfd_soversion="$(VERSION)" ;\
++	bfd_version_string="\"$(VERSION)-%{release}\"" ;\
++	bfd_soversion="$(VERSION)-%{release}" ;\
+ 	bfd_version_package="\"$(PKGVERSION)\"" ;\
+ 	report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\
+ 	. $(srcdir)/development.sh ;\
+@@ -1037,7 +1037,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/
+ 	fi ;\
+ 	sed -e "s, at bfd_version@,$$bfd_version," \
+ 	    -e "s, at bfd_version_string@,$$bfd_version_string," \
+-	    -e "s, at bfd_version_package@,$$bfd_version_package," \
++	    -e "s, at bfd_version_package@,\"version \"," \
+ 	    -e "s, at report_bugs_to@,$$report_bugs_to," \
+ 	    < $(srcdir)/version.h > $@; \
+ 	echo "$${bfd_soversion}" > libtool-soversion
+diff -up binutils-2.25.orig/bfd/Makefile.in binutils-2.25/bfd/Makefile.in
+--- binutils-2.25.orig/bfd/Makefile.in	2014-12-24 10:28:10.558273280 +0000
++++ binutils-2.25/bfd/Makefile.in	2014-12-24 10:31:37.444434637 +0000
+@@ -2085,8 +2085,8 @@ stmp-lcoff-h: $(LIBCOFF_H_FILES)
+ bfdver.h: $(srcdir)/version.h $(srcdir)/development.sh $(srcdir)/Makefile.in
+ 	@echo "creating $@"
+ 	@bfd_version=`echo "$(VERSION)" | sed -e 's/\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\)\.*\([^\.]*\).*/\1.00\2.00\3.00\4.00\5/' -e 's/\([^\.]*\)\..*\(..\)\..*\(..\)\..*\(..\)\..*\(..\)$$/\1\2\3\4\5/'` ;\
+-	bfd_version_string="\"$(VERSION)\"" ;\
+-	bfd_soversion="$(VERSION)" ;\
++	bfd_version_string="\"$(VERSION)-%{release}\"" ;\
++	bfd_soversion="$(VERSION)-%{release}" ;\
+ 	bfd_version_package="\"$(PKGVERSION)\"" ;\
+ 	report_bugs_to="\"$(REPORT_BUGS_TO)\"" ;\
+ 	. $(srcdir)/development.sh ;\
+@@ -2097,7 +2097,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/
+ 	fi ;\
+ 	sed -e "s, at bfd_version@,$$bfd_version," \
+ 	    -e "s, at bfd_version_string@,$$bfd_version_string," \
+-	    -e "s, at bfd_version_package@,$$bfd_version_package," \
++	    -e "s, at bfd_version_package@,\"version \"," \
+ 	    -e "s, at report_bugs_to@,$$report_bugs_to," \
+ 	    < $(srcdir)/version.h > $@; \
+ 	echo "$${bfd_soversion}" > libtool-soversion
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/cross-binutils.git/commitdiff/688e32ec1bb39c594c77d9e6ce2effcf7dd3cef8



More information about the pld-cvs-commit mailing list