From 0b07f11b74da2cb1635b093c9b55a411ca3cbf09 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 24 2017 08:18:13 +0000 Subject: import devtoolset-7-binutils-2.28-8.el7 --- diff --git a/.devtoolset-7-binutils.metadata b/.devtoolset-7-binutils.metadata new file mode 100644 index 0000000..12ce424 --- /dev/null +++ b/.devtoolset-7-binutils.metadata @@ -0,0 +1 @@ +f8b033731f6baa437d429c60e2623570f1ef9d6b SOURCES/binutils-2.28.tar.bz2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..430daf1 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/binutils-2.28.tar.bz2 diff --git a/README.md b/README.md deleted file mode 100644 index 98f42b4..0000000 --- a/README.md +++ /dev/null @@ -1,4 +0,0 @@ -The master branch has no content - -Look at the c7 branch if you are working with CentOS-7, or the c4/c5/c6 branch for CentOS-4, 5 or 6 -If you find this file in a distro specific branch, it means that no content has been checked in yet diff --git a/SOURCES/binutils-2.19.50.0.1-output-format.sed b/SOURCES/binutils-2.19.50.0.1-output-format.sed new file mode 100644 index 0000000..fd770cb --- /dev/null +++ b/SOURCES/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/SOURCES/binutils-2.20.51.0.10-ppc64-pie.patch b/SOURCES/binutils-2.20.51.0.10-ppc64-pie.patch new file mode 100644 index 0000000..740c071 --- /dev/null +++ b/SOURCES/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/SOURCES/binutils-2.20.51.0.10-sec-merge-emit.patch b/SOURCES/binutils-2.20.51.0.10-sec-merge-emit.patch new file mode 100644 index 0000000..238beb3 --- /dev/null +++ b/SOURCES/binutils-2.20.51.0.10-sec-merge-emit.patch @@ -0,0 +1,11 @@ +--- binutils-2.26.orig/bfd/merge.c 2016-01-25 10:11:33.505289018 +0000 ++++ binutils-2.26/bfd/merge.c 2016-01-25 10:19:56.961381656 +0000 +@@ -334,7 +334,7 @@ sec_merge_emit (bfd *abfd, struct sec_me + + /* Trailing alignment needed? */ + off = sec->size - off; +- if (off != 0) ++ if (off != 0 && alignment_power) + { + if (contents) + memcpy (contents + offset, pad, off); diff --git a/SOURCES/binutils-2.20.51.0.2-ia64-lib64.patch b/SOURCES/binutils-2.20.51.0.2-ia64-lib64.patch new file mode 100644 index 0000000..c1241ac --- /dev/null +++ b/SOURCES/binutils-2.20.51.0.2-ia64-lib64.patch @@ -0,0 +1,21 @@ +2004-05-14 Jakub Jelinek + + * 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/SOURCES/binutils-2.20.51.0.2-libtool-lib64.patch b/SOURCES/binutils-2.20.51.0.2-libtool-lib64.patch new file mode 100644 index 0000000..142fc7e --- /dev/null +++ b/SOURCES/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/SOURCES/binutils-2.22.52.0.1-export-demangle.h.patch b/SOURCES/binutils-2.22.52.0.1-export-demangle.h.patch new file mode 100644 index 0000000..84f82cd --- /dev/null +++ b/SOURCES/binutils-2.22.52.0.1-export-demangle.h.patch @@ -0,0 +1,21 @@ +--- 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 = +--- binutils-2.26.orig/bfd/Makefile.in 2016-01-25 10:23:35.054721634 +0000 ++++ binutils-2.26/bfd/Makefile.in 2016-01-25 10:25:59.292607840 +0000 +@@ -350,6 +350,7 @@ libbfd_la_LDFLAGS = $(am__append_1) -rel + @INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2) + @INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \ + @INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ ++@INSTALL_LIBBFD_TRUE@ $(INCDIR)/demangle.h \ + @INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2) + @INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@ + @INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la diff --git a/SOURCES/binutils-2.22.52.0.1-relro-on-by-default.patch b/SOURCES/binutils-2.22.52.0.1-relro-on-by-default.patch new file mode 100644 index 0000000..8d9b6c1 --- /dev/null +++ b/SOURCES/binutils-2.22.52.0.1-relro-on-by-default.patch @@ -0,0 +1,13 @@ +--- binutils-2.27.orig/ld/configure.tgt 2016-07-07 11:16:49.967963649 +0100 ++++ binutils-2.27/ld/configure.tgt 2016-07-07 11:17:02.252045673 +0100 +@@ -901,8 +901,8 @@ frv-*-* | hppa*-*-* | ia64-*-* | mips*-* + # FAIL: objcopy -shared -z relro (tbss2) + # FAIL: objcopy -shared -z relro (tbss3) + ;; +-*-*-linux*) +- if test ${ac_default_ld_z_relro} = unset; then ++*) ++ if test x${ac_default_ld_z_relro} = xunset; then + ac_default_ld_z_relro=1 + fi + ;; diff --git a/SOURCES/binutils-2.22.52.0.4-no-config-h-check.patch b/SOURCES/binutils-2.22.52.0.4-no-config-h-check.patch new file mode 100644 index 0000000..c89195a --- /dev/null +++ b/SOURCES/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/SOURCES/binutils-2.23.51.0.3-Provide-std-tr1-hash.patch b/SOURCES/binutils-2.23.51.0.3-Provide-std-tr1-hash.patch new file mode 100644 index 0000000..852034c --- /dev/null +++ b/SOURCES/binutils-2.23.51.0.3-Provide-std-tr1-hash.patch @@ -0,0 +1,57 @@ +From b9fe56f2e08939e68cabda378c7e5c4775ed381e Mon Sep 17 00:00:00 2001 +From: root +Date: Tue, 16 Oct 2012 04:27:15 -0400 +Subject: [PATCH] Provide std::tr1::hash{, } + +When compiling powerpc.cc on gcc 4.1 i386, we fail on line 68 +because we try to instantiate unordered_map with a key that is +elfcpp::Elf_types::Elf_Addr where size seems to be uint64_t. + +That amounts to trying to use an std::tr1::hash +but then system.h only defines an std::tr1::hash with off_t +defined to long long. + +This patch defines a specialization for std::tr1::hash +and std::tr1::hash, similarly to what is done by recent libstdc++ +in the file functional_hash.h. + +gold/ + + * system.h (tr1_hashtable_define_trivial_hash): Define new macro. + Use it to define specializations std::tr1::hash + and std::tr1::hash. +--- + gold/gold.h | 21 ++++++++++++++------- + 1 files changed, 14 insertions(+), 7 deletions(-) + +diff -Nrup a/gold/system.h b/gold/system.h +--- a/gold/system.h 2012-12-21 14:40:41.000000000 -0500 ++++ b/gold/system.h 2013-01-08 13:29:21.872781906 -0500 +@@ -77,13 +77,20 @@ + // arises with GCC 4.1.x when compiling in 32-bit mode with a 64-bit + // off_t type. + namespace std { namespace tr1 { +-template<> +-struct hash : public std::unary_function +-{ +- std::size_t +- operator()(off_t val) const +- { return static_cast(val); } +-}; ++#define tr1_hashtable_define_trivial_hash(T) \ ++ template<> \ ++ struct hash \ ++ : public std::unary_function \ ++ { \ ++ std::size_t \ ++ operator()(T val) const \ ++ { return static_cast(val); } \ ++ } ++ template struct hash; ++ ++ tr1_hashtable_define_trivial_hash(long long); ++ tr1_hashtable_define_trivial_hash(unsigned long long); ++#undef tr1_hashtable_define_trivial_hash + } } // Close namespaces. + #endif // !defined(HAVE_TR1_HASH_OFF_T) + diff --git a/SOURCES/binutils-2.24-ldforcele.patch b/SOURCES/binutils-2.24-ldforcele.patch new file mode 100644 index 0000000..194cf1e --- /dev/null +++ b/SOURCES/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/SOURCES/binutils-2.24-rh919508.patch b/SOURCES/binutils-2.24-rh919508.patch new file mode 100644 index 0000000..4e2e19c --- /dev/null +++ b/SOURCES/binutils-2.24-rh919508.patch @@ -0,0 +1,12 @@ +diff -Nrup a/gold/Makefile.in b/gold/Makefile.in +--- a/gold/Makefile.in 2014-05-16 02:47:18.061653023 -0400 ++++ b/gold/Makefile.in 2014-05-16 02:51:39.680778689 -0400 +@@ -120,7 +120,7 @@ am__objects_3 = yyscript.$(OBJEXT) + am_libgold_a_OBJECTS = $(am__objects_1) $(am__objects_2) \ + $(am__objects_3) $(am__objects_2) + libgold_a_OBJECTS = $(am_libgold_a_OBJECTS) +-am__installdirs = "$(DESTDIR)$(bindir)" ++am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" + @GCC_TRUE@@NATIVE_LINKER_TRUE@@THREADS_TRUE@am__EXEEXT_1 = \ + @GCC_TRUE@@NATIVE_LINKER_TRUE@@THREADS_TRUE@ ld3$(EXEEXT) + PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) diff --git a/SOURCES/binutils-2.25-set-long-long.patch b/SOURCES/binutils-2.25-set-long-long.patch new file mode 100644 index 0000000..1ea7418 --- /dev/null +++ b/SOURCES/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/SOURCES/binutils-2.25-version.patch b/SOURCES/binutils-2.25-version.patch new file mode 100644 index 0000000..d97e81b --- /dev/null +++ b/SOURCES/binutils-2.25-version.patch @@ -0,0 +1,44 @@ +--- binutils-2.26.orig/bfd/Makefile.am 2016-01-25 10:11:33.505289018 +0000 ++++ binutils-2.26/bfd/Makefile.am 2016-01-25 10:13:23.489964145 +0000 +@@ -1043,8 +1043,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 ;\ +@@ -1055,7 +1055,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/ + fi ;\ + $(SED) -e "s,@bfd_version@,$$bfd_version," \ + -e "s,@bfd_version_string@,$$bfd_version_string," \ +- -e "s,@bfd_version_package@,$$bfd_version_package," \ ++ -e "s,@bfd_version_package@,\"version \"," \ + -e "s,@report_bugs_to@,$$report_bugs_to," \ + < $(srcdir)/version.h > $@; \ + echo "$${bfd_soversion}" > libtool-soversion +--- binutils-2.26.orig/bfd/Makefile.in 2016-01-25 10:11:33.505289018 +0000 ++++ binutils-2.26/bfd/Makefile.in 2016-01-25 10:14:17.818297941 +0000 +@@ -2111,8 +2111,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 ;\ +@@ -2123,7 +2123,7 @@ bfdver.h: $(srcdir)/version.h $(srcdir)/ + fi ;\ + $(SED) -e "s,@bfd_version@,$$bfd_version," \ + -e "s,@bfd_version_string@,$$bfd_version_string," \ +- -e "s,@bfd_version_package@,$$bfd_version_package," \ ++ -e "s,@bfd_version_package@,\"version \"," \ + -e "s,@report_bugs_to@,$$report_bugs_to," \ + < $(srcdir)/version.h > $@; \ + echo "$${bfd_soversion}" > libtool-soversion diff --git a/SOURCES/binutils-2.26-lto.patch b/SOURCES/binutils-2.26-lto.patch new file mode 100644 index 0000000..f90faa5 --- /dev/null +++ b/SOURCES/binutils-2.26-lto.patch @@ -0,0 +1,2559 @@ +diff -rup binutils-2.26.orig/bfd/bfd.c binutils-2.26/bfd/bfd.c +--- binutils-2.26.orig/bfd/bfd.c 2016-02-19 09:35:36.231000625 +0000 ++++ binutils-2.26/bfd/bfd.c 2016-02-19 09:35:54.901106498 +0000 +@@ -57,6 +57,14 @@ CODE_FRAGMENT + . bfd_byte data[1]; + . }; + . ++.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. *} +@@ -227,6 +235,9 @@ CODE_FRAGMENT + . {* Set if this is a plugin output file. *} + . unsigned int lto_output : 1; + . ++. {* LTO object type. *} ++. ENUM_BITFIELD (bfd_lto_object_type) lto_type : 2; ++. + . {* Set to dummy BFD created when claimed by a compiler plug-in + . library. *} + . bfd *plugin_dummy_bfd; +@@ -252,6 +263,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; + . +@@ -2270,3 +2284,36 @@ bfd_convert_section_contents (bfd *ibfd, + *ptr_size = size; + return TRUE; + } ++ ++/* ++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; ++} +diff -rup binutils-2.26.orig/bfd/bfd-in2.h binutils-2.26/bfd/bfd-in2.h +--- binutils-2.26.orig/bfd/bfd-in2.h 2016-02-19 09:35:36.280000903 +0000 ++++ binutils-2.26/bfd/bfd-in2.h 2016-02-19 09:35:54.900106492 +0000 +@@ -1089,6 +1089,9 @@ struct bfd_section *bfd_create_gnu_debug + + char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir); + ++const char *bfd_extract_object_only_section ++ (bfd *abfd); ++ + /* Extracted from libbfd.c. */ + + /* Byte swapping macros for user section data. */ +@@ -1654,6 +1657,9 @@ extern asection _bfd_std_section[4]; + #define BFD_COM_SECTION_NAME "*COM*" + #define BFD_IND_SECTION_NAME "*IND*" + ++/* GNU object-only section name. */ ++#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" ++ + /* Pointer to the common section. */ + #define bfd_com_section_ptr (&_bfd_std_section[0]) + /* Pointer to the undefined section. */ +@@ -6511,6 +6517,14 @@ struct bfd_build_id + bfd_byte data[1]; + }; + ++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. */ +@@ -6681,6 +6695,9 @@ struct bfd + /* Set if this is a plugin output file. */ + unsigned int lto_output : 1; + ++ /* LTO object type. */ ++ ENUM_BITFIELD (bfd_lto_object_type) lto_type : 2; ++ + /* Set to dummy BFD created when claimed by a compiler plug-in + library. */ + bfd *plugin_dummy_bfd; +@@ -6706,6 +6723,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; + +@@ -7026,6 +7046,8 @@ bfd_boolean bfd_convert_section_contents + (bfd *ibfd, asection *isec, bfd *obfd, + bfd_byte **ptr, bfd_size_type *ptr_size); + ++asymbol *bfd_group_signature (asection *group, asymbol **isympp); ++ + /* Extracted from archive.c. */ + symindex bfd_get_next_mapent + (bfd *abfd, symindex previous, carsym **sym); +diff -rup binutils-2.26.orig/bfd/elf.c binutils-2.26/bfd/elf.c +--- binutils-2.26.orig/bfd/elf.c 2016-02-19 09:35:36.280000903 +0000 ++++ binutils-2.26/bfd/elf.c 2016-02-19 09:35:54.904106515 +0000 +@@ -2387,6 +2387,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.26.orig/bfd/format.c binutils-2.26/bfd/format.c +--- binutils-2.26.orig/bfd/format.c 2016-02-19 09:35:36.265000818 +0000 ++++ binutils-2.26/bfd/format.c 2016-02-19 09:36:21.420256880 +0000 +@@ -46,6 +46,9 @@ SUBSECTION + #include "sysdep.h" + #include "bfd.h" + #include "libbfd.h" ++#if BFD_SUPPORTS_PLUGINS ++#include "plugin.h" ++#endif + + /* IMPORT from targets.c. */ + extern const size_t _bfd_target_vector_entries; +@@ -179,6 +182,33 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE + preserve->marker = 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; ++ } ++} ++ + /* + FUNCTION + bfd_check_format_matches +@@ -221,7 +251,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) + { +@@ -285,6 +318,13 @@ bfd_check_format_matches (bfd *abfd, bfd + || (*target)->match_priority > best_match) + continue; + ++#if BFD_SUPPORTS_PLUGINS ++ /* If the plugin target is explicitly specified when a BFD file ++ is opened, don't check it twice. */ ++ if (bfd_plugin_specified_p () && bfd_plugin_target_p (*target)) ++ continue; ++#endif ++ + /* If we already tried a match, the bfd is modified and may + have sections attached, which will confuse the next + _bfd_check_format call. */ +@@ -449,6 +489,8 @@ 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; + } +diff -rup binutils-2.26.orig/bfd/opncls.c binutils-2.26/bfd/opncls.c +--- binutils-2.26.orig/bfd/opncls.c 2016-02-19 09:35:36.281000909 +0000 ++++ binutils-2.26/bfd/opncls.c 2016-02-19 09:35:54.905106520 +0000 +@@ -1717,6 +1717,72 @@ 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 <> 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; ++} + + /* + INTERNAL_FUNCTION +diff -rup binutils-2.26.orig/bfd/plugin.c binutils-2.26/bfd/plugin.c +--- binutils-2.26.orig/bfd/plugin.c 2016-02-19 09:35:36.271000852 +0000 ++++ binutils-2.26/bfd/plugin.c 2016-02-19 09:35:54.905106520 +0000 +@@ -130,6 +130,146 @@ 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, ".text", 0, 0); ++static asection bfd_plugin_fake_common_section ++ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, 0, ++ NULL, 0, SEC_IS_COMMON); ++ ++/* 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_error_handler) ++ (_("%s: failed to open to extract object only section: %s"), ++ abfd->filename, bfd_errmsg (bfd_get_error ())); ++ goto error_return; ++ } ++ else if (!bfd_check_format (nbfd, bfd_object)) ++ { ++ /* There is no object only section if it isn't a bfd_object ++ file. */ ++error_return: ++ 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, +@@ -142,10 +282,13 @@ add_symbols (void * handle, + plugin_data->nsyms = nsyms; + plugin_data->syms = syms; + +- if (nsyms != 0) ++ abfd->tdata.plugin_data = plugin_data; ++ ++ 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; + return LDPS_OK; + } + +@@ -440,7 +583,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); + +@@ -474,12 +618,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++) + { +@@ -492,10 +631,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: +@@ -503,15 +643,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; + } + +diff -rup binutils-2.26.orig/bfd/plugin.h binutils-2.26/bfd/plugin.h +--- binutils-2.26.orig/bfd/plugin.h 2016-02-19 09:35:36.271000852 +0000 ++++ binutils-2.26/bfd/plugin.h 2016-02-19 09:35:54.906106526 +0000 +@@ -33,6 +33,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.26.orig/bfd/section.c binutils-2.26/bfd/section.c +--- binutils-2.26.orig/bfd/section.c 2016-02-19 09:35:36.276000881 +0000 ++++ binutils-2.26/bfd/section.c 2016-02-19 09:35:54.906106526 +0000 +@@ -588,6 +588,9 @@ CODE_FRAGMENT + .#define BFD_COM_SECTION_NAME "*COM*" + .#define BFD_IND_SECTION_NAME "*IND*" + . ++.{* GNU object-only section name. *} ++.#define GNU_OBJECT_ONLY_SECTION_NAME ".gnu_object_only" ++. + .{* Pointer to the common section. *} + .#define bfd_com_section_ptr (&_bfd_std_section[0]) + .{* Pointer to the undefined section. *} +diff -rup binutils-2.26.orig/binutils/readelf.c binutils-2.26/binutils/readelf.c +--- binutils-2.26.orig/binutils/readelf.c 2016-02-19 09:35:36.295000988 +0000 ++++ binutils-2.26/binutils/readelf.c 2016-02-19 09:35:54.911106554 +0000 +@@ -3900,6 +3900,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)) +diff -rup binutils-2.26.orig/gas/testsuite/gas/elf/section9.d binutils-2.26/gas/testsuite/gas/elf/section9.d +--- binutils-2.26.orig/gas/testsuite/gas/elf/section9.d 2016-02-19 09:35:36.397001567 +0000 ++++ binutils-2.26/gas/testsuite/gas/elf/section9.d 2016-02-19 09:35:54.912106560 +0000 +@@ -4,4 +4,5 @@ + #... + [ ]*\[.*\][ ]+\.gnu\.lto_main[ ]+PROGBITS.*[ ]+E[ ]+.* + [ ]*\[.*\][ ]+\.gnu\.lto_\.pureconst[ ]+PROGBITS.*[ ]+E[ ]+.* ++[ ]*\[.*\][ ]+\.gnu_object_only[ ]+GNU_OBJECT_ONLY.*[ ]+E[ ]+.* + #pass +diff -rup binutils-2.26.orig/gas/testsuite/gas/elf/section9.s binutils-2.26/gas/testsuite/gas/elf/section9.s +--- binutils-2.26.orig/gas/testsuite/gas/elf/section9.s 2016-02-19 09:35:36.397001567 +0000 ++++ binutils-2.26/gas/testsuite/gas/elf/section9.s 2016-02-19 09:35:54.912106560 +0000 +@@ -2,3 +2,5 @@ + .byte 0,0,0,0 + .section .gnu.lto_.pureconst,"",%progbits + .byte 0,0,0,0 ++ .section .gnu_object_only ++ .byte 0,0,0,0 +diff -rup binutils-2.26.orig/include/bfdlink.h binutils-2.26/include/bfdlink.h +--- binutils-2.26.orig/include/bfdlink.h 2016-02-19 09:35:36.672003126 +0000 ++++ binutils-2.26/include/bfdlink.h 2016-02-19 09:35:54.913106566 +0000 +@@ -400,6 +400,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; + +diff -rup binutils-2.26.orig/include/elf/common.h binutils-2.26/include/elf/common.h +--- binutils-2.26.orig/include/elf/common.h 2016-02-19 09:35:36.675003143 +0000 ++++ binutils-2.26/include/elf/common.h 2016-02-19 09:35:54.913106566 +0000 +@@ -478,6 +478,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.26.orig/ld/emultempl/aarch64elf.em binutils-2.26/ld/emultempl/aarch64elf.em +--- binutils-2.26.orig/ld/emultempl/aarch64elf.em 2016-02-19 09:35:36.698003274 +0000 ++++ binutils-2.26/ld/emultempl/aarch64elf.em 2016-02-19 09:35:54.914106571 +0000 +@@ -271,7 +271,7 @@ gld${EMULATION_NAME}_after_allocation (v + } + + static void +-gld${EMULATION_NAME}_finish (void) ++aarch64_finish (void) + { + if (!bfd_link_relocatable (&link_info)) + { +@@ -283,7 +283,7 @@ gld${EMULATION_NAME}_finish (void) + } + } + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + } + + /* This is a convenient point to tell BFD about target specific flags. +@@ -435,4 +435,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=aarch64_finish +diff -rup binutils-2.26.orig/ld/emultempl/alphaelf.em binutils-2.26/ld/emultempl/alphaelf.em +--- binutils-2.26.orig/ld/emultempl/alphaelf.em 2016-02-19 09:35:36.698003274 +0000 ++++ binutils-2.26/ld/emultempl/alphaelf.em 2016-02-19 09:35:54.914106571 +0000 +@@ -104,7 +104,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.26.orig/ld/emultempl/avrelf.em binutils-2.26/ld/emultempl/avrelf.em +--- binutils-2.26.orig/ld/emultempl/avrelf.em 2016-02-19 09:35:36.698003274 +0000 ++++ binutils-2.26/ld/emultempl/avrelf.em 2016-02-19 09:35:54.915106577 +0000 +@@ -209,7 +209,7 @@ avr_finish (void) + else + elf_elfheader (abfd)->e_flags &= ~EF_AVR_LINKRELAX_PREPARED; + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + } + EOF + +diff -rup binutils-2.26.orig/ld/emultempl/elf32.em binutils-2.26/ld/emultempl/elf32.em +--- binutils-2.26.orig/ld/emultempl/elf32.em 2016-02-19 09:35:36.700003285 +0000 ++++ binutils-2.26/ld/emultempl/elf32.em 2016-02-19 09:35:54.915106577 +0000 +@@ -66,6 +66,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 +@@ -1795,6 +1796,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. */ + +@@ -1803,7 +1806,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, +@@ -1833,6 +1836,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, +@@ -1845,7 +1849,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; +@@ -1924,15 +1927,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; + } + +@@ -2017,6 +2027,27 @@ gld${EMULATION_NAME}_place_orphan (asect + EOF + fi + ++fragment <my_archive; ++ 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 = abfd->my_archive; ++ ++ 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 = nbfd->my_archive; ++ 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; ++} ++ ++/* Get object-only input files. */ ++ ++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 (abfd->my_archive) ++ 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 = abfd->my_archive; ++ ++ /* 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 = nbfd->my_archive; ++ } ++ 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; ++ 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; ++ } ++ /* To be used after bfd_close (). */ ++ ofilename = xstrdup (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")); ++ } ++ ++ free (ofilename); ++ return; ++ ++loser: ++ if (isympp) ++ free (isympp); ++ if (osympp) ++ free (osympp); ++ if (obfd) ++ bfd_close (obfd); ++ if (ofilename) ++ { ++ unlink (ofilename); ++ free (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); ++ ldexp_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; ++ ++ /* Get object-only input files. */ ++ cmdline_get_object_only_input_files (); ++ ++ /* Open 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 (); ++ ++ ldexp_finish (TRUE); ++ 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 (bfd_link_relocatable (&link_info)) ++ { ++ /* 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; ++ } ++} +diff -rup binutils-2.26.orig/ld/ldlang.h binutils-2.26/ld/ldlang.h +--- binutils-2.26.orig/ld/ldlang.h 2016-02-19 09:35:36.701003291 +0000 ++++ binutils-2.26/ld/ldlang.h 2016-02-19 09:35:54.921106611 +0000 +@@ -517,7 +517,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 +@@ -693,7 +693,48 @@ lang_ld_feature (char *); + extern void + lang_print_memory_usage (void); + + extern void + lang_add_gc_name (const 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 +diff -rup binutils-2.26.orig/ld/ldlex.h binutils-2.26/ld/ldlex.h +--- binutils-2.26.orig/ld/ldlex.h 2016-02-19 09:35:36.701003291 +0000 ++++ binutils-2.26/ld/ldlex.h 2016-02-19 09:35:54.921106611 +0000 +@@ -134,6 +134,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.26.orig/ld/ldmain.c binutils-2.26/ld/ldmain.c +--- binutils-2.26.orig/ld/ldmain.c 2016-02-19 09:35:36.701003291 +0000 ++++ binutils-2.26/ld/ldmain.c 2016-02-19 09:35:54.922106617 +0000 +@@ -219,6 +219,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) +@@ -291,8 +294,8 @@ 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 (); +- ldexp_init (); ++ lang_init (FALSE); ++ ldexp_init (FALSE); + ldemul_before_parse (); + lang_has_input_file = FALSE; + parse_args (argc, argv); +@@ -307,34 +310,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) + { +@@ -445,7 +421,7 @@ main (int argc, char **argv) + fprintf (stderr, "lookup = %p val %lx\n", h, h ? h->u.def.value : 1); + } + #endif +- ldexp_finish (); ++ ldexp_finish (FALSE); + lang_finish (); + + /* Even if we're producing relocatable output, some non-fatal errors should +@@ -465,6 +441,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. */ +@@ -512,6 +490,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) +@@ -805,7 +786,9 @@ add_archive_element (struct bfd_link_inf + *subsbfd = input->the_bfd; + } + } ++ else + #endif /* ENABLE_PLUGINS */ ++ cmdline_check_object_only_section (input->the_bfd, FALSE); + + ldlang_add_file (input); + +@@ -1484,3 +1467,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; ++ } ++} +diff -rup binutils-2.26.orig/ld/ldmain.h binutils-2.26/ld/ldmain.h +--- binutils-2.26.orig/ld/ldmain.h 2016-02-19 09:35:36.701003291 +0000 ++++ binutils-2.26/ld/ldmain.h 2016-02-19 09:35:54.922106617 +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 +diff -rup binutils-2.26.orig/ld/lexsup.c binutils-2.26/ld/lexsup.c +--- binutils-2.26.orig/ld/lexsup.c 2016-02-19 09:35:36.700003285 +0000 ++++ binutils-2.26/ld/lexsup.c 2016-02-19 09:35:54.923106623 +0000 +@@ -169,6 +169,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 }, +@@ -1020,6 +1023,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; +diff -rup binutils-2.26.orig/ld/plugin.c binutils-2.26/ld/plugin.c +--- binutils-2.26.orig/ld/plugin.c 2016-02-19 09:35:36.702003296 +0000 ++++ binutils-2.26/ld/plugin.c 2016-02-19 09:35:54.923106623 +0000 +@@ -57,6 +57,9 @@ extern int errno; + /* 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. */ +@@ -1182,6 +1185,9 @@ plugin_maybe_claim (lang_input_statement + { + bfd *abfd = entry->the_bfd->plugin_dummy_bfd; + ++ /* Check object only section. */ ++ cmdline_check_object_only_section (entry->the_bfd, TRUE); ++ + /* Discard the real file's BFD and substitute the dummy one. */ + + /* We can't call bfd_close on archives. BFD archive handling +@@ -1227,14 +1233,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; +diff -rup binutils-2.26.orig/ld/plugin.h binutils-2.26/ld/plugin.h +--- binutils-2.26.orig/ld/plugin.h 2016-02-19 09:35:36.702003296 +0000 ++++ binutils-2.26/ld/plugin.h 2016-02-19 09:35:54.924106628 +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.26.orig/ld/scripttempl/armbpabi.sc binutils-2.26/ld/scripttempl/armbpabi.sc +--- binutils-2.26.orig/ld/scripttempl/armbpabi.sc 2016-02-19 09:35:36.704003308 +0000 ++++ binutils-2.26/ld/scripttempl/armbpabi.sc 2016-02-19 09:35:54.924106628 +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} : + { +diff -rup binutils-2.26.orig/ld/scripttempl/elf32sh-symbian.sc binutils-2.26/ld/scripttempl/elf32sh-symbian.sc +--- binutils-2.26.orig/ld/scripttempl/elf32sh-symbian.sc 2016-02-19 09:35:36.705003313 +0000 ++++ binutils-2.26/ld/scripttempl/elf32sh-symbian.sc 2016-02-19 09:35:54.925106634 +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} : + { +diff -rup binutils-2.26.orig/ld/scripttempl/elf64hppa.sc binutils-2.26/ld/scripttempl/elf64hppa.sc +--- binutils-2.26.orig/ld/scripttempl/elf64hppa.sc 2016-02-19 09:35:36.705003313 +0000 ++++ binutils-2.26/ld/scripttempl/elf64hppa.sc 2016-02-19 09:35:54.925106634 +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} : + { +diff -rup binutils-2.26.orig/ld/scripttempl/elf.sc binutils-2.26/ld/scripttempl/elf.sc +--- binutils-2.26.orig/ld/scripttempl/elf.sc 2016-02-19 09:35:36.705003313 +0000 ++++ binutils-2.26/ld/scripttempl/elf.sc 2016-02-19 09:35:54.924106628 +0000 +@@ -170,7 +170,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} : + { +diff -rup binutils-2.26.orig/ld/scripttempl/elfxtensa.sc binutils-2.26/ld/scripttempl/elfxtensa.sc +--- binutils-2.26.orig/ld/scripttempl/elfxtensa.sc 2016-02-19 09:35:36.705003313 +0000 ++++ binutils-2.26/ld/scripttempl/elfxtensa.sc 2016-02-19 09:35:54.925106634 +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) }" +diff -rup binutils-2.26.orig/ld/scripttempl/mep.sc binutils-2.26/ld/scripttempl/mep.sc +--- binutils-2.26.orig/ld/scripttempl/mep.sc 2016-02-19 09:35:36.706003319 +0000 ++++ binutils-2.26/ld/scripttempl/mep.sc 2016-02-19 09:35:54.926106640 +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} : + { +diff -rup binutils-2.26.orig/ld/scripttempl/pep.sc binutils-2.26/ld/scripttempl/pep.sc +--- binutils-2.26.orig/ld/scripttempl/pep.sc 2016-02-19 09:35:36.706003319 +0000 ++++ binutils-2.26/ld/scripttempl/pep.sc 2016-02-19 09:35:54.926106640 +0000 +@@ -178,6 +178,7 @@ SECTIONS + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} ++ ${RELOCATING+ *(.gnu_object_only)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : +diff -rup binutils-2.26.orig/ld/scripttempl/pe.sc binutils-2.26/ld/scripttempl/pe.sc +--- binutils-2.26.orig/ld/scripttempl/pe.sc 2016-02-19 09:35:36.706003319 +0000 ++++ binutils-2.26/ld/scripttempl/pe.sc 2016-02-19 09:35:54.926106640 +0000 +@@ -165,6 +165,7 @@ SECTIONS + *(.drectve) + ${RELOCATING+ *(.note.GNU-stack)} + ${RELOCATING+ *(.gnu.lto_*)} ++ ${RELOCATING+ *(.gnu_object_only)} + } + + .idata ${RELOCATING+BLOCK(__section_alignment__)} : +diff -rup binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp binutils-2.26/ld/testsuite/ld-plugin/lto.exp +--- binutils-2.26.orig/ld/testsuite/ld-plugin/lto.exp 2016-02-19 09:35:36.807003892 +0000 ++++ binutils-2.26/ld/testsuite/ld-plugin/lto.exp 2016-02-19 09:36:15.450223025 +0000 +@@ -79,6 +79,15 @@ set lto_link_tests [list \ + [list "Build liblto-3.a" \ + "" "-flto $lto_fat" \ + {lto-3b.c} {} "liblto-3.a"] \ ++ [list "Compile 4a" \ ++ "" "-flto $lto_fat" \ ++ {lto-4a.c} {} ""] \ ++ [list "Compile 4b" \ ++ "" "-O2" \ ++ {lto-4b.c} {} ""] \ ++ [list "Compile 4c" \ ++ "" "-O2" \ ++ {lto-4c.c} {} ""] \ + [list "Compile 5a" \ + "" "-flto $lto_fat" \ + {lto-5a.c} {} ""] \ +@@ -94,6 +103,12 @@ set lto_link_tests [list \ + [list "Compile 9" \ + "" "-O2 -finline -flto" \ + {lto-9.cc} {} "" "c++"] \ ++ [list "Compile 10a" \ ++ "" "-O2" \ ++ {lto-10a.c} {} ""] \ ++ [list "Compile 10b" \ ++ "" "-O2 -flto $lto_fat" \ ++ {lto-10b.c} {} ""] \ + [list "Compile 11a" \ + "" "-O -flto" \ + {lto-11a.c} {} ""] \ +@@ -291,9 +306,21 @@ set lto_run_tests [list \ + [list "LTO 3c" \ + "-O2 -flto -fuse-linker-plugin tmpdir/lto-3a.o tmpdir/lto-3c.o -Wl,--whole-archive tmpdir/liblto-3.a -Wl,--no-whole-archive tmpdir/liblto-3.a" "" \ + {dummy.c} "lto-3d.exe" "lto-3.out" "" "c"] \ ++ [list "LTO 4a" \ ++ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-a.o" "" \ ++ {dummy.c} "lto-4a.exe" "lto-4.out" "" "c"] \ ++ [list "LTO 4c" \ ++ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-c.o" "" \ ++ {dummy.c} "lto-4c.exe" "lto-4.out" "" "c"] \ ++ [list "LTO 4d" \ ++ "-O2 -flto -fuse-linker-plugin tmpdir/lto-4r-d.o" "" \ ++ {dummy.c} "lto-4d.exe" "lto-4.out" "" "c"] \ + [list "LTO 5" \ + "-O2 -flto -fuse-linker-plugin tmpdir/lto-5.o" "" \ + {dummy.c} "lto-5.exe" "lto-5.out" "" "c"] \ ++ [list "LTO 10" \ ++ "-O2 -flto -fuse-linker-plugin tmpdir/lto-10.o" "" \ ++ {dummy.c} "lto-10.exe" "lto-10.out" "" "c"] \ + [list "LTO 11" \ + "-O -flto -fuse-linker-plugin tmpdir/liblto-11.a" "" \ + {dummy.c} "lto-11.exe" "lto-11.out" "" "c"] \ +@@ -378,6 +405,15 @@ if { [is_elf_format] && [check_lto_share + } + } + ++set testname "Build liblto-4.a" ++remote_file host delete "tmpdir/liblto-4.a" ++set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-4.a tmpdir/lto-4a.o tmpdir/lto-4b.o tmpdir/lto-4c.o"] ++if {![string match "" $catch_output]} { ++ unresolved $testname ++ restore_notify ++ return ++} ++ + set testname "Build liblto-11.a" + remote_file host delete "tmpdir/liblto-11.a" + set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"] +@@ -424,8 +460,30 @@ return + # Run "ld -r" to generate inputs for complex LTO tests. + run_dump_test "lto-3r" + remote_exec host "mv" "tmpdir/dump tmpdir/lto-3.o" ++run_dump_test "lto-4r-a" ++remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-a.o" ++run_dump_test "lto-4r-b" ++remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-b.o" ++run_dump_test "lto-4r-c" ++remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-c.o" ++run_dump_test "lto-4r-d" ++remote_exec host "mv" "tmpdir/dump tmpdir/lto-4r-d.o" + run_dump_test "lto-5r" + remote_exec host "mv" "tmpdir/dump tmpdir/lto-5.o" ++run_dump_test "lto-10r" ++remote_exec host "mv" "tmpdir/dump tmpdir/lto-10.o" ++set testname "nm mixed object" ++set lto_plugin [run_host_cmd "$CC" "-print-prog-name=liblto_plugin.so tmpdir/lto-10.o"] ++if { [ regexp "liblto_plugin.so" $lto_plugin ] } { ++ set exec_output [run_host_cmd "$NM" "--plugin $lto_plugin tmpdir/lto-10.o"] ++ if { [ regexp "T main" $exec_output ] } { ++ pass $testname ++ } { ++ fail $testname ++ } ++} { ++ fail $testname ++ } + + run_cc_link_tests $lto_link_symbol_tests + +--- /dev/null 2016-08-19 08:03:37.292222041 +0100 ++++ binutils-2.27/ld/testsuite/ld-plugin/lto-4a.c 2016-08-19 12:14:15.685818046 +0100 +@@ -0,0 +1,7 @@ ++extern void foo(void); ++ ++int main(void) ++{ ++ foo(); ++ return 0; ++} +--- /dev/null 2016-08-19 08:03:37.292222041 +0100 ++++ binutils-2.27/ld/testsuite/ld-plugin/lto-4b.c 2016-08-19 12:14:19.603842115 +0100 +@@ -0,0 +1,9 @@ ++#include ++ ++extern void bar (void); ++ ++void foo(void) ++{ ++ bar (); ++ printf ("hello foo\n"); ++} +--- /dev/null 2016-08-19 08:03:37.292222041 +0100 ++++ binutils-2.27/ld/testsuite/ld-plugin/lto-4c.c 2016-08-19 12:14:21.987856760 +0100 +@@ -0,0 +1,6 @@ ++#include ++ ++void bar (void) ++{ ++ printf ("hello bar\n"); ++} +--- /dev/null 2016-08-19 08:03:37.292222041 +0100 ++++ binutils-2.27/ld/testsuite/ld-plugin/lto-10a.c 2016-08-19 12:14:27.670891671 +0100 +@@ -0,0 +1,6 @@ ++extern int foo(void); ++ ++int main(void) ++{ ++ return foo(); ++} +--- /dev/null 2016-08-19 08:03:37.292222041 +0100 ++++ binutils-2.27/ld/testsuite/ld-plugin/lto-10b.c 2016-08-19 12:14:33.380926748 +0100 +@@ -0,0 +1,7 @@ ++#include ++ ++int foo(void) ++{ ++ printf ("hello\n"); ++ return 0; ++} diff --git a/SOURCES/binutils-2.27-revert-PLT-elision.patch b/SOURCES/binutils-2.27-revert-PLT-elision.patch new file mode 100644 index 0000000..3eb828f --- /dev/null +++ b/SOURCES/binutils-2.27-revert-PLT-elision.patch @@ -0,0 +1,76 @@ +diff -rup binutils.orig/bfd/elf32-i386.c binutils-2.27/bfd/elf32-i386.c +--- binutils.orig/bfd/elf32-i386.c 2017-05-17 11:22:32.393303573 +0100 ++++ binutils-2.27/bfd/elf32-i386.c 2017-05-17 11:25:33.097138811 +0100 +@@ -2322,8 +2322,7 @@ do_size: + if (use_plt_got + && h != NULL + && h->plt.refcount > 0 +- && (((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) +- || h->got.refcount > 0) ++ && h->got.refcount > 0 + && htab->plt_got == NULL) + { + /* Create the GOT procedure linkage table. */ +@@ -2672,16 +2671,6 @@ elf_i386_allocate_dynrelocs (struct elf_ + if PLT is used. */ + eh->func_pointer_refcount = 0; + +- if ((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) +- { +- /* Don't use the regular PLT for DF_BIND_NOW. */ +- h->plt.offset = (bfd_vma) -1; +- +- /* Use the GOT PLT. */ +- h->got.refcount = 1; +- eh->plt_got.refcount = 1; +- } +- + use_plt_got = eh->plt_got.refcount > 0; + + /* Make sure this symbol is output as a dynamic symbol. +diff -rup binutils.orig/bfd/elf64-x86-64.c binutils-2.27/bfd/elf64-x86-64.c +--- binutils.orig/bfd/elf64-x86-64.c 2017-05-17 11:22:32.396303537 +0100 ++++ binutils-2.27/bfd/elf64-x86-64.c 2017-05-17 11:26:00.250813521 +0100 +@@ -2722,8 +2722,7 @@ do_size: + if (use_plt_got + && h != NULL + && h->plt.refcount > 0 +- && (((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) +- || h->got.refcount > 0) ++ && h->got.refcount > 0 + && htab->plt_got == NULL) + { + /* Create the GOT procedure linkage table. */ +@@ -3094,16 +3093,6 @@ elf_x86_64_allocate_dynrelocs (struct el + if PLT is used. */ + eh->func_pointer_refcount = 0; + +- if ((info->flags & DF_BIND_NOW) && !h->pointer_equality_needed) +- { +- /* Don't use the regular PLT for DF_BIND_NOW. */ +- h->plt.offset = (bfd_vma) -1; +- +- /* Use the GOT PLT. */ +- h->got.refcount = 1; +- eh->plt_got.refcount = 1; +- } +- + use_plt_got = eh->plt_got.refcount > 0; + + /* Make sure this symbol is output as a dynamic symbol. +diff -rup binutils.orig/ld/testsuite/ld-i386/pr17689now.rd binutils-2.27/ld/testsuite/ld-i386/pr17689now.rd +--- binutils.orig/ld/testsuite/ld-i386/pr17689now.rd 2017-05-17 11:22:32.677300171 +0100 ++++ binutils-2.27/ld/testsuite/ld-i386/pr17689now.rd 2017-05-17 11:39:36.097021963 +0100 +@@ -1,4 +1,3 @@ +-#failif + #... + [0-9a-f ]+R_386_JUMP_SLOT +0+.* + #... +diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr17689now.rd binutils-2.27/ld/testsuite/ld-x86-64/pr17689now.rd +--- binutils.orig/ld/testsuite/ld-x86-64/pr17689now.rd 2017-05-17 11:22:32.734299489 +0100 ++++ binutils-2.27/ld/testsuite/ld-x86-64/pr17689now.rd 2017-05-17 11:39:53.071818174 +0100 +@@ -1,4 +1,3 @@ +-#failif + #... + [0-9a-f ]+R_X86_64_JUMP_SLOT +0+ +.* + #... diff --git a/SOURCES/binutils-2.28-DW_AT_export_symbols.patch b/SOURCES/binutils-2.28-DW_AT_export_symbols.patch new file mode 100644 index 0000000..e15b3d4 --- /dev/null +++ b/SOURCES/binutils-2.28-DW_AT_export_symbols.patch @@ -0,0 +1,14 @@ +--- binutils.orig/include/dwarf2.def 2017-07-20 09:05:22.616764282 +0100 ++++ binutils-2.28/include/dwarf2.def 2017-07-20 09:05:59.168330104 +0100 +@@ -310,6 +310,11 @@ DW_AT (DW_AT_enum_class, 0x6d) + DW_AT (DW_AT_linkage_name, 0x6e) + /* DWARF 5. */ + DW_AT (DW_AT_noreturn, 0x87) ++DW_AT (DW_AT_alignment, 0x88) ++DW_AT (DW_AT_export_symbols, 0x89) ++DW_AT (DW_AT_deleted, 0x8a) ++DW_AT (DW_AT_defaulted, 0x8b) ++DW_AT (DW_AT_loclists_base, 0x8c) + + DW_AT_DUP (DW_AT_lo_user, 0x2000) /* Implementation-defined range start. */ + DW_AT_DUP (DW_AT_hi_user, 0x3fff) /* Implementation-defined range end. */ diff --git a/SOURCES/binutils-2.28-aarch64-copy-relocs.patch b/SOURCES/binutils-2.28-aarch64-copy-relocs.patch new file mode 100644 index 0000000..6fdb056 --- /dev/null +++ b/SOURCES/binutils-2.28-aarch64-copy-relocs.patch @@ -0,0 +1,414 @@ +diff -rupN binutils.orig/bfd/elfnn-aarch64.c binutils-2.28/bfd/elfnn-aarch64.c +--- binutils.orig/bfd/elfnn-aarch64.c 2017-06-08 09:11:46.364977859 +0100 ++++ binutils-2.28/bfd/elfnn-aarch64.c 2017-06-08 09:15:46.901961364 +0100 +@@ -246,7 +246,7 @@ + || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC \ + || (R_TYPE) == BFD_RELOC_AARCH64_TLSDESC_OFF_G1) + +-#define ELIMINATE_COPY_RELOCS 0 ++#define ELIMINATE_COPY_RELOCS 1 + + /* Return size of a relocation entry. HTAB is the bfd's + elf_aarch64_link_hash_entry. */ +@@ -5152,12 +5152,25 @@ elfNN_aarch64_final_link_relocate (reloc + /* When generating a shared object or relocatable executable, these + relocations are copied into the output file to be resolved at + run time. */ +- if (((bfd_link_pic (info) == TRUE) +- || globals->root.is_relocatable_executable) +- && (input_section->flags & SEC_ALLOC) +- && (h == NULL +- || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT +- || h->root.type != bfd_link_hash_undefweak)) ++ if (((bfd_link_pic (info) ++ || globals->root.is_relocatable_executable) ++ && (input_section->flags & SEC_ALLOC) ++ && (h == NULL ++ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT ++ || h->root.type != bfd_link_hash_undefweak)) ++ /* Or we are creating an executable, we may need to keep relocations ++ for symbols satisfied by a dynamic library if we manage to avoid ++ copy relocs for the symbol. */ ++ || (ELIMINATE_COPY_RELOCS ++ && !bfd_link_pic (info) ++ && h != NULL ++ && (input_section->flags & SEC_ALLOC) ++ && h->dynindx != -1 ++ && !h->non_got_ref ++ && ((h->def_dynamic ++ && !h->def_regular) ++ || h->root.type == bfd_link_hash_undefweak ++ || h->root.type == bfd_link_hash_undefined))) + { + Elf_Internal_Rela outrel; + bfd_byte *loc; +@@ -6822,6 +6835,25 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, + return TRUE; + } + ++/* Return true if we have dynamic relocs against EH or any of its weak ++ aliases, that apply to read-only sections. */ ++ ++static bfd_boolean ++alias_readonly_dynrelocs (struct elf_aarch64_link_hash_entry *eh) ++{ ++ struct elf_dyn_relocs *p; ++ asection *s; ++ ++ for (p = eh->dyn_relocs; p != NULL; p = p->next) ++ { ++ s = p->sec->output_section; ++ if (s != NULL && (s->flags & SEC_READONLY) != 0) ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ + /* Adjust a symbol defined by a dynamic object and referenced by a + regular object. The current definition is in some section of the + dynamic object, but we're not including those sections. We have to +@@ -6895,6 +6927,19 @@ elfNN_aarch64_adjust_dynamic_symbol (str + return TRUE; + } + ++ if (ELIMINATE_COPY_RELOCS) ++ { ++ struct elf_aarch64_link_hash_entry *eh; ++ /* If we didn't find any dynamic relocs in read-only sections, then ++ we'll be keeping the dynamic relocs and avoiding the copy reloc. */ ++ eh = (struct elf_aarch64_link_hash_entry *) h; ++ if (eh->dyn_relocs && !alias_readonly_dynrelocs (eh)) ++ { ++ h->non_got_ref = 0; ++ return TRUE; ++ } ++ } ++ + /* We must allocate the symbol in our .dynbss section, which will + become part of the .bss section of the executable. There will be + an entry for this symbol in the .dynsym section. The dynamic +@@ -7167,7 +7212,16 @@ elfNN_aarch64_check_relocs (bfd *abfd, s + + /* No need to do anything if we're not creating a shared + object. */ +- if (! bfd_link_pic (info)) ++ if (!(bfd_link_pic (info) ++ /* If on the other hand, we are creating an executable, we ++ may need to keep relocations for symbols satisfied by a ++ dynamic library if we manage to avoid copy relocs for the ++ symbol. */ ++ || (ELIMINATE_COPY_RELOCS ++ && !bfd_link_pic (info) ++ && h != NULL ++ && (h->root.type == bfd_link_hash_defweak ++ || !h->def_regular)))) + break; + + { +diff -rupN binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp +--- binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-08 09:11:54.845871503 +0100 ++++ binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-08 09:16:34.984358379 +0100 +@@ -323,6 +323,8 @@ set aarch64elflinktests { + {} "copy-reloc-so.so"} + {"ld-aarch64/exe with copy relocation" "-e0 tmpdir/copy-reloc-so.so" "" "" + {copy-reloc-exe.s} {{objdump -R copy-reloc.d}} "copy-reloc"} ++ {"ld-aarch64/exe with copy relocation elimination" "-e0 tmpdir/copy-reloc-so.so" "" "" ++ {copy-reloc-exe-eliminate.s} {{objdump -R copy-reloc-eliminate.d}} "copy-reloc-elimination"} + } + + run_ld_link_tests $aarch64elflinktests +diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d +--- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-eliminate.d 2017-06-08 09:12:10.191679056 +0100 +@@ -0,0 +1,4 @@ ++.* ++DYNAMIC RELOCATION RECORDS ++OFFSET.*TYPE.*VALUE.* ++.*R_AARCH64_ABS64.*global_a +diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s +--- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-eliminate.s 2017-06-08 09:12:10.191679056 +0100 +@@ -0,0 +1,7 @@ ++ .global p ++ .section .data.rel.ro,"aw",%progbits ++ .align 3 ++ .type p, %object ++ .size p, 8 ++p: ++ .xword global_a +diff -rupN binutils.orig/bfd/elfnn-aarch64.c binutils-2.28/bfd/elfnn-aarch64.c +--- binutils.orig/bfd/elfnn-aarch64.c 2017-06-15 15:30:17.620175425 +0100 ++++ binutils-2.28/bfd/elfnn-aarch64.c 2017-06-15 15:31:21.415444817 +0100 +@@ -6812,15 +6812,22 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, + h->plt.refcount -= 1; + break; + ++ case BFD_RELOC_AARCH64_ADD_LO12: + case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: + case BFD_RELOC_AARCH64_ADR_HI21_PCREL: + case BFD_RELOC_AARCH64_ADR_LO21_PCREL: ++ case BFD_RELOC_AARCH64_LDST128_LO12: ++ case BFD_RELOC_AARCH64_LDST16_LO12: ++ case BFD_RELOC_AARCH64_LDST32_LO12: ++ case BFD_RELOC_AARCH64_LDST64_LO12: ++ case BFD_RELOC_AARCH64_LDST8_LO12: ++ case BFD_RELOC_AARCH64_LD_LO19_PCREL: + case BFD_RELOC_AARCH64_MOVW_G0_NC: + case BFD_RELOC_AARCH64_MOVW_G1_NC: + case BFD_RELOC_AARCH64_MOVW_G2_NC: + case BFD_RELOC_AARCH64_MOVW_G3: + case BFD_RELOC_AARCH64_NN: +- if (h != NULL && bfd_link_executable (info)) ++ if (h != NULL && !bfd_link_pic (info)) + { + if (h->plt.refcount > 0) + h->plt.refcount -= 1; +@@ -6835,18 +6842,24 @@ elfNN_aarch64_gc_sweep_hook (bfd *abfd, + return TRUE; + } + +-/* Return true if we have dynamic relocs against EH or any of its weak +- aliases, that apply to read-only sections. */ ++/* Return true if we need copy relocation against EH. */ + + static bfd_boolean +-alias_readonly_dynrelocs (struct elf_aarch64_link_hash_entry *eh) ++need_copy_relocation_p (struct elf_aarch64_link_hash_entry *eh) + { + struct elf_dyn_relocs *p; + asection *s; + + for (p = eh->dyn_relocs; p != NULL; p = p->next) + { ++ /* If there is any pc-relative reference, we need to keep copy relocation ++ to avoid propagating the relocation into runtime that current glibc ++ does not support. */ ++ if (p->pc_count) ++ return TRUE; ++ + s = p->sec->output_section; ++ /* Need copy relocation if it's against read-only section. */ + if (s != NULL && (s->flags & SEC_READONLY) != 0) + return TRUE; + } +@@ -6933,7 +6946,7 @@ elfNN_aarch64_adjust_dynamic_symbol (str + /* If we didn't find any dynamic relocs in read-only sections, then + we'll be keeping the dynamic relocs and avoiding the copy reloc. */ + eh = (struct elf_aarch64_link_hash_entry *) h; +- if (eh->dyn_relocs && !alias_readonly_dynrelocs (eh)) ++ if (!need_copy_relocation_p (eh)) + { + h->non_got_ref = 0; + return TRUE; +@@ -7194,6 +7207,41 @@ elfNN_aarch64_check_relocs (bfd *abfd, s + + switch (bfd_r_type) + { ++ case BFD_RELOC_AARCH64_MOVW_G0_NC: ++ case BFD_RELOC_AARCH64_MOVW_G1_NC: ++ case BFD_RELOC_AARCH64_MOVW_G2_NC: ++ case BFD_RELOC_AARCH64_MOVW_G3: ++ if (bfd_link_pic (info)) ++ { ++ int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; ++ _bfd_error_handler ++ /* xgettext:c-format */ ++ (_("%B: relocation %s against `%s' can not be used when making " ++ "a shared object; recompile with -fPIC"), ++ abfd, elfNN_aarch64_howto_table[howto_index].name, ++ (h) ? h->root.root.string : "a local symbol"); ++ bfd_set_error (bfd_error_bad_value); ++ return FALSE; ++ } ++ /* Fall through. */ ++ ++ case BFD_RELOC_AARCH64_16_PCREL: ++ case BFD_RELOC_AARCH64_32_PCREL: ++ case BFD_RELOC_AARCH64_64_PCREL: ++ case BFD_RELOC_AARCH64_ADD_LO12: ++ case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: ++ case BFD_RELOC_AARCH64_ADR_HI21_PCREL: ++ case BFD_RELOC_AARCH64_ADR_LO21_PCREL: ++ case BFD_RELOC_AARCH64_LDST128_LO12: ++ case BFD_RELOC_AARCH64_LDST16_LO12: ++ case BFD_RELOC_AARCH64_LDST32_LO12: ++ case BFD_RELOC_AARCH64_LDST64_LO12: ++ case BFD_RELOC_AARCH64_LDST8_LO12: ++ case BFD_RELOC_AARCH64_LD_LO19_PCREL: ++ if (h == NULL || bfd_link_pic (info)) ++ break; ++ /* Fall through. */ ++ + case BFD_RELOC_AARCH64_NN: + + /* We don't need to handle relocs into sections not going into +@@ -7216,7 +7264,17 @@ elfNN_aarch64_check_relocs (bfd *abfd, s + /* If on the other hand, we are creating an executable, we + may need to keep relocations for symbols satisfied by a + dynamic library if we manage to avoid copy relocs for the +- symbol. */ ++ symbol. ++ ++ NOTE: Currently, there is no support of copy relocs ++ elimination on pc-relative relocation types, because there is ++ no dynamic relocation support for them in glibc. We still ++ record the dynamic symbol reference for them. This is ++ because one symbol may be referenced by both absolute ++ relocation (for example, BFD_RELOC_AARCH64_NN) and ++ pc-relative relocation. We need full symbol reference ++ information to make correct decision later in ++ elfNN_aarch64_adjust_dynamic_symbol. */ + || (ELIMINATE_COPY_RELOCS + && !bfd_link_pic (info) + && h != NULL +@@ -7227,6 +7285,7 @@ elfNN_aarch64_check_relocs (bfd *abfd, s + { + struct elf_dyn_relocs *p; + struct elf_dyn_relocs **head; ++ int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; + + /* We must copy these reloc types into the output file. + Create a reloc section in dynobj and make room for +@@ -7290,6 +7349,8 @@ elfNN_aarch64_check_relocs (bfd *abfd, s + + p->count += 1; + ++ if (elfNN_aarch64_howto_table[howto_index].pc_relative) ++ p->pc_count += 1; + } + break; + +@@ -7393,44 +7454,6 @@ elfNN_aarch64_check_relocs (bfd *abfd, s + break; + } + +- case BFD_RELOC_AARCH64_MOVW_G0_NC: +- case BFD_RELOC_AARCH64_MOVW_G1_NC: +- case BFD_RELOC_AARCH64_MOVW_G2_NC: +- case BFD_RELOC_AARCH64_MOVW_G3: +- if (bfd_link_pic (info)) +- { +- int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; +- _bfd_error_handler +- /* xgettext:c-format */ +- (_("%B: relocation %s against `%s' can not be used when making " +- "a shared object; recompile with -fPIC"), +- abfd, elfNN_aarch64_howto_table[howto_index].name, +- (h) ? h->root.root.string : "a local symbol"); +- bfd_set_error (bfd_error_bad_value); +- return FALSE; +- } +- /* Fall through. */ +- +- case BFD_RELOC_AARCH64_ADR_HI21_NC_PCREL: +- case BFD_RELOC_AARCH64_ADR_HI21_PCREL: +- case BFD_RELOC_AARCH64_ADR_LO21_PCREL: +- if (h != NULL && bfd_link_executable (info)) +- { +- /* If this reloc is in a read-only section, we might +- need a copy reloc. We can't check reliably at this +- stage whether the section is read-only, as input +- sections have not yet been mapped to output sections. +- Tentatively set the flag for now, and correct in +- adjust_dynamic_symbol. */ +- h->non_got_ref = 1; +- h->plt.refcount += 1; +- h->pointer_equality_needed = 1; +- } +- /* FIXME:: RR need to handle these in shared libraries +- and essentially bomb out as these being non-PIC +- relocations in shared libraries. */ +- break; +- + case BFD_RELOC_AARCH64_CALL26: + case BFD_RELOC_AARCH64_JUMP26: + /* If this is a local symbol then we resolve it +diff -rupN binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp +--- binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-15 15:30:28.779047629 +0100 ++++ binutils-2.28/ld/testsuite/ld-aarch64/aarch64-elf.exp 2017-06-15 15:31:21.415444817 +0100 +@@ -323,6 +323,8 @@ set aarch64elflinktests { + {} "copy-reloc-so.so"} + {"ld-aarch64/exe with copy relocation" "-e0 tmpdir/copy-reloc-so.so" "" "" + {copy-reloc-exe.s} {{objdump -R copy-reloc.d}} "copy-reloc"} ++ {"ld-aarch64/exe with copy relocation 2" "-e0 tmpdir/copy-reloc-so.so" "" "" ++ {copy-reloc-exe-2.s} {{objdump -R copy-reloc-2.d}} "copy-reloc-2"} + {"ld-aarch64/exe with copy relocation elimination" "-e0 tmpdir/copy-reloc-so.so" "" "" + {copy-reloc-exe-eliminate.s} {{objdump -R copy-reloc-eliminate.d}} "copy-reloc-elimination"} + } +diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-2.d binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-2.d +--- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-2.d 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-2.d 2017-06-15 15:31:21.415444817 +0100 +@@ -0,0 +1,7 @@ ++.* ++DYNAMIC RELOCATION RECORDS ++OFFSET.*TYPE.*VALUE.* ++.*R_AARCH64_COPY.*global_[abcd] ++.*R_AARCH64_COPY.*global_[abcd] ++.*R_AARCH64_COPY.*global_[abcd] ++.*R_AARCH64_COPY.*global_[abcd] +diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s +--- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-exe-2.s 2017-06-15 15:31:21.415444817 +0100 +@@ -0,0 +1,32 @@ ++ # expect copy relocation for all these scenarios. ++ .global p ++ .global q ++ .global r ++ .section .data.rel.ro,"aw",%progbits ++ .align 3 ++ .type p, %object ++ .size p, 8 ++p: ++ .xword global_a ++ ++ .type q, %object ++ .size q, 8 ++q: ++ .xword global_b ++ ++ .type r, %object ++ .size r, 8 ++r: ++ # Any pc-rel relocation as no dynamic linker support on AArch64. ++ .xword global_c - . ++ ++ .text ++ .global main ++main: ++ # Symbols are referenced by any other relocation against read-only ++ # section. ++ movz x0, :abs_g0_nc:global_a ++ adrp x1, global_b ++ # pc-rel. ++ adrp x2, global_d ++ add x2, x2, #:lo12:global_c +diff -rupN binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-so.s binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-so.s +--- binutils.orig/ld/testsuite/ld-aarch64/copy-reloc-so.s 2017-06-15 15:30:28.781047606 +0100 ++++ binutils-2.28/ld/testsuite/ld-aarch64/copy-reloc-so.s 2017-06-15 15:31:21.415444817 +0100 +@@ -1,6 +1,25 @@ + .global global_a + .type global_a, %object + .size global_a, 4 ++ ++ .global global_b ++ .type global_b, %object ++ .size global_b, 4 ++ ++ .global global_c ++ .type global_c, %object ++ .size global_c, 4 ++ ++ .global global_d ++ .type global_d, %object ++ .size global_d, 4 ++ + .data + global_a: + .word 0xcafedead ++global_b: ++ .word 0xcafecafe ++global_c: ++ .word 0xdeadcafe ++global_d: ++ .word 0xdeaddead diff --git a/SOURCES/binutils-2.28-dynamic-section-warning.patch b/SOURCES/binutils-2.28-dynamic-section-warning.patch new file mode 100644 index 0000000..804286c --- /dev/null +++ b/SOURCES/binutils-2.28-dynamic-section-warning.patch @@ -0,0 +1,33 @@ +diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2017-03-20 17:06:41.260789454 +0000 ++++ binutils-2.28/binutils/readelf.c 2017-03-20 17:08:09.181289807 +0000 +@@ -4965,12 +4965,6 @@ process_program_headers (FILE * file) + section in the DYNAMIC segment. */ + dynamic_addr = segment->p_offset; + dynamic_size = segment->p_filesz; +- /* PR binutils/17512: Avoid corrupt dynamic section info in the segment. */ +- if (dynamic_addr + dynamic_size >= current_file_size) +- { +- error (_("the dynamic segment offset + size exceeds the size of the file\n")); +- dynamic_addr = dynamic_size = 0; +- } + + /* Try to locate the .dynamic section. If there is + a section header table, we can easily locate it. */ +@@ -5005,6 +4999,16 @@ process_program_headers (FILE * file) + warn (_("the .dynamic section is not the first section" + " in the dynamic segment.\n")); + } ++ ++ /* PR binutils/17512: Avoid corrupt dynamic section info in the ++ segment. Check this after matching against the section headers ++ so we don't warn on debuginfo file (which have NOBITS .dynamic ++ sections). */ ++ if (dynamic_addr + dynamic_size >= current_file_size) ++ { ++ error (_("the dynamic segment offset + size exceeds the size of the file\n")); ++ dynamic_addr = dynamic_size = 0; ++ } + break; + + case PT_INTERP: diff --git a/SOURCES/binutils-2.28-gas-comp_dir.patch b/SOURCES/binutils-2.28-gas-comp_dir.patch new file mode 100644 index 0000000..35a9c94 --- /dev/null +++ b/SOURCES/binutils-2.28-gas-comp_dir.patch @@ -0,0 +1,209 @@ +commit 49fced1206db40c71208c201165d65f92c69cebe +Author: Mark Wielaard +Date: Sun Mar 5 23:37:54 2017 +0100 + + gas: Emit name, comp_dir and producer strings in .debug_str. + + Putting the name, comp_dir and producer strings in the .debug_str section + makes it possible to share them across CUs. This saves a small amount of + space (about ~20K on a glibc libc.so.6 build with debuginfo). And makes + it easier for tools like rpm debugedit to adjust the source paths when + generating separate debuginfo files. + + gas/ + * dwarf2dbg.c (out_debug_abbrev): Use DW_FORM_strp instead of + DW_FORM_string for DW_AT_name, DW_AT_comp_dir and DW_AT_producer. + (out_debug_info): Accept symbols to name, comp_dir and producer + in the .debug_str section and emit those offsets not full strings. + (out_debug_str): New function that outputs the strings for name, + comp_dir and producer in .debug_str and generates symbols to + those strings. + (out_debug_line): Create a .debug_str section if necessary and + call out_debug_str before calling out_debug_info. + * testsuite/gas/aarch64/dwarf.d: Add extra section symbol to + expected output. + +diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c +index 4bb658b..e02b6e8 100644 +--- a/gas/dwarf2dbg.c ++++ b/gas/dwarf2dbg.c +@@ -1726,9 +1726,9 @@ out_debug_abbrev (segT abbrev_seg, + else + out_abbrev (DW_AT_ranges, DW_FORM_data8); + } +- out_abbrev (DW_AT_name, DW_FORM_string); +- out_abbrev (DW_AT_comp_dir, DW_FORM_string); +- out_abbrev (DW_AT_producer, DW_FORM_string); ++ out_abbrev (DW_AT_name, DW_FORM_strp); ++ out_abbrev (DW_AT_comp_dir, DW_FORM_strp); ++ out_abbrev (DW_AT_producer, DW_FORM_strp); + out_abbrev (DW_AT_language, DW_FORM_data2); + out_abbrev (0, 0); + +@@ -1739,15 +1739,11 @@ out_debug_abbrev (segT abbrev_seg, + /* Emit a description of this compilation unit for .debug_info. */ + + static void +-out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg) ++out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg, ++ symbolS *name_sym, symbolS *comp_dir_sym, symbolS *producer_sym) + { +- char producer[128]; +- const char *comp_dir; +- const char *dirname; + expressionS exp; + symbolS *info_end; +- char *p; +- int len; + int sizeof_offset; + + sizeof_offset = out_header (info_seg, &exp); +@@ -1798,10 +1794,38 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg) + TC_DWARF2_EMIT_OFFSET (section_symbol (ranges_seg), sizeof_offset); + } + ++ /* DW_AT_name, DW_AT_comp_dir and DW_AT_producer. Symbols in .debug_str ++ setup in out_debug_str below. */ ++ TC_DWARF2_EMIT_OFFSET (name_sym, sizeof_offset); ++ TC_DWARF2_EMIT_OFFSET (comp_dir_sym, sizeof_offset); ++ TC_DWARF2_EMIT_OFFSET (producer_sym, sizeof_offset); ++ ++ /* DW_AT_language. Yes, this is probably not really MIPS, but the ++ dwarf2 draft has no standard code for assembler. */ ++ out_two (DW_LANG_Mips_Assembler); ++ ++ symbol_set_value_now (info_end); ++} ++ ++/* Emit the three debug strings needed in .debug_str and setup symbols ++ to them for use in out_debug_info. */ ++static void ++out_debug_str (segT str_seg, symbolS **name_sym, symbolS **comp_dir_sym, ++ symbolS **producer_sym) ++{ ++ char producer[128]; ++ const char *comp_dir; ++ const char *dirname; ++ char *p; ++ int len; ++ ++ subseg_set (str_seg, 0); ++ + /* DW_AT_name. We don't have the actual file name that was present + on the command line, so assume files[1] is the main input file. + We're not supposed to get called unless at least one line number + entry was emitted, so this should always be defined. */ ++ *name_sym = symbol_temp_new_now (); + if (files_in_use == 0) + abort (); + if (files[1].dir) +@@ -1823,22 +1847,18 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg) + memcpy (p, files[1].filename, len); + + /* DW_AT_comp_dir */ ++ *comp_dir_sym = symbol_temp_new_now (); + comp_dir = remap_debug_filename (getpwd ()); + len = strlen (comp_dir) + 1; + p = frag_more (len); + memcpy (p, comp_dir, len); + + /* DW_AT_producer */ ++ *producer_sym = symbol_temp_new_now (); + sprintf (producer, "GNU AS %s", VERSION); + len = strlen (producer) + 1; + p = frag_more (len); + memcpy (p, producer, len); +- +- /* DW_AT_language. Yes, this is probably not really MIPS, but the +- dwarf2 draft has no standard code for assembler. */ +- out_two (DW_LANG_Mips_Assembler); +- +- symbol_set_value_now (info_end); + } + + void +@@ -1907,19 +1927,22 @@ dwarf2_finish (void) + out_debug_line (line_seg); + + /* If this is assembler generated line info, and there is no +- debug_info already, we need .debug_info and .debug_abbrev +- sections as well. */ ++ debug_info already, we need .debug_info, .debug_abbrev and ++ .debug_str sections as well. */ + if (emit_other_sections) + { + segT abbrev_seg; + segT aranges_seg; + segT ranges_seg; ++ segT str_seg; ++ symbolS *name_sym, *comp_dir_sym, *producer_sym; + + gas_assert (all_segs); + + info_seg = subseg_new (".debug_info", 0); + abbrev_seg = subseg_new (".debug_abbrev", 0); + aranges_seg = subseg_new (".debug_aranges", 0); ++ str_seg = subseg_new (".debug_str", 0); + + bfd_set_section_flags (stdoutput, info_seg, + SEC_READONLY | SEC_DEBUGGING); +@@ -1927,6 +1950,10 @@ dwarf2_finish (void) + SEC_READONLY | SEC_DEBUGGING); + bfd_set_section_flags (stdoutput, aranges_seg, + SEC_READONLY | SEC_DEBUGGING); ++ bfd_set_section_flags (stdoutput, str_seg, ++ (SEC_READONLY | SEC_DEBUGGING ++ | SEC_MERGE | SEC_STRINGS)); ++ str_seg->entsize = 1; + + record_alignment (aranges_seg, ffs (2 * sizeof_address) - 1); + +@@ -1943,6 +1970,8 @@ dwarf2_finish (void) + + out_debug_aranges (aranges_seg, info_seg); + out_debug_abbrev (abbrev_seg, info_seg, line_seg); +- out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg); ++ out_debug_str (str_seg, &name_sym, &comp_dir_sym, &producer_sym); ++ out_debug_info (info_seg, abbrev_seg, line_seg, ranges_seg, ++ name_sym, comp_dir_sym, producer_sym); + } + } +diff --git a/gas/testsuite/gas/aarch64/dwarf.d b/gas/testsuite/gas/aarch64/dwarf.d +index 005f1d5..2a75e0b 100644 +--- a/gas/testsuite/gas/aarch64/dwarf.d ++++ b/gas/testsuite/gas/aarch64/dwarf.d +@@ -1,7 +1,7 @@ + #readelf: -s --debug-dump=aranges + #as: -g + +-Symbol table '.symtab' contains 10 entries: ++Symbol table '.symtab' contains 11 entries: + Num:[ ]+Value[ ]+Size[ ]+Type[ ]+Bind[ ]+Vis[ ]+Ndx[ ]+Name + 0: 0+ 0 NOTYPE LOCAL DEFAULT UND[ ]+ + 1: 0+ 0 SECTION LOCAL DEFAULT 1[ ]+ +@@ -11,8 +11,9 @@ Symbol table '.symtab' contains 10 entries: + 5: 0+ 0 SECTION LOCAL DEFAULT 6[ ]+ + 6: 0+ 0 SECTION LOCAL DEFAULT 8[ ]+ + 7: 0+ 0 SECTION LOCAL DEFAULT 4[ ]+ +- 8: 0+ 0 SECTION LOCAL DEFAULT 9[ ]+ +- 9: 0+ 8 FUNC GLOBAL DEFAULT 1 testfunc ++ 8: 0+ 0 SECTION LOCAL DEFAULT 11[ ]+ ++ 9: 0+ 0 SECTION LOCAL DEFAULT 9[ ]+ ++ 10: 0+ 8 FUNC GLOBAL DEFAULT 1 testfunc + Contents of the .debug_aranges section: + + Length: (44|28) +--- binutils.orig/gas/config/tc-s390.c 2017-07-19 17:04:18.038524453 +0100 ++++ binutils-2.28/gas/config/tc-s390.c 2017-07-19 17:04:46.117211159 +0100 +@@ -2135,8 +2135,9 @@ md_pcrel_from_section (fixS *fixp, segT + int + tc_s390_fix_adjustable (fixS *fixP) + { +- /* Don't adjust references to merge sections. */ +- if ((S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_MERGE) != 0) ++ /* Don't adjust pc-relative references to merge sections. */ ++ if (fixP->fx_pcrel ++ && (S_GET_SEGMENT (fixP->fx_addsy)->flags & SEC_MERGE) != 0) + return 0; + /* adjust_reloc_syms doesn't know about the GOT. */ + if ( fixP->fx_r_type == BFD_RELOC_16_GOTOFF diff --git a/SOURCES/binutils-2.28-ignore-gold-duplicates.patch b/SOURCES/binutils-2.28-ignore-gold-duplicates.patch new file mode 100644 index 0000000..346f956 --- /dev/null +++ b/SOURCES/binutils-2.28-ignore-gold-duplicates.patch @@ -0,0 +1,14 @@ +diff -rup binutils.orig/ld/ldmain.c binutils-2.28/ld/ldmain.c +--- binutils.orig/ld/ldmain.c 2017-06-09 09:08:26.954016429 +0100 ++++ binutils-2.28/ld/ldmain.c 2017-06-09 09:09:11.307490976 +0100 +@@ -923,6 +923,10 @@ multiple_definition (struct bfd_link_inf + obfd = h->u.def.section->owner; + break; + case bfd_link_hash_indirect: ++ /* PR 21074: The GOLD linker can produce multiple indirect ++ refences to the same symbol. These can be ignored. */ ++ if (bfd_is_ind_section (nsec)) ++ return; + osec = bfd_ind_section_ptr; + oval = 0; + obfd = NULL; diff --git a/SOURCES/binutils-2.28-libiberty-bugfixes.patch b/SOURCES/binutils-2.28-libiberty-bugfixes.patch new file mode 100644 index 0000000..2b8723b --- /dev/null +++ b/SOURCES/binutils-2.28-libiberty-bugfixes.patch @@ -0,0 +1,104 @@ +diff -rup binutils-2.28/libiberty/configure /work/sources/binutils/current/libiberty/configure +--- binutils-2.28/libiberty/configure 2017-03-02 11:41:42.254309307 +0000 ++++ /work/sources/binutils/current/libiberty/configure 2017-01-04 16:01:24.944939339 +0000 +@@ -5097,7 +5097,7 @@ case "${host}" in + # If we are using a compiler supporting mdynamic-no-pic + # and the option has been tested as safe to add, then cancel + # it here, since the code generated is incompatible with shared +- # libs. ++ # libs. + *-mdynamic-no-pic*) PICFLAG='-fno-common -mno-dynamic-no-pic' ;; + *) PICFLAG=-fno-common ;; + esac +diff -rup binutils-2.28/libiberty/cp-demangle.c /work/sources/binutils/current/libiberty/cp-demangle.c +--- binutils-2.28/libiberty/cp-demangle.c 2017-03-02 08:28:19.000000000 +0000 ++++ /work/sources/binutils/current/libiberty/cp-demangle.c 2017-03-01 14:37:20.557586479 +0000 +@@ -2595,7 +2594,11 @@ cplus_demangle_type (struct d_info *di) + /* auto */ + ret = d_make_name (di, "auto", 4); + break; +- ++ case 'c': ++ /* decltype(auto) */ ++ ret = d_make_name (di, "decltype(auto)", 14); ++ break; ++ + case 'f': + /* 32-bit decimal floating point */ + ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[26]); +diff -rup binutils-2.28/libiberty/Makefile.in /work/sources/binutils/current/libiberty/Makefile.in +--- binutils-2.28/libiberty/Makefile.in 2016-12-23 08:40:18.000000000 +0000 ++++ /work/sources/binutils/current/libiberty/Makefile.in 2017-01-04 16:01:24.943939351 +0000 +@@ -1,9 +1,7 @@ + # Makefile for the libiberty library. + # Originally written by K. Richard Pixley . + # +-# Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, +-# 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, +-# 2012, 2014, 2015 Free Software Foundation ++# Copyright (C) 1990-2017 Free Software Foundation, Inc. + # + # This file is part of the libiberty library. + # Libiberty is free software; you can redistribute it and/or +@@ -484,7 +482,8 @@ configure_deps = $(srcdir)/aclocal.m4 \ + $(srcdir)/../config/acx.m4 \ + $(srcdir)/../config/no-executables.m4 \ + $(srcdir)/../config/override.m4 \ +- $(srcdir)/../config/warnings.m4 \ ++ $(srcdir)/../config/picflag.m4 \ ++ $(srcdir)/../config/warnings.m4 + + $(srcdir)/configure: @MAINT@ $(srcdir)/configure.ac $(configure_deps) + cd $(srcdir) && $(AUTOCONF) +diff -rup binutils-2.28/libiberty/strndup.c /work/sources/binutils/current/libiberty/strndup.c +--- binutils-2.28/libiberty/strndup.c 2013-11-04 15:33:40.000000000 +0000 ++++ /work/sources/binutils/current/libiberty/strndup.c 2017-01-04 16:01:24.950939263 +0000 +@@ -33,7 +33,7 @@ memory was available. The result is alw + #include "ansidecl.h" + #include + +-extern size_t strlen (const char*); ++extern size_t strnlen (const char *s, size_t maxlen); + extern PTR malloc (size_t); + extern PTR memcpy (PTR, const PTR, size_t); + +@@ -41,10 +41,7 @@ char * + strndup (const char *s, size_t n) + { + char *result; +- size_t len = strlen (s); +- +- if (n < len) +- len = n; ++ size_t len = strnlen (s, n); + + result = (char *) malloc (len + 1); + if (!result) +diff -rup binutils-2.28/libiberty/testsuite/demangle-expected /work/sources/binutils/current/libiberty/testsuite/demangle-expected +--- binutils-2.28/libiberty/testsuite/demangle-expected 2017-03-02 08:28:19.000000000 +0000 ++++ /work/sources/binutils/current/libiberty/testsuite/demangle-expected 2017-03-01 14:37:55.295138174 +0000 +@@ -4200,6 +4200,9 @@ decltype (new auto({parm#1})) f(int + _Z1fIiERDaRKT_S1_ + auto& f(int const&, int) + --format=gnu-v3 ++_Z1gIiEDcRKT_S0_ ++decltype(auto) g(int const&, int) ++--format=gnu-v3 + _Z1gILi1EEvR1AIXT_EER1BIXscbT_EE + void g<1>(A<1>&, B(1)>&) + --format=gnu-v3 +diff -rup binutils-2.28/libiberty/xstrndup.c /work/sources/binutils/current/libiberty/xstrndup.c +--- binutils-2.28/libiberty/xstrndup.c 2013-11-04 15:33:40.000000000 +0000 ++++ /work/sources/binutils/current/libiberty/xstrndup.c 2017-01-04 16:01:24.951939251 +0000 +@@ -48,10 +48,7 @@ char * + xstrndup (const char *s, size_t n) + { + char *result; +- size_t len = strlen (s); +- +- if (n < len) +- len = n; ++ size_t len = strnlen (s, n); + + result = XNEWVEC (char, len + 1); + diff --git a/SOURCES/binutils-2.28-ppc-dynamic-relocs.patch b/SOURCES/binutils-2.28-ppc-dynamic-relocs.patch new file mode 100644 index 0000000..2017dae --- /dev/null +++ b/SOURCES/binutils-2.28-ppc-dynamic-relocs.patch @@ -0,0 +1,15 @@ +--- binutils.orig/bfd/elf64-ppc.c 2017-03-08 15:44:25.132804697 +0000 ++++ binutils-2.28/bfd/elf64-ppc.c 2017-03-08 15:44:54.596440794 +0000 +@@ -14798,8 +14798,10 @@ ppc64_elf_relocate_section (bfd *output_ + break; + + if (bfd_link_pic (info) +- ? ((h != NULL && pc_dynrelocs (h)) +- || must_be_dyn_reloc (info, r_type)) ++ ? ((h == NULL ++ || h->dyn_relocs != NULL) ++ && ((h != NULL && pc_dynrelocs (h)) ++ || must_be_dyn_reloc (info, r_type))) + : (h != NULL + ? h->dyn_relocs != NULL + : ELF_ST_TYPE (sym->st_info) == STT_GNU_IFUNC)) diff --git a/SOURCES/binutils-2.28-ppc-extra-insns.patch b/SOURCES/binutils-2.28-ppc-extra-insns.patch new file mode 100644 index 0000000..582598d --- /dev/null +++ b/SOURCES/binutils-2.28-ppc-extra-insns.patch @@ -0,0 +1,494 @@ +diff -rupN binutils.orig/gas/testsuite/gas/ppc/power9.d binutils-2.28/gas/testsuite/gas/ppc/power9.d +--- binutils.orig/gas/testsuite/gas/ppc/power9.d 2017-06-26 15:56:01.251233778 +0100 ++++ binutils-2.28/gas/testsuite/gas/ppc/power9.d 2017-06-26 16:08:04.575813938 +0100 +@@ -312,8 +312,8 @@ Disassembly of section \.text: + .*: (f1 31 9d 6f|6f 9d 31 f1) xscvdphp vs41,vs51 + .*: (f1 58 a7 6f|6f a7 58 f1) xvcvhpsp vs42,vs52 + .*: (f1 79 af 6f|6f af 79 f1) xvcvsphp vs43,vs53 +-.*: (4c 60 00 04|04 00 60 4c) addpcis r3,0 +-.*: (4c 60 00 04|04 00 60 4c) addpcis r3,0 ++.*: (4c 60 00 04|04 00 60 4c) lnia r3 ++.*: (4c 60 00 04|04 00 60 4c) lnia r3 + .*: (4c 80 00 05|05 00 80 4c) addpcis r4,1 + .*: (4c 80 00 05|05 00 80 4c) addpcis r4,1 + .*: (4c bf ff c4|c4 ff bf 4c) addpcis r5,-2 +diff -rupN binutils.orig/opcodes/ppc-opc.c binutils-2.28/opcodes/ppc-opc.c +--- binutils.orig/opcodes/ppc-opc.c 2017-06-26 15:56:01.505230821 +0100 ++++ binutils-2.28/opcodes/ppc-opc.c 2017-06-26 16:02:19.865826399 +0100 +@@ -54,6 +54,7 @@ static long extract_bo (unsigned long, p + static unsigned long insert_boe (unsigned long, long, ppc_cpu_t, const char **); + static long extract_boe (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_esync (unsigned long, long, ppc_cpu_t, const char **); ++static long extract_esync (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_dcmxs (unsigned long, long, ppc_cpu_t, const char **); + static long extract_dcmxs (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_dxd (unsigned long, long, ppc_cpu_t, const char **); +@@ -65,6 +66,7 @@ static long extract_fxm (unsigned long, + static unsigned long insert_li20 (unsigned long, long, ppc_cpu_t, const char **); + static long extract_li20 (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_ls (unsigned long, long, ppc_cpu_t, const char **); ++static long extract_ls (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_mbe (unsigned long, long, ppc_cpu_t, const char **); + static long extract_mbe (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_mb6 (unsigned long, long, ppc_cpu_t, const char **); +@@ -76,12 +78,17 @@ static long extract_nsi (unsigned long, + static unsigned long insert_oimm (unsigned long, long, ppc_cpu_t, const char **); + static long extract_oimm (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_ral (unsigned long, long, ppc_cpu_t, const char **); ++static long extract_ral (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_ram (unsigned long, long, ppc_cpu_t, const char **); ++static long extract_ram (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_raq (unsigned long, long, ppc_cpu_t, const char **); ++static long extract_raq (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_ras (unsigned long, long, ppc_cpu_t, const char **); ++static long extract_ras (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_rbs (unsigned long, long, ppc_cpu_t, const char **); + static long extract_rbs (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_rbx (unsigned long, long, ppc_cpu_t, const char **); ++static long extract_rbx (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_rx (unsigned long, long, ppc_cpu_t, const char **); + static long extract_rx (unsigned long, ppc_cpu_t, int *); + static unsigned long insert_ry (unsigned long, long, ppc_cpu_t, const char **); +@@ -462,7 +469,7 @@ const struct powerpc_operand powerpc_ope + /* The LS or WC field in an X (sync or wait) form instruction. */ + #define LS LIA + 1 + #define WC LS +- { 0x3, 21, insert_ls, NULL, PPC_OPERAND_OPTIONAL }, ++ { 0x3, 21, insert_ls, extract_ls, PPC_OPERAND_OPTIONAL }, + + /* The ME field in an M form instruction. */ + #define ME LS + 1 +@@ -519,24 +526,24 @@ const struct powerpc_operand powerpc_ope + value restrictions. */ + #define RAQ RA0 + 1 + #define RAX RAQ +- { 0x1f, 16, insert_raq, NULL, PPC_OPERAND_GPR_0 }, ++ { 0x1f, 16, insert_raq, extract_raq, PPC_OPERAND_GPR_0 }, + + /* The RA field in a D or X form instruction which is an updating + load, which means that the RA field may not be zero and may not + equal the RT field. */ + #define RAL RAQ + 1 +- { 0x1f, 16, insert_ral, NULL, PPC_OPERAND_GPR_0 }, ++ { 0x1f, 16, insert_ral, extract_ral, PPC_OPERAND_GPR_0 }, + + /* The RA field in an lmw instruction, which has special value + restrictions. */ + #define RAM RAL + 1 +- { 0x1f, 16, insert_ram, NULL, PPC_OPERAND_GPR_0 }, ++ { 0x1f, 16, insert_ram, extract_ram, PPC_OPERAND_GPR_0 }, + + /* The RA field in a D or X form instruction which is an updating + store or an updating floating point load, which means that the RA + field may not be zero. */ + #define RAS RAM + 1 +- { 0x1f, 16, insert_ras, NULL, PPC_OPERAND_GPR_0 }, ++ { 0x1f, 16, insert_ras, extract_ras, PPC_OPERAND_GPR_0 }, + + /* The RA field of the tlbwe, dccci and iccci instructions, + which are optional. */ +@@ -557,7 +564,7 @@ const struct powerpc_operand powerpc_ope + /* The RB field in an lswx instruction, which has special value + restrictions. */ + #define RBX RBS + 1 +- { 0x1f, 11, insert_rbx, NULL, PPC_OPERAND_GPR }, ++ { 0x1f, 11, insert_rbx, extract_rbx, PPC_OPERAND_GPR }, + + /* The RB field of the dccci and iccci instructions, which are optional. */ + #define RBOPT RBX + 1 +@@ -580,6 +587,7 @@ const struct powerpc_operand powerpc_ope + which have special value restrictions. */ + #define RSQ RS + 1 + #define RTQ RSQ ++#define Q_MASK (1 << 21) + { 0x1e, 21, NULL, NULL, PPC_OPERAND_GPR }, + + /* The RS field of the tlbwe instruction, which is optional. */ +@@ -694,7 +702,7 @@ const struct powerpc_operand powerpc_ope + + /* The ESYNC field in an X (sync) form instruction. */ + #define ESYNC STRM + 1 +- { 0xf, 16, insert_esync, NULL, PPC_OPERAND_OPTIONAL }, ++ { 0xf, 16, insert_esync, extract_esync, PPC_OPERAND_OPTIONAL }, + + /* The SV field in a POWER SC form instruction. */ + #define SV ESYNC + 1 +@@ -1533,6 +1541,22 @@ insert_ls (unsigned long insn, + return insn | ((value & 0x3) << 21); + } + ++static long ++extract_ls (unsigned long insn, ++ ppc_cpu_t dialect, ++ int *invalid) ++{ ++ unsigned long lvalue = (insn >> 21) & 3; ++ ++ if (((insn >> 1) & 0x3ff) == 598) ++ { ++ unsigned long max_lvalue = (dialect & PPC_OPCODE_POWER4) ? 2 : 1; ++ if (lvalue > max_lvalue) ++ *invalid = 1; ++ } ++ return lvalue; ++} ++ + /* The 4-bit E field in a sync instruction that accepts 2 operands. + If ESYNC is non-zero, then the L field must be either 0 or 1 and + the complement of ESYNC-bit2. */ +@@ -1560,6 +1584,27 @@ insert_esync (unsigned long insn, + return insn | ((value & 0xf) << 16); + } + ++static long ++extract_esync (unsigned long insn, ++ ppc_cpu_t dialect, ++ int *invalid) ++{ ++ unsigned long ls = (insn >> 21) & 0x3; ++ unsigned long lvalue = (insn >> 16) & 0xf; ++ ++ if (lvalue == 0) ++ { ++ if (((dialect & PPC_OPCODE_E6500) != 0 && ls > 1) ++ || ((dialect & PPC_OPCODE_POWER9) != 0 && ls > 2)) ++ *invalid = 1; ++ } ++ else if ((ls & ~0x1) ++ || (((lvalue >> 1) & 0x1) ^ ls) == 0) ++ *invalid = 1; ++ ++ return lvalue; ++} ++ + /* The MB and ME fields in an M form instruction expressed as a single + operand which is itself a bitmask. The extraction function always + marks it as invalid, since we never want to recognize an +@@ -1743,6 +1788,19 @@ insert_ral (unsigned long insn, + return insn | ((value & 0x1f) << 16); + } + ++static long ++extract_ral (unsigned long insn, ++ ppc_cpu_t dialect ATTRIBUTE_UNUSED, ++ int *invalid) ++{ ++ long rtvalue = (insn >> 21) & 0x1f; ++ long ravalue = (insn >> 16) & 0x1f; ++ ++ if (rtvalue == ravalue || ravalue == 0) ++ *invalid = 1; ++ return ravalue; ++} ++ + /* The RA field in an lmw instruction, which has special value + restrictions. */ + +@@ -1757,6 +1815,19 @@ insert_ram (unsigned long insn, + return insn | ((value & 0x1f) << 16); + } + ++static long ++extract_ram (unsigned long insn, ++ ppc_cpu_t dialect ATTRIBUTE_UNUSED, ++ int *invalid) ++{ ++ unsigned long rtvalue = (insn >> 21) & 0x1f; ++ unsigned long ravalue = (insn >> 16) & 0x1f; ++ ++ if (ravalue >= rtvalue) ++ *invalid = 1; ++ return ravalue; ++} ++ + /* The RA field in the DQ form lq or an lswx instruction, which have special + value restrictions. */ + +@@ -1773,6 +1844,19 @@ insert_raq (unsigned long insn, + return insn | ((value & 0x1f) << 16); + } + ++static long ++extract_raq (unsigned long insn, ++ ppc_cpu_t dialect ATTRIBUTE_UNUSED, ++ int *invalid) ++{ ++ unsigned long rtvalue = (insn >> 21) & 0x1f; ++ unsigned long ravalue = (insn >> 16) & 0x1f; ++ ++ if (ravalue == rtvalue) ++ *invalid = 1; ++ return ravalue; ++} ++ + /* The RA field in a D or X form instruction which is an updating + store or an updating floating point load, which means that the RA + field may not be zero. */ +@@ -1788,6 +1872,18 @@ insert_ras (unsigned long insn, + return insn | ((value & 0x1f) << 16); + } + ++static long ++extract_ras (unsigned long insn, ++ ppc_cpu_t dialect ATTRIBUTE_UNUSED, ++ int *invalid) ++{ ++ unsigned long ravalue = (insn >> 16) & 0x1f; ++ ++ if (ravalue == 0) ++ *invalid = 1; ++ return ravalue; ++} ++ + /* The RB field in an X form instruction when it must be the same as + the RS field in the instruction. This is used for extended + mnemonics like mr. This operand is marked FAKE. The insertion +@@ -1829,6 +1925,19 @@ insert_rbx (unsigned long insn, + return insn | ((value & 0x1f) << 11); + } + ++static long ++extract_rbx (unsigned long insn, ++ ppc_cpu_t dialect ATTRIBUTE_UNUSED, ++ int *invalid) ++{ ++ unsigned long rtvalue = (insn >> 21) & 0x1f; ++ unsigned long rbvalue = (insn >> 11) & 0x1f; ++ ++ if (rbvalue == rtvalue) ++ *invalid = 1; ++ return rbvalue; ++} ++ + /* The SCI8 field is made up of SCL and {U,N}I8 fields. */ + static unsigned long + insert_sci8 (unsigned long insn, +@@ -2443,6 +2552,8 @@ extract_vleil (unsigned long insn, + /* An DX form instruction. */ + #define DX(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1)) + #define DX_MASK DX (0x3f, 0x1f) ++/* An DX form instruction with the D bits specified. */ ++#define NODX_MASK (DX_MASK | 0x1fffc1) + + /* An EVSEL form instruction. */ + #define EVSEL(op, xop) (OP (op) | (((unsigned long)(xop)) & 0xff) << 3) +@@ -4155,6 +4266,7 @@ const struct powerpc_opcode powerpc_opco + + {"mcrf", XL(19,0), XLBB_MASK|(3<<21)|(3<<16), COM, PPCVLE, {BF, BFA}}, + ++{"lnia", DX(19,2), NODX_MASK, POWER9, PPCVLE, {RT}}, + {"addpcis", DX(19,2), DX_MASK, POWER9, PPCVLE, {RT, DXD}}, + {"subpcis", DX(19,2), DX_MASK, POWER9, PPCVLE, {RT, NDXD}}, + +@@ -4974,7 +5086,7 @@ const struct powerpc_opcode powerpc_opco + + {"stdux", X(31,181), X_MASK, PPC64, 0, {RS, RAS, RB}}, + +-{"stqcx.", XRC(31,182,1), X_MASK, POWER8, 0, {RSQ, RA0, RB}}, ++{"stqcx.", XRC(31,182,1), X_MASK|Q_MASK, POWER8, 0, {RSQ, RA0, RB}}, + {"wchkall", X(31,182), X_MASK, PPCA2, 0, {OBF}}, + + {"stwux", X(31,183), X_MASK, PPCCOM, 0, {RS, RAS, RB}}, +@@ -5105,7 +5217,7 @@ const struct powerpc_opcode powerpc_opco + + {"mfapidi", X(31,275), X_MASK, BOOKE, E500|TITAN, {RT, RA}}, + +-{"lqarx", X(31,276), XEH_MASK, POWER8, 0, {RTQ, RAX, RBX, EH}}, ++{"lqarx", X(31,276), XEH_MASK|Q_MASK, POWER8, 0, {RTQ, RAX, RBX, EH}}, + + {"lscbx", XRC(31,277,0), X_MASK, M601, 0, {RT, RA, RB}}, + {"lscbx.", XRC(31,277,1), X_MASK, M601, 0, {RT, RA, RB}}, +@@ -6052,7 +6164,7 @@ const struct powerpc_opcode powerpc_opco + + {"lhbrx", X(31,790), X_MASK, COM, 0, {RT, RA0, RB}}, + +-{"lfdpx", X(31,791), X_MASK, POWER6, POWER7, {FRTp, RA0, RB}}, ++{"lfdpx", X(31,791), X_MASK|Q_MASK, POWER6, POWER7, {FRTp, RA0, RB}}, + {"lfqx", X(31,791), X_MASK, POWER2, 0, {FRT, RA, RB}}, + + {"sraw", XRC(31,792,0), X_MASK, PPCCOM, 0, {RA, RS, RB}}, +@@ -6167,7 +6279,7 @@ const struct powerpc_opcode powerpc_opco + + {"sthbrx", X(31,918), X_MASK, COM, 0, {RS, RA0, RB}}, + +-{"stfdpx", X(31,919), X_MASK, POWER6, POWER7, {FRSp, RA0, RB}}, ++{"stfdpx", X(31,919), X_MASK|Q_MASK, POWER6, POWER7, {FRSp, RA0, RB}}, + {"stfqx", X(31,919), X_MASK, POWER2, 0, {FRS, RA0, RB}}, + + {"sraq", XRC(31,920,0), X_MASK, M601, 0, {RA, RS, RB}}, +@@ -6345,13 +6457,13 @@ const struct powerpc_opcode powerpc_opco + + {"stfdu", OP(55), OP_MASK, COM, PPCEFS|PPCVLE, {FRS, D, RAS}}, + +-{"lq", OP(56), OP_MASK, POWER4, PPC476|PPCVLE, {RTQ, DQ, RAQ}}, ++{"lq", OP(56), OP_MASK|Q_MASK, POWER4, PPC476|PPCVLE, {RTQ, DQ, RAQ}}, + {"psq_l", OP(56), OP_MASK, PPCPS, PPCVLE, {FRT,PSD,RA,PSW,PSQ}}, + {"lfq", OP(56), OP_MASK, POWER2, PPCVLE, {FRT, D, RA0}}, + + {"lxsd", DSO(57,2), DS_MASK, PPCVSX3, PPCVLE, {VD, DS, RA0}}, + {"lxssp", DSO(57,3), DS_MASK, PPCVSX3, PPCVLE, {VD, DS, RA0}}, +-{"lfdp", OP(57), OP_MASK, POWER6, POWER7|PPCVLE, {FRTp, DS, RA0}}, ++{"lfdp", OP(57), OP_MASK|Q_MASK, POWER6, POWER7|PPCVLE, {FRTp, DS, RA0}}, + {"psq_lu", OP(57), OP_MASK, PPCPS, PPCVLE, {FRT,PSD,RA,PSW,PSQ}}, + {"lfqu", OP(57), OP_MASK, POWER2, PPCVLE, {FRT, D, RA0}}, + +@@ -6676,21 +6788,21 @@ const struct powerpc_opcode powerpc_opco + {"stxv", DQX(61,5), DQX_MASK, PPCVSX3, PPCVLE, {XSQ6, DQ, RA0}}, + {"stxsd", DSO(61,2), DS_MASK, PPCVSX3, PPCVLE, {VS, DS, RA0}}, + {"stxssp", DSO(61,3), DS_MASK, PPCVSX3, PPCVLE, {VS, DS, RA0}}, +-{"stfdp", OP(61), OP_MASK, POWER6, POWER7|PPCVLE, {FRSp, DS, RA0}}, ++{"stfdp", OP(61), OP_MASK|Q_MASK, POWER6, POWER7|PPCVLE, {FRSp, DS, RA0}}, + {"psq_stu", OP(61), OP_MASK, PPCPS, PPCVLE, {FRS,PSD,RA,PSW,PSQ}}, + {"stfqu", OP(61), OP_MASK, POWER2, PPCVLE, {FRS, D, RA}}, + + {"std", DSO(62,0), DS_MASK, PPC64, PPCVLE, {RS, DS, RA0}}, + {"stdu", DSO(62,1), DS_MASK, PPC64, PPCVLE, {RS, DS, RAS}}, +-{"stq", DSO(62,2), DS_MASK, POWER4, PPC476|PPCVLE, {RSQ, DS, RA0}}, ++{"stq", DSO(62,2), DS_MASK|Q_MASK, POWER4, PPC476|PPCVLE, {RSQ, DS, RA0}}, + + {"fcmpu", X(63,0), XBF_MASK, COM, PPCEFS|PPCVLE, {BF, FRA, FRB}}, + +-{"daddq", XRC(63,2,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, +-{"daddq.", XRC(63,2,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"daddq", XRC(63,2,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"daddq.", XRC(63,2,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, + +-{"dquaq", ZRC(63,3,0), Z2_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp, RMC}}, +-{"dquaq.", ZRC(63,3,1), Z2_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp, RMC}}, ++{"dquaq", ZRC(63,3,0), Z2_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp, RMC}}, ++{"dquaq.", ZRC(63,3,1), Z2_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp, RMC}}, + + {"xsaddqp", XRC(63,4,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, + {"xsaddqpo", XRC(63,4,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, +@@ -6772,11 +6884,11 @@ const struct powerpc_opcode powerpc_opco + + {"fcmpo", X(63,32), XBF_MASK, COM, PPCEFS|PPCVLE, {BF, FRA, FRB}}, + +-{"dmulq", XRC(63,34,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, +-{"dmulq.", XRC(63,34,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"dmulq", XRC(63,34,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"dmulq.", XRC(63,34,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, + +-{"drrndq", ZRC(63,35,0), Z2_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp, RMC}}, +-{"drrndq.", ZRC(63,35,1), Z2_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp, RMC}}, ++{"drrndq", ZRC(63,35,0), Z2_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp, RMC}}, ++{"drrndq.", ZRC(63,35,1), Z2_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp, RMC}}, + + {"xsmulqp", XRC(63,36,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, + {"xsmulqpo", XRC(63,36,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, +@@ -6791,11 +6903,11 @@ const struct powerpc_opcode powerpc_opco + + {"mcrfs", X(63,64), XRB_MASK|(3<<21)|(3<<16), COM, PPCVLE, {BF, BFA}}, + +-{"dscliq", ZRC(63,66,0), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, +-{"dscliq.", ZRC(63,66,1), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, ++{"dscliq", ZRC(63,66,0), Z_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, ++{"dscliq.", ZRC(63,66,1), Z_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, + +-{"dquaiq", ZRC(63,67,0), Z2_MASK, POWER6, PPCVLE, {TE, FRTp, FRBp, RMC}}, +-{"dquaiq.", ZRC(63,67,1), Z2_MASK, POWER6, PPCVLE, {TE, FRTp, FRBp, RMC}}, ++{"dquaiq", ZRC(63,67,0), Z2_MASK|Q_MASK, POWER6, PPCVLE, {TE, FRTp, FRBp, RMC}}, ++{"dquaiq.", ZRC(63,67,1), Z2_MASK|Q_MASK, POWER6, PPCVLE, {TE, FRTp, FRBp, RMC}}, + + {"mtfsb0", XRC(63,70,0), XRARB_MASK, COM, PPCVLE, {BT}}, + {"mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, PPCVLE, {BT}}, +@@ -6803,11 +6915,11 @@ const struct powerpc_opcode powerpc_opco + {"fmr", XRC(63,72,0), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}}, + {"fmr.", XRC(63,72,1), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}}, + +-{"dscriq", ZRC(63,98,0), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, +-{"dscriq.", ZRC(63,98,1), Z_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, ++{"dscriq", ZRC(63,98,0), Z_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, ++{"dscriq.", ZRC(63,98,1), Z_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, SH16}}, + +-{"drintxq", ZRC(63,99,0), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, +-{"drintxq.", ZRC(63,99,1), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, ++{"drintxq", ZRC(63,99,0), Z2_MASK|Q_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, ++{"drintxq.", ZRC(63,99,1), Z2_MASK|Q_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, + + {"xscpsgnqp", X(63,100), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, + +@@ -6839,11 +6951,11 @@ const struct powerpc_opcode powerpc_opco + {"dtstdcq", Z(63,194), Z_MASK, POWER6, PPCVLE, {BF, FRAp, DCM}}, + {"dtstdgq", Z(63,226), Z_MASK, POWER6, PPCVLE, {BF, FRAp, DGM}}, + +-{"drintnq", ZRC(63,227,0), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, +-{"drintnq.", ZRC(63,227,1), Z2_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, ++{"drintnq", ZRC(63,227,0), Z2_MASK|Q_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, ++{"drintnq.", ZRC(63,227,1), Z2_MASK|Q_MASK, POWER6, PPCVLE, {R, FRTp, FRBp, RMC}}, + +-{"dctqpq", XRC(63,258,0), X_MASK, POWER6, PPCVLE, {FRTp, FRB}}, +-{"dctqpq.", XRC(63,258,1), X_MASK, POWER6, PPCVLE, {FRTp, FRB}}, ++{"dctqpq", XRC(63,258,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRB}}, ++{"dctqpq.", XRC(63,258,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRB}}, + + {"fabs", XRC(63,264,0), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}}, + {"fabs.", XRC(63,264,1), XRA_MASK, COM, PPCEFS|PPCVLE, {FRT, FRB}}, +@@ -6851,8 +6963,8 @@ const struct powerpc_opcode powerpc_opco + {"dctfixq", XRC(63,290,0), X_MASK, POWER6, PPCVLE, {FRT, FRBp}}, + {"dctfixq.", XRC(63,290,1), X_MASK, POWER6, PPCVLE, {FRT, FRBp}}, + +-{"ddedpdq", XRC(63,322,0), X_MASK, POWER6, PPCVLE, {SP, FRTp, FRBp}}, +-{"ddedpdq.", XRC(63,322,1), X_MASK, POWER6, PPCVLE, {SP, FRTp, FRBp}}, ++{"ddedpdq", XRC(63,322,0), X_MASK|Q_MASK, POWER6, PPCVLE, {SP, FRTp, FRBp}}, ++{"ddedpdq.", XRC(63,322,1), X_MASK|Q_MASK, POWER6, PPCVLE, {SP, FRTp, FRBp}}, + + {"dxexq", XRC(63,354,0), X_MASK, POWER6, PPCVLE, {FRT, FRBp}}, + {"dxexq.", XRC(63,354,1), X_MASK, POWER6, PPCVLE, {FRT, FRBp}}, +@@ -6881,14 +6993,14 @@ const struct powerpc_opcode powerpc_opco + {"frim", XRC(63,488,0), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}}, + {"frim.", XRC(63,488,1), XRA_MASK, POWER5, PPCVLE, {FRT, FRB}}, + +-{"dsubq", XRC(63,514,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, +-{"dsubq.", XRC(63,514,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"dsubq", XRC(63,514,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"dsubq.", XRC(63,514,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, + + {"xssubqp", XRC(63,516,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, + {"xssubqpo", XRC(63,516,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, + +-{"ddivq", XRC(63,546,0), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, +-{"ddivq.", XRC(63,546,1), X_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"ddivq", XRC(63,546,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, ++{"ddivq.", XRC(63,546,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRAp, FRBp}}, + + {"xsdivqp", XRC(63,548,0), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, + {"xsdivqpo", XRC(63,548,1), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, +@@ -6917,11 +7029,11 @@ const struct powerpc_opcode powerpc_opco + {"mtfsf.", XFL(63,711,1), XFL_MASK, POWER6|PPCA2|PPC476, PPCVLE, {FLM, FRB, XFL_L, W}}, + {"mtfsf.", XFL(63,711,1), XFL_MASK, COM, POWER6|PPCA2|PPC476|PPCEFS|PPCVLE, {FLM, FRB}}, + +-{"drdpq", XRC(63,770,0), X_MASK, POWER6, PPCVLE, {FRTp, FRBp}}, +-{"drdpq.", XRC(63,770,1), X_MASK, POWER6, PPCVLE, {FRTp, FRBp}}, ++{"drdpq", XRC(63,770,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRBp}}, ++{"drdpq.", XRC(63,770,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRBp}}, + +-{"dcffixq", XRC(63,802,0), X_MASK, POWER6, PPCVLE, {FRTp, FRB}}, +-{"dcffixq.", XRC(63,802,1), X_MASK, POWER6, PPCVLE, {FRTp, FRB}}, ++{"dcffixq", XRC(63,802,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRB}}, ++{"dcffixq.", XRC(63,802,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRB}}, + + {"xsabsqp", XVA(63,804,0), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}}, + {"xsxexpqp", XVA(63,804,2), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}}, +@@ -6941,8 +7053,8 @@ const struct powerpc_opcode powerpc_opco + {"fctidz.", XRC(63,815,1), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}}, + {"fctidz.", XRC(63,815,1), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}}, + +-{"denbcdq", XRC(63,834,0), X_MASK, POWER6, PPCVLE, {S, FRTp, FRBp}}, +-{"denbcdq.", XRC(63,834,1), X_MASK, POWER6, PPCVLE, {S, FRTp, FRBp}}, ++{"denbcdq", XRC(63,834,0), X_MASK|Q_MASK, POWER6, PPCVLE, {S, FRTp, FRBp}}, ++{"denbcdq.", XRC(63,834,1), X_MASK|Q_MASK, POWER6, PPCVLE, {S, FRTp, FRBp}}, + + {"xscvqpuwz", XVA(63,836,1), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}}, + {"xscvudqp", XVA(63,836,2), XVA_MASK, PPCVSX3, PPCVLE, {VD, VB}}, +@@ -6961,8 +7073,8 @@ const struct powerpc_opcode powerpc_opco + {"fcfid.", XRC(63,846,1), XRA_MASK, PPC64, PPCVLE, {FRT, FRB}}, + {"fcfid.", XRC(63,846,1), XRA_MASK, PPC476, PPCVLE, {FRT, FRB}}, + +-{"diexq", XRC(63,866,0), X_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp}}, +-{"diexq.", XRC(63,866,1), X_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp}}, ++{"diexq", XRC(63,866,0), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp}}, ++{"diexq.", XRC(63,866,1), X_MASK|Q_MASK, POWER6, PPCVLE, {FRTp, FRA, FRBp}}, + + {"xsiexpqp", X(63,868), X_MASK, PPCVSX3, PPCVLE, {VD, VA, VB}}, + diff --git a/SOURCES/binutils-2.28-testsuite-failure-fixes.patch b/SOURCES/binutils-2.28-testsuite-failure-fixes.patch new file mode 100644 index 0000000..dd7824a --- /dev/null +++ b/SOURCES/binutils-2.28-testsuite-failure-fixes.patch @@ -0,0 +1,32 @@ +--- binutils.orig/ld/testsuite/ld-elf/elf.exp 2017-05-23 11:03:36.552764573 +0100 ++++ binutils-2.28/ld/testsuite/ld-elf/elf.exp 2017-05-23 11:13:48.419611868 +0100 +@@ -142,6 +142,10 @@ if { [check_shared_lib_support] } then { + {pr20995b.s} {} "pr20995.so"} + } + setup_xfail "tic6x-*-*" ++ # xfail on arm*-*-eabi*. The list can be enlarged to those targets that ++ # don't support GNU_RELRO. For more details, please see discussions at: ++ # https://sourceware.org/ml/binutils/2017-01/msg00441.html ++ setup_xfail "arm*-*-eabi*" "hppa*64*-*-hpux*" + run_ld_link_tests { + {"Build pr20995-2.so" + "-shared -z relro" "" "" +@@ -149,12 +153,17 @@ if { [check_shared_lib_support] } then { + } + # These targets don't copy dynamic variables into .bss. + setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" ++ # or don't have .data.rel.ro ++ setup_xfail "hppa*64*-*-hpux*" + run_ld_link_tests [list \ + [list \ + "pr20995" \ + "" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \ + {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]] +- setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" ++ # xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO. ++ # Please see the link above for details. ++ setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*" ++ setup_xfail "hppa*64*-*-hpux*" + run_ld_link_tests [list \ + [list \ + "pr20995-2" \ diff --git a/SOURCES/binutils-gnu-build-notes.patch b/SOURCES/binutils-gnu-build-notes.patch new file mode 100644 index 0000000..933cd82 --- /dev/null +++ b/SOURCES/binutils-gnu-build-notes.patch @@ -0,0 +1,1790 @@ +diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.28/binutils/doc/binutils.texi +--- binutils.orig/binutils/doc/binutils.texi 2017-03-20 17:03:56.166605442 +0000 ++++ binutils-2.28/binutils/doc/binutils.texi 2017-03-20 17:04:07.688408917 +0000 +@@ -1140,6 +1140,7 @@ objcopy [@option{-F} @var{bfdname}|@opti + [@option{--compress-debug-sections}] + [@option{--decompress-debug-sections}] + [@option{--elf-stt-common=@var{val}}] ++ [@option{--merge-notes}] + [@option{-v}|@option{--verbose}] + [@option{-V}|@option{--version}] + [@option{--help}] [@option{--info}] +@@ -1956,6 +1957,10 @@ converted to the @code{STT_COMMON} or @c + @code{STT_COMMON}. @option{--elf-stt-common=no} converts common symbol + type to @code{STT_OBJECT}. + ++@item --merge-notes ++For ELF files, attempt to reduce the size of any SHT_NOTE type ++sections by removing duplicate notes. ++ + @item -V + @itemx --version + Show the version number of @command{objcopy}. +diff -rup binutils.orig/binutils/NEWS binutils-2.28/binutils/NEWS +--- binutils.orig/binutils/NEWS 2017-03-20 17:03:56.167605425 +0000 ++++ binutils-2.28/binutils/NEWS 2017-03-20 17:04:07.688408917 +0000 +@@ -1,5 +1,8 @@ + -*- text -*- + ++* Add --merge-notes options to objcopy to reduce the size of notes in ++ a binary file by merging and deleting redundant notes. ++ + Changes in 2.28: + + * Add support for locating separate debug info files using the build-id +diff -rup binutils.orig/binutils/objcopy.c binutils-2.28/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2017-03-20 17:03:56.167605425 +0000 ++++ binutils-2.28/binutils/objcopy.c 2017-03-20 17:04:07.718408405 +0000 +@@ -30,6 +30,7 @@ + #include "elf-bfd.h" + #include "coff/internal.h" + #include "libcoff.h" ++#include "safe-ctype.h" + + /* FIXME: See bfd/peXXigen.c for why we include an architecture specific + header in generic PE code. */ +@@ -96,6 +97,10 @@ static bfd_boolean preserve_dates; /* Pr + static int deterministic = -1; /* Enable deterministic archives. */ + static int status = 0; /* Exit status. */ + ++static bfd_boolean merge_notes = FALSE; /* Merge note sections. */ ++static bfd_byte * merged_notes = NULL; /* Contents on note section undergoing a merge. */ ++static bfd_size_type merged_size = 0; /* New, smaller size of the merged note section. */ ++ + enum strip_action + { + STRIP_UNDEF, +@@ -315,6 +320,7 @@ enum command_line_switch + OPTION_LOCALIZE_HIDDEN, + OPTION_LOCALIZE_SYMBOLS, + OPTION_LONG_SECTION_NAMES, ++ OPTION_MERGE_NOTES, + OPTION_NO_CHANGE_WARNINGS, + OPTION_ONLY_KEEP_DEBUG, + OPTION_PAD_TO, +@@ -436,6 +442,7 @@ static struct option copy_options[] = + {"localize-symbol", required_argument, 0, 'L'}, + {"localize-symbols", required_argument, 0, OPTION_LOCALIZE_SYMBOLS}, + {"long-section-names", required_argument, 0, OPTION_LONG_SECTION_NAMES}, ++ {"merge-notes", no_argument, 0, 'M'}, + {"no-adjust-warnings", no_argument, 0, OPTION_NO_CHANGE_WARNINGS}, + {"no-change-warnings", no_argument, 0, OPTION_NO_CHANGE_WARNINGS}, + {"only-keep-debug", no_argument, 0, OPTION_ONLY_KEEP_DEBUG}, +@@ -634,6 +641,7 @@ copy_usage (FILE *stream, int exit_statu + --decompress-debug-sections Decompress DWARF debug sections using zlib\n\ + --elf-stt-common=[yes|no] Generate ELF common symbols with STT_COMMON\n\ + type\n\ ++ -M --merge-notes Remove redundant entries in note sections\n\ + -v --verbose List all object files modified\n\ + @ Read options from \n\ + -V --version Display this program's version number\n\ +@@ -1201,6 +1209,24 @@ is_update_section (bfd *abfd ATTRIBUTE_U + return FALSE; + } + ++static bfd_boolean ++is_merged_note_section (bfd * abfd, asection * sec) ++{ ++ if (merge_notes ++ && bfd_get_flavour (abfd) == bfd_target_elf_flavour ++ && elf_section_data (sec)->this_hdr.sh_type == SHT_NOTE ++ /* FIXME: We currently only support merging GNU_BUILD_NOTEs. ++ We should add support for more note types. */ ++ && ((elf_section_data (sec)->this_hdr.sh_flags & SHF_GNU_BUILD_NOTE) != 0 ++ /* Old versions of GAS (prior to 2.27) could not set the section ++ flags to OS-specific values, so we also accept sections with the ++ expected name. */ ++ || (strcmp (sec->name, GNU_BUILD_ATTRS_SECTION_NAME) == 0))) ++ return TRUE; ++ ++ return FALSE; ++} ++ + /* See if a non-group section is being removed. */ + + static bfd_boolean +@@ -1818,6 +1844,255 @@ copy_unknown_object (bfd *ibfd, bfd *obf + return TRUE; + } + ++/* Merge the notes on SEC, removing redundant entries. ++ Returns the new, smaller size of the section upon success. */ ++ ++static bfd_size_type ++merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte * contents) ++{ ++ Elf_Internal_Note * pnotes_end; ++ Elf_Internal_Note * pnotes; ++ Elf_Internal_Note * pnote; ++ bfd_size_type remain = size; ++ unsigned version_notes_seen = 0; ++ bfd_boolean duplicate_found = FALSE; ++ const char * err = NULL; ++ bfd_byte * in = contents; ++ ++ /* Make a copy of the notes. ++ Minimum size of a note is 12 bytes. */ ++ pnote = pnotes = (Elf_Internal_Note *) xmalloc ((size / 12) * sizeof (Elf_Internal_Note)); ++ while (remain >= 12) ++ { ++ pnote->namesz = (bfd_get_32 (abfd, in ) + 3) & ~3; ++ pnote->descsz = (bfd_get_32 (abfd, in + 4) + 3) & ~3; ++ pnote->type = bfd_get_32 (abfd, in + 8); ++ ++ if (pnote->type != NT_GNU_BUILD_ATTRIBUTE_OPEN ++ && pnote->type != NT_GNU_BUILD_ATTRIBUTE_FUNC) ++ { ++ err = _("corrupt GNU build attribute note: wrong note type"); ++ goto done; ++ } ++ ++ if (pnote->namesz + pnote->descsz + 12 > remain) ++ { ++ err = _("corrupt GNU build attribute note: note too big"); ++ goto done; ++ } ++ ++ if (pnote->namesz < 2) ++ { ++ err = _("corrupt GNU build attribute note: name too small"); ++ goto done; ++ } ++ ++ if (pnote->descsz != 0 ++ && pnote->descsz != 4 ++ && pnote->descsz != 8) ++ { ++ err = _("corrupt GNU build attribute note: bad description size"); ++ goto done; ++ } ++ ++ pnote->namedata = (char *)(in + 12); ++ pnote->descdata = (char *)(in + 12 + pnote->namesz); ++ ++ remain -= 12 + pnote->namesz + pnote->descsz; ++ in += 12 + pnote->namesz + pnote->descsz; ++ ++ if (pnote->namesz > 1 && pnote->namedata[1] == GNU_BUILD_ATTRIBUTE_VERSION) ++ ++ version_notes_seen; ++ pnote ++; ++ } ++ ++ pnotes_end = pnote; ++ ++ /* Check that the notes are valid. */ ++ if (remain != 0) ++ { ++ err = _("corrupt GNU build attribute notes: data at end"); ++ goto done; ++ } ++ ++ if (version_notes_seen == 0) ++ { ++ err = _("bad GNU build attribute notes: no version note"); ++ goto done; ++ } ++ ++ /* Merging is only needed if there is more than one version note... */ ++ if (version_notes_seen == 1) ++ goto done; ++ ++ /* The first note should be the first version note. */ ++ if (pnotes[0].namedata[1] != GNU_BUILD_ATTRIBUTE_VERSION) ++ { ++ err = _("bad GNU build attribute notes: first note not version note"); ++ goto done; ++ } ++ ++ if (pnotes[0].namedata[0] != GNU_BUILD_ATTRIBUTE_TYPE_STRING ++ || pnotes[0].namedata[2] != '1') ++ { ++ err = _("bad GNU build attribute notes: version note not v1"); ++ goto done; ++ } ++ ++ /* Now merge the notes. The rules are: ++ 1. Preserve the ordering of the notes. ++ 2. Preserve any NT_GNU_BUILD_ATTRIBUTE_FUNC notes. ++ 3. Eliminate any NT_GNU_BUILD_ATTRIBUTE_OPEN notes that have the same ++ full name field as the immediately preceeding note with the same type ++ of name. ++ 4. If an NT_GNU_BUILD_ATTRIBUTE_OPEN note is going to be preserved and ++ its description field is empty then the nearest preceeding OPEN note ++ with a non-empty description field must also be preserved *OR* the ++ description field of the note must be changed to contain the starting ++ address to which it refers. */ ++ for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++) ++ { ++ Elf_Internal_Note * back; ++ Elf_Internal_Note * prev_open = NULL; ++ ++ if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC) ++ continue; ++ ++ /* Scan for duplicates. Clear the type field of any found - but do not ++ delete them just yet. */ ++ for (back = pnote - 1; back >= pnotes; back --) ++ { ++ if (back->descsz > 0 ++ && back->type != NT_GNU_BUILD_ATTRIBUTE_FUNC ++ && prev_open == NULL) ++ prev_open = back; ++ ++ if (back->type == pnote->type ++ && back->namedata[1] == pnote->namedata[1]) ++ { ++ if (back->namesz == pnote->namesz ++ && memcmp (back->namedata, pnote->namedata, back->namesz) == 0) ++ { ++ duplicate_found = TRUE; ++ pnote->type = 0; ++ break; ++ } ++ ++ /* If we have found an attribute match then stop searching backwards. */ ++ if (! ISPRINT (back->namedata[1]) ++ || strcmp (back->namedata + 2, pnote->namedata + 2) == 0) ++ { ++ /* Since we are keeping this note we must check to see if its ++ description refers back to an earlier OPEN note. If so ++ then we must make sure that version note is also preserved. */ ++ if (pnote->descsz == 0 ++ && prev_open != NULL ++ && prev_open->type == 0) ++ prev_open->type = NT_GNU_BUILD_ATTRIBUTE_FUNC; ++ ++ break; ++ } ++ } ++ } ++ } ++ ++ if (duplicate_found) ++ { ++ bfd_byte * new_contents; ++ bfd_byte * old; ++ bfd_byte * new; ++ bfd_size_type new_size; ++ arelent ** relpp = NULL; ++ long relsize; ++ long relcount = 0; ++ ++ relsize = bfd_get_reloc_upper_bound (abfd, sec); ++ if (relsize > 0) ++ { ++ /* If there are relocs associated with this section then we may ++ have to adjust them as well, as we remove notes. */ ++ relpp = (arelent **) xmalloc (relsize); ++ relcount = bfd_canonicalize_reloc (abfd, sec, relpp, isympp); ++ if (relcount < 0) ++ /* Do not bother complaining here - copy_relocations_in_section ++ will do that for us. */ ++ relcount = 0; ++ } ++ ++ /* Eliminate the duplicates. */ ++ new = new_contents = xmalloc (size); ++ for (pnote = pnotes, old = contents; ++ pnote < pnotes_end; ++ pnote ++) ++ { ++ bfd_size_type note_size = 12 + pnote->namesz + pnote->descsz; ++ ++ if (pnote->type == 0) ++ { ++ if (relcount > 0) ++ { ++ arelent ** rel; ++ ++ /* If there is a reloc at the current offset, delete it. ++ Adjust the location of any relocs above the current ++ location downwards by the size of the note being deleted. ++ FIXME: We could optimize this loop by retaining a pointer to ++ the last reloc below the current note. */ ++ for (rel = relpp; rel < relpp + relcount; rel ++) ++ { ++ if ((* rel)->howto == NULL) ++ continue; ++ if ((* rel)->address < (bfd_vma) (new - new_contents)) ++ continue; ++ if ((* rel)->address >= (bfd_vma) ((new + note_size) - new_contents)) ++ (* rel)->address -= note_size; ++ else ++ (* rel)->howto = NULL; ++ } ++ } ++ } ++ else ++ { ++ memcpy (new, old, note_size); ++ new += note_size; ++ } ++ ++ old += note_size; ++ } ++ ++ new_size = new - new_contents; ++ memcpy (contents, new_contents, new_size); ++ size = new_size; ++ free (new_contents); ++ ++ if (relcount > 0) ++ { ++ arelent ** rel; ++ ++ for (rel = relpp; rel < relpp + relcount; rel ++) ++ if ((* rel)->howto == NULL) ++ { ++ /* Delete eliminated relocs. ++ FIXME: There are better ways to do this. */ ++ memmove (rel, rel + 1, ((relcount - (rel - relpp)) - 1) * sizeof (* rel)); ++ relcount --; ++ } ++ bfd_set_reloc (abfd, sec, relpp, relcount); ++ } ++ } ++ ++ done: ++ if (err) ++ { ++ bfd_set_error (bfd_error_bad_value); ++ bfd_nonfatal_message (NULL, abfd, sec, err); ++ status = 1; ++ } ++ ++ free (pnotes); ++ return size; ++} ++ + /* Copy object file IBFD onto OBFD. + Returns TRUE upon success, FALSE otherwise. */ + +@@ -2145,6 +2420,57 @@ copy_object (bfd *ibfd, bfd *obfd, const + } + } + ++ if (merge_notes) ++ { ++ asection *osec; ++ ++ /* This palaver is necessary because we must set the output ++ section size first, before its contents are ready. */ ++ osec = bfd_get_section_by_name (ibfd, GNU_BUILD_ATTRS_SECTION_NAME); ++ if (osec && is_merged_note_section (ibfd, osec)) ++ { ++ bfd_size_type size; ++ ++ size = bfd_get_section_size (osec); ++ if (size == 0) ++ { ++ bfd_nonfatal_message (NULL, ibfd, osec, _("warning: note section is empty")); ++ merge_notes = FALSE; ++ } ++ else if (! bfd_get_full_section_contents (ibfd, osec, & merged_notes)) ++ { ++ bfd_nonfatal_message (NULL, ibfd, osec, _("warning: could not load note section")); ++ free (merged_notes); ++ merged_notes = NULL; ++ merge_notes = FALSE; ++ } ++ else ++ { ++ merged_size = merge_gnu_build_notes (ibfd, osec, size, merged_notes); ++ if (merged_size == size) ++ { ++ /* Merging achieves nothing. */ ++ free (merged_notes); ++ merged_notes = NULL; ++ merge_notes = FALSE; ++ merged_size = 0; ++ } ++ else ++ { ++ if (osec->output_section == NULL ++ || ! bfd_set_section_size (obfd, osec->output_section, merged_size)) ++ { ++ bfd_nonfatal_message (NULL, obfd, osec, _("warning: failed to set merged notes size")); ++ free (merged_notes); ++ merged_notes = NULL; ++ merge_notes = FALSE; ++ merged_size = 0; ++ } ++ } ++ } ++ } ++ } ++ + if (dump_sections != NULL) + { + struct section_add * pdump; +@@ -2454,6 +2780,24 @@ copy_object (bfd *ibfd, bfd *obfd, const + } + } + ++ if (merge_notes) ++ { ++ asection * osec = bfd_get_section_by_name (obfd, GNU_BUILD_ATTRS_SECTION_NAME); ++ if (osec && is_merged_note_section (obfd, osec)) ++ { ++ if (! bfd_set_section_contents (obfd, osec, merged_notes, 0, merged_size)) ++ { ++ bfd_nonfatal_message (NULL, obfd, osec, _("error: failed to copy merged notes into output")); ++ return FALSE; ++ } ++ } ++ else ++ bfd_nonfatal_message (NULL, obfd, osec, _("ICE: lost merged note section")); ++ free (merged_notes); ++ merged_notes = NULL; ++ merge_notes = FALSE; ++ } ++ + if (gnu_debuglink_filename != NULL) + { + if (! bfd_fill_in_gnu_debuglink_section +@@ -3179,7 +3523,7 @@ setup_section (bfd *ibfd, sec_ptr isecti + /* Return TRUE if input section ISECTION should be skipped. */ + + static bfd_boolean +-skip_section (bfd *ibfd, sec_ptr isection) ++skip_section (bfd *ibfd, sec_ptr isection, bfd_boolean skip_copy) + { + sec_ptr osection; + bfd_size_type size; +@@ -3199,6 +3543,11 @@ skip_section (bfd *ibfd, sec_ptr isectio + if (is_update_section (ibfd, isection)) + return TRUE; + ++ /* When merging a note section we skip the copying of the contents, ++ but not the copying of the relocs associated with the contents. */ ++ if (skip_copy && is_merged_note_section (ibfd, isection)) ++ return TRUE; ++ + flags = bfd_get_section_flags (ibfd, isection); + if ((flags & SEC_GROUP) != 0) + return TRUE; +@@ -3265,7 +3614,7 @@ copy_relocations_in_section (bfd *ibfd, + long relcount; + sec_ptr osection; + +- if (skip_section (ibfd, isection)) ++ if (skip_section (ibfd, isection, FALSE)) + return; + + osection = isection->output_section; +@@ -3354,7 +3703,7 @@ copy_section (bfd *ibfd, sec_ptr isectio + sec_ptr osection; + bfd_size_type size; + +- if (skip_section (ibfd, isection)) ++ if (skip_section (ibfd, isection, TRUE)) + return; + + osection = isection->output_section; +@@ -4010,7 +4359,7 @@ copy_main (int argc, char *argv[]) + struct stat statbuf; + const bfd_arch_info_type *input_arch = NULL; + +- while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:N:s:O:d:F:L:G:R:SpgxXHhVvW:wDU", ++ while ((c = getopt_long (argc, argv, "b:B:i:I:j:K:MN:s:O:d:F:L:G:R:SpgxXHhVvW:wDU", + copy_options, (int *) 0)) != EOF) + { + switch (c) +@@ -4104,6 +4453,10 @@ copy_main (int argc, char *argv[]) + add_specific_symbol (optarg, keep_specific_htab); + break; + ++ case 'M': ++ merge_notes = TRUE; ++ break; ++ + case 'N': + add_specific_symbol (optarg, strip_specific_htab); + break; +diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2017-03-20 17:03:56.164605476 +0000 ++++ binutils-2.28/binutils/readelf.c 2017-03-20 17:06:13.368265213 +0000 +@@ -15557,6 +15557,10 @@ get_note_type (unsigned e_type) + return _("NT_VERSION (version)"); + case NT_ARCH: + return _("NT_ARCH (architecture)"); ++ case NT_GNU_BUILD_ATTRIBUTE_OPEN: ++ return _("NT_GNU_BUILD_ATTRIBUTE_OPEN"); ++ case NT_GNU_BUILD_ATTRIBUTE_FUNC: ++ return _("NT_GNU_BUILD_ATTRIBUTE_FUNC"); + default: + break; + } +@@ -15665,6 +15669,12 @@ get_gnu_elf_note_type (unsigned e_type) + return _("NT_GNU_BUILD_ID (unique build ID bitstring)"); + case NT_GNU_GOLD_VERSION: + return _("NT_GNU_GOLD_VERSION (gold version)"); ++ case NT_GNU_PROPERTY_TYPE_0: ++ return _("NT_GNU_PROPERTY_TYPE_0"); ++ case NT_GNU_BUILD_ATTRIBUTE_OPEN: ++ return _("NT_GNU_BUILD_ATTRIBUTE_OPEN"); ++ case NT_GNU_BUILD_ATTRIBUTE_FUNC: ++ return _("NT_GNU_BUILD_ATTRIBUTE_FUNC"); + default: + { + static char buff[64]; +@@ -15675,6 +15685,155 @@ get_gnu_elf_note_type (unsigned e_type) + } + } + ++static void ++decode_x86_isa (unsigned int bitmask) ++{ ++ while (bitmask) ++ { ++ unsigned int bit = bitmask & (- bitmask); ++ ++ bitmask &= ~ bit; ++ switch (bit) ++ { ++ case GNU_PROPERTY_X86_ISA_1_486: printf ("i486"); break; ++ case GNU_PROPERTY_X86_ISA_1_586: printf ("586"); break; ++ case GNU_PROPERTY_X86_ISA_1_686: printf ("686"); break; ++ case GNU_PROPERTY_X86_ISA_1_SSE: printf ("SSE"); break; ++ case GNU_PROPERTY_X86_ISA_1_SSE2: printf ("SSE2"); break; ++ case GNU_PROPERTY_X86_ISA_1_SSE3: printf ("SSE3"); break; ++ case GNU_PROPERTY_X86_ISA_1_SSSE3: printf ("SSSE3"); break; ++ case GNU_PROPERTY_X86_ISA_1_SSE4_1: printf ("SSE4_1"); break; ++ case GNU_PROPERTY_X86_ISA_1_SSE4_2: printf ("SSE4_2"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX: printf ("AVX"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX2: printf ("AVX2"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512F: printf ("AVX512F"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512CD: printf ("AVX512CD"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512ER: printf ("AVX512ER"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512PF: printf ("AVX512PF"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512VL: printf ("AVX512VL"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512DQ: printf ("AVX512DQ"); break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512BW: printf ("AVX512BW"); break; ++ default: printf (_(""), bit); break; ++ } ++ if (bitmask) ++ printf (", "); ++ } ++} ++ ++static void ++print_gnu_property_note (Elf_Internal_Note * pnote) ++{ ++ unsigned char * ptr = (unsigned char *) pnote->descdata; ++ unsigned char * ptr_end = ptr + pnote->descsz; ++ unsigned int size = is_32bit_elf ? 4 : 8; ++ ++ printf (_(" Properties: ")); ++ ++ if (pnote->descsz < 8 || (pnote->descsz % size) != 0) ++ { ++ printf (_("\n"), pnote->descsz); ++ return; ++ } ++ ++ while (1) ++ { ++ unsigned int j; ++ unsigned int type = byte_get (ptr, 4); ++ unsigned int datasz = byte_get (ptr + 4, 4); ++ ++ ptr += 8; ++ ++ if ((ptr + datasz) > ptr_end) ++ { ++ printf (_("\n"), ++ type, datasz); ++ break; ++ } ++ ++ if (type >= GNU_PROPERTY_LOPROC && type <= GNU_PROPERTY_HIPROC) ++ { ++ if (elf_header.e_machine == EM_X86_64 ++ || elf_header.e_machine == EM_IAMCU ++ || elf_header.e_machine == EM_386) ++ { ++ switch (type) ++ { ++ case GNU_PROPERTY_X86_ISA_1_USED: ++ printf ("x86 ISA used: "); ++ if (datasz != 4) ++ printf (_(" "), datasz); ++ else ++ decode_x86_isa (byte_get (ptr, 4)); ++ goto next; ++ ++ case GNU_PROPERTY_X86_ISA_1_NEEDED: ++ printf ("x86 ISA needed: "); ++ if (datasz != 4) ++ printf (_(" "), datasz); ++ else ++ decode_x86_isa (byte_get (ptr, 4)); ++ goto next; ++ ++ default: ++ break; ++ } ++ } ++ } ++ else ++ { ++ switch (type) ++ { ++ case GNU_PROPERTY_STACK_SIZE: ++ printf (_("stack size: ")); ++ if (datasz != size) ++ printf (_(" "), datasz); ++ else ++ printf ("%#lx", (unsigned long) byte_get (ptr, size)); ++ goto next; ++ ++ case GNU_PROPERTY_NO_COPY_ON_PROTECTED: ++ printf ("no copy on protected "); ++ if (datasz) ++ printf (_(" "), datasz); ++ goto next; ++ ++ default: ++ break; ++ } ++ } ++ ++ if (type < GNU_PROPERTY_LOPROC) ++ printf (_(""); ++ ++next: ++ ptr += ((datasz + (size - 1)) & ~ (size - 1)); ++ if (ptr == ptr_end) ++ break; ++ else ++ { ++ if (do_wide) ++ printf (", "); ++ else ++ printf ("\n\t"); ++ } ++ ++ if (ptr > (ptr_end - 8)) ++ { ++ printf (_("\n"), pnote->descsz); ++ break; ++ } ++ } ++ ++ printf ("\n"); ++} ++ + static int + print_gnu_note (Elf_Internal_Note *pnote) + { +@@ -15775,6 +15934,10 @@ print_gnu_note (Elf_Internal_Note *pnote + } + break; + ++ case NT_GNU_PROPERTY_TYPE_0: ++ print_gnu_property_note (pnote); ++ break; ++ + default: + /* Handle unrecognised types. An error message should have already been + created by get_gnu_elf_note_type(), so all that we need to do is to +@@ -16164,15 +16327,370 @@ print_ia64_vms_note (Elf_Internal_Note * + return 1; + } + ++/* Print the name of the symbol associated with a build attribute ++ that is attached to address OFFSET. */ ++ ++static bfd_boolean ++print_symbol_for_build_attribute (FILE * file, ++ unsigned long offset, ++ bfd_boolean is_open_attr) ++{ ++ static FILE * saved_file = NULL; ++ static char * strtab; ++ static unsigned long strtablen; ++ static Elf_Internal_Sym * symtab; ++ static unsigned long nsyms; ++ Elf_Internal_Sym * saved_sym = NULL; ++ Elf_Internal_Sym * sym; ++ ++ if (saved_file == NULL || file != saved_file) ++ { ++ Elf_Internal_Shdr * symsec; ++ ++ /* Load the symbol and string sections. */ ++ for (symsec = section_headers; ++ symsec < section_headers + elf_header.e_shnum; ++ symsec ++) ++ { ++ if (symsec->sh_type == SHT_SYMTAB) ++ { ++ symtab = GET_ELF_SYMBOLS (file, symsec, & nsyms); ++ ++ if (symsec->sh_link < elf_header.e_shnum) ++ { ++ Elf_Internal_Shdr * strtab_sec = section_headers + symsec->sh_link; ++ ++ strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset, ++ 1, strtab_sec->sh_size, ++ _("string table")); ++ strtablen = strtab != NULL ? strtab_sec->sh_size : 0; ++ } ++ } ++ } ++ saved_file = file; ++ } ++ ++ if (symtab == NULL || strtab == NULL) ++ { ++ printf ("\n"); ++ return FALSE; ++ } ++ ++ /* Find a symbol whose value matches offset. */ ++ for (sym = symtab; sym < symtab + nsyms; sym ++) ++ if (sym->st_value == offset) ++ { ++ if (sym->st_name >= strtablen) ++ /* Huh ? This should not happen. */ ++ continue; ++ ++ if (strtab[sym->st_name] == 0) ++ continue; ++ ++ if (is_open_attr) ++ { ++ /* For OPEN attributes we prefer GLOBAL over LOCAL symbols ++ and FILE or OBJECT symbols over NOTYPE symbols. We skip ++ FUNC symbols entirely. */ ++ switch (ELF_ST_TYPE (sym->st_info)) ++ { ++ case STT_FILE: ++ saved_sym = sym; ++ /* We can stop searching now. */ ++ sym = symtab + nsyms; ++ continue; ++ ++ case STT_OBJECT: ++ saved_sym = sym; ++ continue; ++ ++ case STT_FUNC: ++ /* Ignore function symbols. */ ++ continue; ++ ++ default: ++ break; ++ } ++ ++ switch (ELF_ST_BIND (sym->st_info)) ++ { ++ case STB_GLOBAL: ++ if (saved_sym == NULL ++ || ELF_ST_TYPE (saved_sym->st_info) != STT_OBJECT) ++ saved_sym = sym; ++ break; ++ ++ case STB_LOCAL: ++ if (saved_sym == NULL) ++ saved_sym = sym; ++ break; ++ ++ default: ++ break; ++ } ++ } ++ else ++ { ++ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) ++ continue; ++ ++ saved_sym = sym; ++ break; ++ } ++ } ++ ++ printf (" (%s: %s)\n", ++ is_open_attr ? _("file") : _("func"), ++ saved_sym ? strtab + saved_sym->st_name : _(")")); ++ return TRUE; ++} ++ ++static bfd_boolean ++print_gnu_build_attribute_description (Elf_Internal_Note * pnote, ++ FILE * file) ++{ ++ static unsigned long global_offset = 0; ++ unsigned long offset; ++ unsigned int desc_size = is_32bit_elf ? 4 : 8; ++ bfd_boolean is_open_attr = pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN; ++ ++ if (pnote->descsz == 0) ++ { ++ if (is_open_attr) ++ { ++ printf (_(" Applies from offset %#lx\n"), global_offset); ++ return TRUE; ++ } ++ else ++ { ++ printf (_(" Applies to func at %#lx"), global_offset); ++ return print_symbol_for_build_attribute (file, global_offset, is_open_attr); ++ } ++ } ++ ++ if (pnote->descsz != desc_size) ++ { ++ error (_(" \n"), pnote->descsz); ++ printf (_(" ")); ++ return FALSE; ++ } ++ ++ offset = byte_get ((unsigned char *) pnote->descdata, desc_size); ++ ++ if (is_open_attr) ++ { ++ printf (_(" Applies from offset %#lx"), offset); ++ global_offset = offset; ++ } ++ else ++ { ++ printf (_(" Applies to func at %#lx"), offset); ++ } ++ ++ return print_symbol_for_build_attribute (file, offset, is_open_attr); ++} ++ ++static bfd_boolean ++print_gnu_build_attribute_name (Elf_Internal_Note * pnote) ++{ ++ char name_type; ++ char name_attribute; ++ char * expected_types; ++ const char * name = pnote->namedata; ++ const char * text; ++ int left; ++ ++ if (name == NULL || pnote->namesz < 2) ++ { ++ error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote->namesz); ++ print_symbol (-20, _(" ")); ++ return FALSE; ++ } ++ ++ switch ((name_type = * name)) ++ { ++ case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: ++ case GNU_BUILD_ATTRIBUTE_TYPE_STRING: ++ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: ++ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: ++ printf ("%c", * name); ++ break; ++ default: ++ error (_("unrecognised attribute type in name field: %d\n"), name_type); ++ print_symbol (-20, _("")); ++ return FALSE; ++ } ++ ++ left = 19; ++ ++ name; ++ text = NULL; ++ ++ switch ((name_attribute = * name)) ++ { ++ case GNU_BUILD_ATTRIBUTE_VERSION: ++ text = _(""); ++ expected_types = "$"; ++ ++ name; ++ break; ++ case GNU_BUILD_ATTRIBUTE_STACK_PROT: ++ text = _(""); ++ expected_types = "!+*"; ++ ++ name; ++ break; ++ case GNU_BUILD_ATTRIBUTE_RELRO: ++ text = _(""); ++ expected_types = "!+"; ++ ++ name; ++ break; ++ case GNU_BUILD_ATTRIBUTE_STACK_SIZE: ++ text = _(""); ++ expected_types = "*"; ++ ++ name; ++ break; ++ case GNU_BUILD_ATTRIBUTE_TOOL: ++ text = _(""); ++ expected_types = "$"; ++ ++ name; ++ break; ++ case GNU_BUILD_ATTRIBUTE_ABI: ++ text = _(""); ++ expected_types = "$*"; ++ ++ name; ++ break; ++ case GNU_BUILD_ATTRIBUTE_PIC: ++ text = _(""); ++ expected_types = "*"; ++ ++ name; ++ break; ++ case GNU_BUILD_ATTRIBUTE_SHORT_ENUM: ++ text = _(""); ++ expected_types = "!+"; ++ ++ name; ++ break; ++ ++ default: ++ if (ISPRINT (* name)) ++ { ++ int len = strnlen (name, pnote->namesz - (name - pnote->namedata)) + 1; ++ ++ if (len > left && ! do_wide) ++ len = left; ++ printf ("%.*s:", len, name); ++ left -= len; ++ name += len; ++ } ++ else ++ { ++ error (_("unexpected character in name field\n")); ++ print_symbol (- left, _("")); ++ return 0; ++ } ++ expected_types = "*$!+"; ++ break; ++ } ++ ++ if (text) ++ { ++ printf ("%s", text); ++ left -= strlen (text); ++ } ++ ++ if (strchr (expected_types, name_type) == NULL) ++ warn (_("attribute does not have an expected type (%c)\n"), name_type); ++ ++ if ((unsigned long)(name - pnote->namedata) > pnote->namesz) ++ { ++ error (_("corrupt name field: namesz: %lu but parsing gets to %ld\n"), ++ (unsigned long) pnote->namesz, ++ (long) (name - pnote->namedata)); ++ return FALSE; ++ } ++ ++ if (left < 1 && ! do_wide) ++ return TRUE; ++ ++ switch (name_type) ++ { ++ case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: ++ { ++ unsigned int bytes = pnote->namesz - (name - pnote->namedata); ++ unsigned long val = 0; ++ unsigned int shift = 0; ++ char * decoded = NULL; ++ ++ while (bytes --) ++ { ++ unsigned long byte = (* name ++) & 0xff; ++ ++ val |= byte << shift; ++ shift += 8; ++ } ++ ++ switch (name_attribute) ++ { ++ case GNU_BUILD_ATTRIBUTE_PIC: ++ switch (val) ++ { ++ case 0: decoded = "static"; break; ++ case 1: decoded = "pic"; break; ++ case 2: decoded = "PIC"; break; ++ case 3: decoded = "pie"; break; ++ case 4: decoded = "PIE"; break; ++ default: break; ++ } ++ break; ++ case GNU_BUILD_ATTRIBUTE_STACK_PROT: ++ switch (val) ++ { ++ /* Based upon the SPCT_FLAG_xxx enum values in gcc/cfgexpand.c. */ ++ case 0: decoded = "off"; break; ++ case 1: decoded = "on"; break; ++ case 2: decoded = "all"; break; ++ case 3: decoded = "strong"; break; ++ case 4: decoded = "explicit"; break; ++ default: break; ++ } ++ break; ++ default: ++ break; ++ } ++ ++ if (decoded != NULL) ++ print_symbol (-left, decoded); ++ else ++ { ++ if (do_wide) ++ left -= printf ("0x%lx", val); ++ else ++ left -= printf ("0x%-.*lx", left, val); ++ } ++ } ++ break; ++ case GNU_BUILD_ATTRIBUTE_TYPE_STRING: ++ left -= print_symbol (- left, name); ++ break; ++ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE: ++ left -= print_symbol (- left, "true"); ++ break; ++ case GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE: ++ left -= print_symbol (- left, "false"); ++ break; ++ } ++ ++ if (do_wide && left > 0) ++ printf ("%-*s", left, " "); ++ ++ return TRUE; ++} ++ + /* Note that by the ELF standard, the name field is already null byte + terminated, and namesz includes the terminating null byte. + I.E. the value of namesz for the name "FSF" is 4. + + If the value of namesz is zero, there is no name present. */ + static int +-process_note (Elf_Internal_Note * pnote, +- FILE * file ATTRIBUTE_UNUSED, +- Elf_Internal_Shdr * section ATTRIBUTE_UNUSED) ++process_note (Elf_Internal_Note * pnote, ++ FILE * file) + { + const char * name = pnote->namesz ? pnote->namedata : "(NONE)"; + const char * nt; +@@ -16218,8 +16736,17 @@ process_note (Elf_Internal_Note * pnote, + nt = get_note_type (pnote->type); + + printf (" "); +- print_symbol (-20, name); +- printf (" 0x%08lx\t%s\n", pnote->descsz, nt); ++ ++ if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN ++ || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC) ++ print_gnu_build_attribute_name (pnote); ++ else ++ print_symbol (-20, name); ++ ++ if (do_wide) ++ printf (" 0x%08lx\t%s\t", pnote->descsz, nt); ++ else ++ printf (" 0x%08lx\t%s\n", pnote->descsz, nt); + + if (const_strneq (pnote->namedata, "IPF/VMS")) + return print_ia64_vms_note (pnote); +@@ -16229,17 +16756,22 @@ process_note (Elf_Internal_Note * pnote, + return print_stapsdt_note (pnote); + else if (const_strneq (pnote->namedata, "CORE")) + return print_core_note (pnote); ++ else if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN ++ || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC) ++ return print_gnu_build_attribute_description (pnote, file); + +- else if (pnote->descsz) ++ if (pnote->descsz) + { + unsigned long i; + + printf (_(" description data: ")); + for (i = 0; i < pnote->descsz; i++) + printf ("%02x ", pnote->descdata[i]); +- printf ("\n"); + } + ++ if (do_wide) ++ printf ("\n"); ++ + return 1; + } + +@@ -16369,14 +16901,14 @@ process_notes_at (FILE * fi + break; + } + +- strncpy (temp, inote.namedata, inote.namesz); ++ memcpy (temp, inote.namedata, inote.namesz); + temp[inote.namesz] = 0; + + /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */ + inote.namedata = temp; + } + +- res &= process_note (& inote, file, section); ++ res &= process_note (& inote, file); + + if (temp != NULL) + { +Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-32.d +Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-32.s +Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-64.d +Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-64.s +diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.28/binutils/testsuite/binutils-all/objcopy.exp +--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2017-03-20 17:03:56.174605306 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/objcopy.exp 2017-03-20 17:04:07.721408353 +0000 +@@ -1053,6 +1053,11 @@ if [is_elf_format] { + run_dump_test "group-6" + run_dump_test "copy-1" + run_dump_test "note-1" ++ if [is_elf64 tmpdir/bintest.o] { ++ run_dump_test "note-2-64" ++ } else { ++ run_dump_test "note-2-32" ++ } + } + + run_dump_test "copy-2" +diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h +--- binutils.orig/include/elf/common.h 2017-03-20 17:03:56.417601161 +0000 ++++ binutils-2.28/include/elf/common.h 2017-03-20 17:04:07.733408149 +0000 +@@ -538,6 +538,7 @@ + + /* #define SHF_MASKOS 0x0F000000 *//* OS-specific semantics */ + #define SHF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */ ++#define SHF_GNU_BUILD_NOTE (1 << 20) /* Section contains GNU BUILD ATTRIBUTE notes. */ + #define SHF_MASKPROC 0xF0000000 /* Processor-specific semantics */ + + /* This used to be implemented as a processor specific section flag. +@@ -669,6 +670,62 @@ + #define NT_GNU_HWCAP 2 /* Used by ld.so and kernel vDSO. */ + #define NT_GNU_BUILD_ID 3 /* Generated by ld --build-id. */ + #define NT_GNU_GOLD_VERSION 4 /* Generated by gold. */ ++#define NT_GNU_PROPERTY_TYPE_0 5 /* Generated by gcc. */ ++ ++#define NT_GNU_BUILD_ATTRIBUTE_OPEN 0x100 ++#define NT_GNU_BUILD_ATTRIBUTE_FUNC 0x101 ++ ++#define GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC '*' ++#define GNU_BUILD_ATTRIBUTE_TYPE_STRING '$' ++#define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE '+' ++#define GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE '!' ++ ++#define GNU_BUILD_ATTRIBUTE_VERSION 1 ++#define GNU_BUILD_ATTRIBUTE_STACK_PROT 2 ++#define GNU_BUILD_ATTRIBUTE_RELRO 3 ++#define GNU_BUILD_ATTRIBUTE_STACK_SIZE 4 ++#define GNU_BUILD_ATTRIBUTE_TOOL 5 ++#define GNU_BUILD_ATTRIBUTE_ABI 6 ++#define GNU_BUILD_ATTRIBUTE_PIC 7 ++#define GNU_BUILD_ATTRIBUTE_SHORT_ENUM 8 ++ ++#define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property" ++#define GNU_BUILD_ATTRS_SECTION_NAME ".gnu.build.attributes" ++ ++/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). */ ++#define GNU_PROPERTY_STACK_SIZE 1 ++#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2 ++ ++/* Processor-specific semantics, lo */ ++#define GNU_PROPERTY_LOPROC 0xc0000000 ++/* Processor-specific semantics, hi */ ++#define GNU_PROPERTY_HIPROC 0xdfffffff ++/* Application-specific semantics, lo */ ++#define GNU_PROPERTY_LOUSER 0xe0000000 ++/* Application-specific semantics, hi */ ++#define GNU_PROPERTY_HIUSER 0xffffffff ++ ++#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000 ++#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001 ++ ++#define GNU_PROPERTY_X86_ISA_1_486 (1U << 0) ++#define GNU_PROPERTY_X86_ISA_1_586 (1U << 1) ++#define GNU_PROPERTY_X86_ISA_1_686 (1U << 2) ++#define GNU_PROPERTY_X86_ISA_1_SSE (1U << 3) ++#define GNU_PROPERTY_X86_ISA_1_SSE2 (1U << 4) ++#define GNU_PROPERTY_X86_ISA_1_SSE3 (1U << 5) ++#define GNU_PROPERTY_X86_ISA_1_SSSE3 (1U << 6) ++#define GNU_PROPERTY_X86_ISA_1_SSE4_1 (1U << 7) ++#define GNU_PROPERTY_X86_ISA_1_SSE4_2 (1U << 8) ++#define GNU_PROPERTY_X86_ISA_1_AVX (1U << 9) ++#define GNU_PROPERTY_X86_ISA_1_AVX2 (1U << 10) ++#define GNU_PROPERTY_X86_ISA_1_AVX512F (1U << 11) ++#define GNU_PROPERTY_X86_ISA_1_AVX512CD (1U << 12) ++#define GNU_PROPERTY_X86_ISA_1_AVX512ER (1U << 13) ++#define GNU_PROPERTY_X86_ISA_1_AVX512PF (1U << 14) ++#define GNU_PROPERTY_X86_ISA_1_AVX512VL (1U << 15) ++#define GNU_PROPERTY_X86_ISA_1_AVX512DQ (1U << 16) ++#define GNU_PROPERTY_X86_ISA_1_AVX512BW (1U << 17) + + /* Values used in GNU .note.ABI-tag notes (NT_GNU_ABI_TAG). */ + #define GNU_ABI_TAG_LINUX 0 +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.s 2017-03-20 17:16:18.922951480 +0000 +@@ -0,0 +1,95 @@ ++ .text ++ .org 0x100 ++ .global note1.s ++note1.s: ++ .word 0 ++ ++ .pushsection .gnu.build.attributes, "0x100000", %note ++ .balign 4 ++ .dc.l 4 ++ .dc.l 4 ++ .dc.l 0x100 ++ .asciz "$1" ++ .dc.l note1.s ++ ++ .dc.l 12 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "$gcc 7.0.1" ++ ++ .dc.l 2 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2b, 0x2 ++ .dc.b 0, 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2a, 0x7, 0 ++ .dc.b 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2a, 0x6, 0 ++ .dc.b 0 ++ .popsection ++ ++ ++ .global note2.s ++note2.s: ++ .type func1, STT_FUNC ++func1: ++ .word 0x100 ++ ++ .pushsection .gnu.build.attributes, "0x100000", %note ++ .dc.l 4 ++ .dc.l 4 ++ .dc.l 0x100 ++ .asciz "$1" ++ .dc.l note2.s ++ ++ .dc.l 12 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "$gcc 7.0.1" ++ ++ .dc.l 2 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x21, 0x2 ++ .dc.b 0, 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x101 ++ .dc.b 0x2a, 0x7, 1 ++ .dc.b 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2a, 0x6, 0 ++ .dc.b 0 ++ .popsection ++ ++ .global note3.s ++note3.s: ++ .word 0x100 ++ ++ .pushsection .gnu.build.attributes, "0x100000", %note ++ .dc.l 4 ++ .dc.l 4 ++ .dc.l 0x100 ++ .asciz "$1" ++ .dc.l note3.s ++ ++ .dc.l 12 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "$gcc 7.0.1" ++ ++ .popsection ++ ++ +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.d 2017-03-20 17:16:18.922951480 +0000 +@@ -0,0 +1,17 @@ ++#PROG: objcopy ++#readelf: --notes --wide ++#objcopy: --merge-notes ++#name: merge notes section (32-bits) ++#source: note-2-32.s ++ ++#... ++ Owner Data size Description ++[ ]+\$1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note1.s\) ++[ ]+\$gcc 7.0.1[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\+true[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\*static[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\*0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\$1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\) ++[ ]+!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. ++[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\) ++#... +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.d 2017-03-20 17:16:18.922951480 +0000 +@@ -0,0 +1,17 @@ ++#PROG: objcopy ++#readelf: --notes --wide ++#objcopy: --merge-notes ++#name: merge notes section (64-bits) ++#source: note-2-64.s ++ ++#... ++ Owner Data size Description ++[ ]+\$1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 \(file: note1.s\) ++[ ]+\$gcc 7.0.1[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\+true[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\*static[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\*0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 ++[ ]+\$1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\) ++[ ]+!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. ++[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\) ++#... +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.s 2017-03-20 17:16:18.922951480 +0000 +@@ -0,0 +1,97 @@ ++ .text ++ .org 0x100 ++ .global note1.s ++note1.s: ++ .word 0 ++ ++ .pushsection .gnu.build.attributes, "0x100000", %note ++ .balign 4 ++ .dc.l 4 ++ .dc.l 8 ++ .dc.l 0x100 ++ .asciz "$1" ++ .8byte note1.s ++ ++ .dc.l 12 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "$gcc 7.0.1" ++ ++ .dc.l 2 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2b, 0x2 ++ .dc.b 0, 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2a, 0x7, 0 ++ .dc.b 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2a, 0x6, 0 ++ .dc.b 0 ++ .popsection ++ ++ ++ .global note2.s ++note2.s: ++ .global func1 ++ .type func1, STT_FUNC ++func1: ++ .word 0x100 ++ ++ .pushsection .gnu.build.attributes, "0x100000", %note ++ .dc.l 4 ++ .dc.l 8 ++ .dc.l 0x100 ++ .asciz "$1" ++ .8byte note2.s ++ ++ .dc.l 12 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "$gcc 7.0.1" ++ ++ .dc.l 2 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x21, 0x2 ++ .dc.b 0, 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x101 ++ .dc.b 0x2a, 0x7, 1 ++ .dc.b 0 ++ ++ .dc.l 3 ++ .dc.l 0 ++ .dc.l 0x100 ++ .dc.b 0x2a, 0x6, 0 ++ .dc.b 0 ++ .popsection ++ ++ ++ .global note3.s ++note3.s: ++ .word 0x100 ++ ++ .pushsection .gnu.build.attributes, "0x100000", %note ++ .dc.l 4 ++ .dc.l 8 ++ .dc.l 0x100 ++ .asciz "$1" ++ .8byte note3.s ++ ++ .dc.l 12 ++ .dc.l 0 ++ .dc.l 0x100 ++ .asciz "$gcc 7.0.1" ++ ++ .popsection ++ ++ +diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2017-05-15 17:12:12.760814593 +0100 ++++ binutils-2.28/binutils/readelf.c 2017-05-15 17:26:46.142293641 +0100 +@@ -4130,7 +4130,18 @@ get_section_type_name (unsigned int sh_t + if (elf_header.e_ident[EI_OSABI] == ELFOSABI_SOLARIS) + result = get_solaris_section_type (sh_type); + else +- result = NULL; ++ { ++ switch (sh_type) ++ { ++ case SHT_GNU_INCREMENTAL_INPUTS: result = "GNU_INCREMENTAL_INPUTS"; break; ++ case SHT_GNU_ATTRIBUTES: result = "GNU_ATTRIBUTES"; break; ++ case SHT_GNU_HASH: result = "GNU_HASH"; break; ++ case SHT_GNU_LIBLIST: result = "GNU_LIBLIST"; break; ++ default: ++ result = NULL; ++ break; ++ } ++ } + break; + } + +@@ -15928,8 +15939,8 @@ print_gnu_note (Elf_Internal_Note *pnote + printf (_(" Hardware Capabilities: ")); + if (pnote->descsz < 8) + { +- printf (_("\n")); +- break; ++ error (_("\n")); ++ return 0; + } + num_entries = byte_get ((unsigned char *) pnote->descdata, 4); + mask = byte_get ((unsigned char *) pnote->descdata + 4, 4); +@@ -16347,7 +16358,8 @@ print_symbol_for_build_attribute (FILE * + Elf_Internal_Sym * saved_sym = NULL; + Elf_Internal_Sym * sym; + +- if (saved_file == NULL || file != saved_file) ++ if (section_headers != NULL ++ && (saved_file == NULL || file != saved_file)) + { + Elf_Internal_Shdr * symsec; + +@@ -16497,9 +16509,12 @@ print_gnu_build_attribute_description (E + static bfd_boolean + print_gnu_build_attribute_name (Elf_Internal_Note * pnote) + { ++ static const char string_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_STRING, 0 }; ++ static const char number_expected [2] = { GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC, 0 }; ++ static const char bool_expected [3] = { GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE, GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE, 0 }; + char name_type; + char name_attribute; +- char * expected_types; ++ const char * expected_types; + const char * name = pnote->namedata; + const char * text; + int left; +@@ -16507,7 +16522,7 @@ print_gnu_build_attribute_name (Elf_Inte + if (name == NULL || pnote->namesz < 2) + { + error (_("corrupt name field in GNU build attribute note: size = %ld\n"), pnote->namesz); +- print_symbol (-20, _(" ")); ++ print_symbol (-20, _(" ")); + return FALSE; + } + +@@ -16533,7 +16548,7 @@ print_gnu_build_attribute_name (Elf_Inte + { + case GNU_BUILD_ATTRIBUTE_VERSION: + text = _(""); +- expected_types = "$"; ++ expected_types = string_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_STACK_PROT: +@@ -16543,17 +16558,17 @@ print_gnu_build_attribute_name (Elf_Inte + break; + case GNU_BUILD_ATTRIBUTE_RELRO: + text = _(""); +- expected_types = "!+"; ++ expected_types = bool_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_STACK_SIZE: + text = _(""); +- expected_types = "*"; ++ expected_types = number_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_TOOL: + text = _(""); +- expected_types = "$"; ++ expected_types = string_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_ABI: +@@ -16563,12 +16578,12 @@ print_gnu_build_attribute_name (Elf_Inte + break; + case GNU_BUILD_ATTRIBUTE_PIC: + text = _(""); +- expected_types = "*"; ++ expected_types = number_expected; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_SHORT_ENUM: + text = _(""); +- expected_types = "!+"; ++ expected_types = bool_expected; + ++ name; + break; + +@@ -16585,9 +16600,11 @@ print_gnu_build_attribute_name (Elf_Inte + } + else + { +- error (_("unexpected character in name field\n")); +- print_symbol (- left, _("")); +- return 0; ++ static char tmpbuf [128]; ++ error (_("unrecognised byte in name field: %d\n"), * name); ++ sprintf (tmpbuf, _(""), * name); ++ text = tmpbuf; ++ name ++; + } + expected_types = "*$!+"; + break; +@@ -16617,11 +16634,29 @@ print_gnu_build_attribute_name (Elf_Inte + { + case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: + { +- unsigned int bytes = pnote->namesz - (name - pnote->namedata); +- unsigned long val = 0; ++ unsigned int bytes; ++ unsigned long long val = 0; + unsigned int shift = 0; + char * decoded = NULL; + ++ bytes = pnote->namesz - (name - pnote->namedata); ++ if (bytes > 0) ++ /* The -1 is because the name field is always 0 terminated, and we ++ want to be able to ensure that the shift in the while loop below ++ will not overflow. */ ++ -- bytes; ++ ++ if (bytes > sizeof (val)) ++ { ++ fprintf (stderr, "namesz %lx name %p namedata %p\n", ++ pnote->namesz, name, pnote->namedata); ++ error (_("corrupt numeric name field: too many bytes in the value: %x\n"), ++ bytes); ++ bytes = sizeof (val); ++ } ++ /* We do not bother to warn if bytes == 0 as this can ++ happen with some early versions of the gcc plugin. */ ++ + while (bytes --) + { + unsigned long byte = (* name ++) & 0xff; +@@ -16660,13 +16695,21 @@ print_gnu_build_attribute_name (Elf_Inte + } + + if (decoded != NULL) +- print_symbol (-left, decoded); ++ { ++ print_symbol (-left, decoded); ++ left = 0; ++ } ++ else if (val == 0) ++ { ++ printf ("0x0"); ++ left -= 3; ++ } + else + { + if (do_wide) +- left -= printf ("0x%lx", val); ++ left -= printf ("0x%llx", val); + else +- left -= printf ("0x%-.*lx", left, val); ++ left -= printf ("0x%-.*llx", left, val); + } + } + break; +diff -rup binutils.orig/binutils/testsuite/binutils-all/note-2-32.s binutils-2.28/binutils/testsuite/binutils-all/note-2-32.s +--- binutils.orig/binutils/testsuite/binutils-all/note-2-32.s 2017-05-23 11:03:36.320767285 +0100 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.s 2017-05-23 11:04:48.851919399 +0100 +@@ -17,23 +17,21 @@ note1.s: + .dc.l 0x100 + .asciz "$gcc 7.0.1" + +- .dc.l 2 ++ .dc.l 3 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2b, 0x2 +- .dc.b 0, 0 ++ .dc.b 0x2b, 0x2, 0 ++ .dc.b 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x7, 0 +- .dc.b 0 ++ .dc.b 0x2a, 0x7, 0, 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0 +- .dc.b 0 ++ .dc.b 0x2a, 0x6, 0, 0 + .popsection + + +@@ -55,23 +53,21 @@ func1: + .dc.l 0x100 + .asciz "$gcc 7.0.1" + +- .dc.l 2 ++ .dc.l 3 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x21, 0x2 +- .dc.b 0, 0 ++ .dc.b 0x21, 0x2, 0 ++ .dc.b 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x101 +- .dc.b 0x2a, 0x7, 1 +- .dc.b 0 ++ .dc.b 0x2a, 0x7, 1, 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0 +- .dc.b 0 ++ .dc.b 0x2a, 0x6, 0, 0 + .popsection + + .global note3.s +@@ -91,5 +87,3 @@ note3.s: + .asciz "$gcc 7.0.1" + + .popsection +- +- +diff -rup binutils.orig/binutils/testsuite/binutils-all/note-2-64.s binutils-2.28/binutils/testsuite/binutils-all/note-2-64.s +--- binutils.orig/binutils/testsuite/binutils-all/note-2-64.s 2017-05-23 11:03:36.322767262 +0100 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.s 2017-05-23 11:05:15.333609830 +0100 +@@ -17,23 +17,21 @@ note1.s: + .dc.l 0x100 + .asciz "$gcc 7.0.1" + +- .dc.l 2 ++ .dc.l 3 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2b, 0x2 +- .dc.b 0, 0 ++ .dc.b 0x2b, 0x2, 0 ++ .dc.b 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x7, 0 +- .dc.b 0 ++ .dc.b 0x2a, 0x7, 0, 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0 +- .dc.b 0 ++ .dc.b 0x2a, 0x6, 0, 0 + .popsection + + +@@ -56,23 +54,21 @@ func1: + .dc.l 0x100 + .asciz "$gcc 7.0.1" + +- .dc.l 2 ++ .dc.l 3 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x21, 0x2 +- .dc.b 0, 0 ++ .dc.b 0x21, 0x2, 0 ++ .dc.b 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x101 +- .dc.b 0x2a, 0x7, 1 +- .dc.b 0 ++ .dc.b 0x2a, 0x7, 1, 0 + +- .dc.l 3 ++ .dc.l 4 + .dc.l 0 + .dc.l 0x100 +- .dc.b 0x2a, 0x6, 0 +- .dc.b 0 ++ .dc.b 0x2a, 0x6, 0, 0 + .popsection + + +@@ -93,5 +89,3 @@ note3.s: + .asciz "$gcc 7.0.1" + + .popsection +- +- diff --git a/SOURCES/binutils-rh1038339.patch b/SOURCES/binutils-rh1038339.patch new file mode 100644 index 0000000..26cb06d --- /dev/null +++ b/SOURCES/binutils-rh1038339.patch @@ -0,0 +1,50 @@ +diff -Nrup a/gas/doc/as.texinfo b/gas/doc/as.texinfo +--- a/gas/doc/as.texinfo 2013-02-27 15:28:03.000000000 -0500 ++++ b/gas/doc/as.texinfo 2013-12-11 13:18:39.401021599 -0500 +@@ -723,10 +723,12 @@ assembly. + Remove local absolute symbols from the outgoing symbol table. + + @item -v +-@itemx -version +-Print the @command{as} version. ++@itemx -verbose ++@itemx --verbose ++Print the @command{as} version and continue. + +-@item --version ++@item -version ++@itemx --version + Print the @command{as} version and exit. + + @item -W +@@ -2361,12 +2363,16 @@ For example, it disables the exception f + @section Announce Version: @option{-v} + + @kindex -v +-@kindex -version + @cindex assembler version + @cindex version of assembler + You can find out what version of as is running by including the +-option @samp{-v} (which you can also spell as @samp{-version}) on the +-command line. ++option @samp{-v} (which you can also spell as @samp{-verbose} or ++@samp{--verbose}) on the command line. ++ ++@section Announce Version and Exit: @option{-version} ++@kindex -version ++The @samp{-version} option (which you can also spell as @samp{--version}) ++prints the version of as and exits. + + @node W + @section Control Warnings: @option{-W}, @option{--warn}, @option{--no-warn}, @option{--fatal-warnings} +--- binutils-2.27.orig/gas/doc/as.texinfo 2016-07-18 09:12:45.299152360 +0100 ++++ binutils-2.27/gas/doc/as.texinfo 2016-07-18 09:13:08.637310883 +0100 +@@ -239,7 +239,7 @@ gcc(1), ld(1), and the Info entries for + [@b{-o} @var{objfile}] [@b{-R}] + [@b{--hash-size}=@var{NUM}] [@b{--reduce-memory-overheads}] + [@b{--statistics}] +- [@b{-v}] [@b{-version}] [@b{--version}] ++ [@b{-v}] [@b{-verbose}] [@b{--verbose}] [@b{-version}] [@b{--version}] + [@b{-W}] [@b{--warn}] [@b{--fatal-warnings}] [@b{-w}] [@b{-x}] + [@b{-Z}] [@b{@@@var{FILE}}] + [@b{--sectname-subst}] [@b{--size-check=[error|warning]}] diff --git a/SPECS/binutils.spec b/SPECS/binutils.spec new file mode 100644 index 0000000..e80b372 --- /dev/null +++ b/SPECS/binutils.spec @@ -0,0 +1,770 @@ +# rpmbuild parameters: +# --define "binutils_target arm-linux-gnu" to create arm-linux-gnu-binutils. +# --with=bootstrap: Build with minimal dependencies. +# --with=debug: Build without optimizations and without splitting the debuginfo. +# --without=docs: Skip building documentation. +# --without=testsuite: Do not run the testsuite. + +# For DTS-7 on RHEL-6 we only support x86 and x86_64. +# For DTS-7 on RHEL-7 we also support ppc64, ppc64le, s390x and aarch64 + +%{?scl:%{?scl_package:%scl_package binutils}} + +%if 0%{!?binutils_target:1} +%define binutils_target %{_target_platform} +%define isnative 1 +%define enable_shared 1 +%else +%define cross %{binutils_target}- +%define isnative 0 +%define enable_shared 0 +%endif +# Disable deterministic archives by default. +# This is for package builders who do not want to have to change +# their build scripts to work with deterministic archives. +%define enable_deterministic_archives 0 +# BZ 1342618: Enable support for GCC LTO compilation. +%define enable_lto 1 +# Disable the default generation of compressed debug sections. +%define default_compress_debug 0 + +# Default: Not bootstrapping. +%bcond_with bootstrap +# Default: Not debug +%bcond_with debug +# Default: Always build documentation. +%bcond_without docs +# Default: Always run the testsuite. +%bcond_without testsuite + +%if %{with bootstrap} +%undefine with_docs +%undefine with_testsuite +%endif + +%if %{with debug} +%undefine with_testsuite +%endif + +Summary: A GNU collection of binary utilities +Name: %{?scl_prefix}%{?cross}binutils%{?_with_debug:-debug} +Version: 2.28 +Release: 8%{?dist} +License: GPLv3+ +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. + +Source: http://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.bz2 + +Source2: binutils-2.19.50.0.1-output-format.sed + +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-sec-merge-emit.patch +# Enable -zrelro by default: BZ #621983 +Patch07: binutils-2.22.52.0.1-relro-on-by-default.patch +# Local patch - export demangle.h with the binutils-devel rpm. +Patch08: binutils-2.22.52.0.1-export-demangle.h.patch +# Disable checks that config.h has been included before system headers. BZ #845084 +Patch09: binutils-2.22.52.0.4-no-config-h-check.patch +# Fix detections little endian PPC shared libraries +Patch10: binutils-2.24-ldforcele.patch +# Import H.J.Lu's Kernel LTO patch. +Patch11: binutils-2.26-lto.patch +Patch12: binutils-2.23.51.0.3-Provide-std-tr1-hash.patch +Patch13: binutils-rh1038339.patch +Patch14: binutils-2.24-rh919508.patch +# Revert H.J.'s patch to elide PLT entries. +Patch15: binutils-2.27-revert-PLT-elision.patch +# Sync libiberty sources with FSF GCC mainline. +Patch16: binutils-2.28-libiberty-bugfixes.patch +# Add support for GNU BUILD NOTEs. +Patch17: binutils-gnu-build-notes.patch +# GAS: Emit name, comp_dir and producer strings in .debug_str. +Patch18: binutils-2.28-gas-comp_dir.patch +# Import fix for PR 21124 and 20519 +Patch19: binutils-2.28-ppc-dynamic-relocs.patch +# Have readelf skip checks of the dynamic section when its type is SHT_NOBITS. +Patch20: binutils-2.28-dynamic-section-warning.patch +# Fix some unexpected failures in the linker testsuite +Patch21: binutils-2.28-testsuite-failure-fixes.patch +# Fix the incorrect generation of copy relocs on AArch64. +Patch22: binutils-2.28-aarch64-copy-relocs.patch +# Ignore duplicate indirect symbols produced by GOLD. +Patch23: binutils-2.28-ignore-gold-duplicates.patch +# Add extra PowerPC instructions that were omitted from the 2.28 release. +Patch24: binutils-2.28-ppc-extra-insns.patch +# Add support for displaying new DWARF5 tags including DW_AT_export_symbols. +Patch25: binutils-2.28-DW_AT_export_symbols.patch + +Provides: bundled(libiberty) + +%define gold_arches %ix86 x86_64 %arm aarch64 + +%if %{with bootstrap} +%define build_gold no +%else +%ifarch %gold_arches +%define build_gold both +%else +%define build_gold no +%endif +%endif + +%define alternatives_cmd %{!?scl:%{_sbindir}}%{?scl:%{_root_sbindir}}/alternatives +%define alternatives_cmdline %{alternatives_cmd}%{?scl: --altdir %{_sysconfdir}/alternatives --admindir %{_scl_root}/var/lib/alternatives} + +%if %{with debug} +# Define this if you want to skip the strip step and preserve debug info. +# Useful for testing. +%define __debug_install_post : > %{_builddir}/%{?buildsubdir}/debugfiles.list +%define debug_package %{nil} +%endif + +Buildroot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) + +BuildRequires: gcc + +# Gold needs bison in order to build gold/yyscript.c. +# Bison needs m4. +%if "%{build_gold}" == "both" +BuildRequires: bison, m4, gcc-c++ +%endif + +%if %{without bootstrap} +BuildRequires: gettext, flex, zlib-devel +%endif + +%if %{with docs} +BuildRequires: texinfo >= 4.0 +# BZ 920545: We need pod2man in order to build the manual pages. +BuildRequires: /usr/bin/pod2man +Requires(post): /sbin/install-info +Requires(preun): /sbin/install-info +%endif + +# Required for: ld-bootstrap/bootstrap.exp bootstrap with --static +# It should not be required for: ld-elf/elf.exp static {preinit,init,fini} array +%if %{with testsuite} +# relro_test.sh uses dc which is part of the bc rpm, hence its inclusion here. +BuildRequires: dejagnu, zlib-static, glibc-static, sharutils, bc +%if "%{build_gold}" == "both" +# The GOLD testsuite needs a static libc++ +%if 0%{?rhel} >= 7 +BuildRequires: libstdc++-static +%endif +%endif +%endif + +Conflicts: gcc-c++ < 4.0.0 + +Requires(post): /sbin/install-info +Requires(preun): /sbin/install-info + +%{?scl:Requires:%scl_runtime} + +# The higher of these two numbers determines the default ld. +%{!?ld_bfd_priority: %global ld_bfd_priority 50} +%{!?ld_gold_priority:%global ld_gold_priority 30} + +%if "%{build_gold}" == "both" +Requires(post): coreutils +Requires(post): %{alternatives_cmd} +Requires(preun): %{alternatives_cmd} +%endif + +# On ARM EABI systems, we do want -gnueabi to be part of the +# target triple. +%ifnarch %{arm} +%define _gnu %{nil} +%endif + +%description +Binutils is a collection of binary utilities, including ar (for +creating, modifying and extracting from archives), as (a family of GNU +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 devel +Summary: BFD and opcodes static and dynamic libraries and header files +Group: System Environment/Libraries +# Note, this provide: +# Provides: binutils-static = %{version}-%{release} +# has been suppressed so that the DTS version does not provide +# a version of the binutils that another package cannot use. +# See: https://bugzilla.redhat.com/show_bug.cgi?id=1485002 +# for more details. +%if %{with docs} +Requires(post): /sbin/install-info +Requires(preun): /sbin/install-info +%endif +Requires: zlib-devel +Requires: %{?scl_prefix}binutils = %{version}-%{release} +# BZ 1215242: We need touch... +Requires: coreutils + +%description devel +This package contains BFD and opcodes static and dynamic libraries. + +The dynamic libraries are in this package, rather than a seperate +base package because they are actually linker scripts that force +the use of the static libraries. This is because the API of the +BFD library is too unstable to be used dynamically. + +The static libraries are here because they are now needed by the +dynamic libraries. + +Developers starting new projects are strongly encouraged to consider +using libelf instead of BFD. + +%prep +%setup -q -n binutils-%{version} +%patch01 -p1 -b .libtool-lib64~ +%patch02 -p1 -b .ppc64-pie~ +%ifarch ia64 +%if "%{_lib}" == "lib64" +%patch03 -p1 -b .ia64-lib64~ +%endif +%endif +%patch04 -p1 -b .version~ +%patch05 -p1 -b .set-long-long~ +%patch06 -p1 -b .sec-merge-emit~ +%if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 +%patch07 -p1 -b .relro~ +%endif +%patch08 -p1 -b .export-demangle-h~ +%patch09 -p1 -b .no-config-h-check~ +%ifarch ppc64le +%patch10 -p1 -b .ldforcele~ +%endif +%patch11 -p1 -b .kernel-lto~ +%patch12 -p1 -b .provide-hash~ +%patch13 -p1 -b .manpage~ +%patch14 -p1 +%patch15 -p1 +%patch16 -p1 +%patch17 -p1 +%patch18 -p1 +%patch19 -p1 +%patch20 -p1 +%patch21 -p1 +%patch22 -p1 +%patch23 -p1 +%patch24 -p1 +%patch25 -p1 + +# We cannot run autotools as there is an exact requirement of autoconf-2.59. + +# On ppc64 and aarch64, we might use 64KiB pages +sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*ppc.c +sed -i -e '/#define.*ELF_COMMONPAGESIZE/s/0x1000$/0x10000/' bfd/elf*aarch64.c +sed -i -e '/common_pagesize/s/4 /64 /' gold/powerpc.cc +sed -i -e '/pagesize/s/0x1000,/0x10000,/' gold/aarch64.cc +# 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 +# Touch the .info files so that they are newer then the .texi files and +# hence do not need to be rebuilt. This eliminates the need for makeinfo. +# The -print is there just to confirm that the command is working. +%if %{without docs} + find . -name *.info -print -exec touch {} \; +%endif + +%ifarch %{power64} +%define _target_platform %{_arch}-%{_vendor}-%{_host_os} +%endif + +%build +echo target is %{binutils_target} +%ifarch %{power64} +#CFLAGS=`echo $RPM_OPT_FLAGS | sed -e -s "s/-Werror//g"` +#export CFLAGS +export CFLAGS="$RPM_OPT_FLAGS -Wno-error" +%else +export CFLAGS="$RPM_OPT_FLAGS" +%endif +CARGS= + +case %{binutils_target} in i?86*|sparc*|ppc*|s390*|sh*|arm*|aarch64*) + CARGS="$CARGS --enable-64-bit-bfd" + ;; +esac + +case %{binutils_target} in ia64*) + CARGS="$CARGS --enable-targets=i386-linux" + ;; +esac + +case %{binutils_target} in ppc*|ppc64*) + CARGS="$CARGS --enable-targets=spu" + ;; +esac + +case %{binutils_target} in ppc64-*) + CARGS="$CARGS --enable-targets=powerpc64le-linux" + ;; +esac + +case %{binutils_target} in ppc64le*) + CARGS="$CARGS --enable-targets=powerpc-linux" + ;; +esac + +case %{binutils_target} in x86_64*|i?86*|arm*|aarch64*) + CARGS="$CARGS --enable-targets=x86_64-pep" + ;; +esac + +%if 0%{?_with_debug:1} +CFLAGS="$CFLAGS -O0 -ggdb2 -Wno-error -D_FORTIFY_SOURCE=0" +%define enable_shared 0 +%endif + +# We could optimize the cross builds size by --enable-shared but the produced +# binaries may be less convenient in the embedded environment. +# The seemingly unncessary --with-sysroot argument is merely meant to enable +# sysroot capabilities in the resulting executables. That allows customers +# to then use the sysroot capability to set up host-x-host build environments +# easier. +%configure \ + --build=%{_target_platform} --host=%{_target_platform} \ + --target=%{binutils_target} \ + --with-sysroot=/ \ +%ifarch %gold_arches +%if "%{build_gold}" == "both" + --enable-gold=default --enable-ld \ +%else + --enable-gold \ +%endif +%endif +%if %{isnative} + --with-sysroot=/ \ +%else + --enable-targets=%{_host} \ + --with-sysroot=%{_prefix}/%{binutils_target}/sys-root \ + --program-prefix=%{cross} \ +%endif +%if %{enable_shared} + --enable-shared \ +%else + --disable-shared \ +%endif +%if %{enable_deterministic_archives} + --enable-deterministic-archives \ +%else + --enable-deterministic-archives=no \ +%endif +%if %{enable_lto} + --enable-lto \ +%endif +%if %{default_compress_debug} + --enable-compressed-debug-sections=all \ +%else + --enable-compressed-debug-sections=none \ +%endif + $CARGS \ + --enable-plugins \ + --with-bugurl=http://bugzilla.redhat.com/bugzilla/ + +%if %{with docs} +make %{_smp_mflags} tooldir=%{_prefix} all +make %{_smp_mflags} tooldir=%{_prefix} info +%else +make %{_smp_mflags} tooldir=%{_prefix} MAKEINFO=true all +%endif + +# Do not use %%check as it is run after %%install where libbfd.so is rebuild +# with -fvisibility=hidden no longer being usable in its shared form. +%if %{without testsuite} +echo ====================TESTSUITE DISABLED========================= +%else +make -k check < /dev/null || : +echo ====================TESTING========================= +cat {gas/testsuite/gas,ld/ld,binutils/binutils}.sum +echo ====================TESTING END===================== +for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log} +do + ln $file binutils-%{_target_platform}-$(basename $file) || : +done +tar cjf binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}-*.{sum,log} +uuencode binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}.tar.bz2 +rm -f binutils-%{_target_platform}.tar.bz2 binutils-%{_target_platform}-*.{sum,log} +%endif + +%install +rm -rf %{buildroot} +%if %{with docs} +make install DESTDIR=%{buildroot} +%else +make install DESTDIR=%{buildroot} MAKEINFO=true +%endif + +%if %{isnative} +%if %{with info} +make prefix=%{buildroot}%{_prefix} infodir=%{buildroot}%{_infodir} install-info +%endif + +# Rebuild libiberty.a with -fPIC. +# Future: Remove it together with its header file, projects should bundle it. +make -C libiberty clean +make CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C libiberty + +# Rebuild libbfd.a with -fPIC. +# Without the hidden visibility the 3rd party shared libraries would export +# the bfd non-stable ABI. +make -C bfd clean +make CFLAGS="-g -fPIC $RPM_OPT_FLAGS -fvisibility=hidden" -C bfd + +# Rebuild libopcodes.a with -fPIC. +make -C opcodes clean +make CFLAGS="-g -fPIC $RPM_OPT_FLAGS" -C opcodes + +install -m 644 bfd/libbfd.a %{buildroot}%{_libdir} +install -m 644 libiberty/libiberty.a %{buildroot}%{_libdir} +install -m 644 include/libiberty.h %{buildroot}%{_prefix}/include +install -m 644 opcodes/libopcodes.a %{buildroot}%{_libdir} +# Remove Windows/Novell only man pages +rm -f %{buildroot}%{_mandir}/man1/{dlltool,nlmconv,windres,windmc}* + +%if %{enable_shared} +chmod +x %{buildroot}%{_libdir}/lib*.so* +%endif + +# Prevent programs from linking against libbfd and libopcodes +# dynamically, as they are change far too often. +rm -f %{buildroot}%{_libdir}/lib{bfd,opcodes}.so + +# Remove libtool files, which reference the .so libs +rm -f %{buildroot}%{_libdir}/lib{bfd,opcodes}.la + +# Sanity check --enable-64-bit-bfd really works. +grep '^#define BFD_ARCH_SIZE 64$' %{buildroot}%{_prefix}/include/bfd.h +# Fix multilib conflicts of generated values by __WORDSIZE-based expressions. +%ifarch %{ix86} x86_64 ppc %{power64} s390 s390x sh3 sh4 sparc sparc64 arm +sed -i -e '/^#include "ansidecl.h"/{p;s~^.*$~#include ~;}' \ + -e 's/^#define BFD_DEFAULT_TARGET_SIZE \(32\|64\) *$/#define BFD_DEFAULT_TARGET_SIZE __WORDSIZE/' \ + -e 's/^#define BFD_HOST_64BIT_LONG [01] *$/#define BFD_HOST_64BIT_LONG (__WORDSIZE == 64)/' \ + -e 's/^#define BFD_HOST_64_BIT \(long \)\?long *$/#if __WORDSIZE == 32\ +#define BFD_HOST_64_BIT long long\ +#else\ +#define BFD_HOST_64_BIT long\ +#endif/' \ + -e 's/^#define BFD_HOST_U_64_BIT unsigned \(long \)\?long *$/#define BFD_HOST_U_64_BIT unsigned BFD_HOST_64_BIT/' \ + %{buildroot}%{_prefix}/include/bfd.h +%endif +touch -r bfd/bfd-in2.h %{buildroot}%{_prefix}/include/bfd.h + +# Generate .so linker scripts for dependencies; imported from glibc/Makerules: + +# This fragment of linker script gives the OUTPUT_FORMAT statement +# for the configuration we are building. +OUTPUT_FORMAT="\ +/* Ensure this .so library will not be used by a link for a different format + on a multi-architecture system. */ +$(gcc $CFLAGS $LDFLAGS -shared -x c /dev/null -o /dev/null -Wl,--verbose -v 2>&1 | sed -n -f "%{SOURCE2}")" + +tee %{buildroot}%{_libdir}/libbfd.so <> %{?cross}binutils.lang +cat %{?cross}bfd.lang >> %{?cross}binutils.lang +cat %{?cross}gas.lang >> %{?cross}binutils.lang +cat %{?cross}gprof.lang >> %{?cross}binutils.lang + +if [ -x ld/ld-new ]; then + %find_lang %{?cross}ld + cat %{?cross}ld.lang >> %{?cross}binutils.lang +fi +if [ -x gold/ld-new ]; then + %find_lang %{?cross}gold + cat %{?cross}gold.lang >> %{?cross}binutils.lang +fi + +%clean +rm -rf %{buildroot} + +%post +%if "%{build_gold}" == "both" +%__rm -f %{_bindir}/%{?cross}ld +%{alternatives_cmdline} --install %{_bindir}/%{?cross}ld %{?cross}ld \ + %{_bindir}/%{?cross}ld.bfd %{ld_bfd_priority} +%{alternatives_cmdline} --install %{_bindir}/%{?cross}ld %{?cross}ld \ + %{_bindir}/%{?cross}ld.gold %{ld_gold_priority} +%{alternatives_cmdline} --auto %{?cross}ld +%endif +%if %{isnative} +/sbin/ldconfig +%if %{with docs} + /sbin/install-info --info-dir=%{_infodir} %{_infodir}/as.info.gz + /sbin/install-info --info-dir=%{_infodir} %{_infodir}/binutils.info.gz + /sbin/install-info --info-dir=%{_infodir} %{_infodir}/gprof.info.gz + /sbin/install-info --info-dir=%{_infodir} %{_infodir}/ld.info.gz +%endif # with docs +%endif # %{isnative} +exit 0 + +%preun +%if "%{build_gold}" == "both" +if [ $1 = 0 ]; then + %{alternatives_cmdline} --remove %{?cross}ld %{_bindir}/%{?cross}ld.bfd + %{alternatives_cmdline} --remove %{?cross}ld %{_bindir}/%{?cross}ld.gold +fi +%endif +%if %{isnative} +if [ $1 = 0 ]; then + if [ -e %{_infodir}/binutils.info.gz ] + then + /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/as.info.gz + /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/binutils.info.gz + /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/gprof.info.gz + /sbin/install-info --delete --info-dir=%{_infodir} %{_infodir}/ld.info.gz + fi +fi +%endif +exit 0 + +%if %{isnative} +%postun -p /sbin/ldconfig +%endif # %{isnative} + +%files -f %{?cross}binutils.lang +%defattr(-,root,root,-) +%license COPYING COPYING3 COPYING3.LIB COPYING.LIB +%doc README +%{_bindir}/%{?cross}[!l]* +%if "%{build_gold}" == "both" +%{_bindir}/%{?cross}ld.* +%ghost %{_bindir}/%{?cross}ld +%else +%{_bindir}/%{?cross}ld* +%endif +%{_mandir}/man1/* +%if %{enable_shared} +%{_libdir}/lib*.so +%exclude %{_libdir}/libbfd.so +%exclude %{_libdir}/libopcodes.so +%endif + +%if %{isnative} +%if %{with docs} +%{_infodir}/[^b]*info* +%{_infodir}/binutils*info* +%endif + +%files devel +%defattr(-,root,root,-) +%{_prefix}/include/* +%{_libdir}/lib*.a +%{_libdir}/libbfd.so +%{_libdir}/libopcodes.so +%if %{with docs} +%{_infodir}/bfd*info* +%endif # with docs +%endif # %{isnative} + +%changelog +* Thu Aug 31 2017 Nick Clifton 2.28-8 +- Remove the Provides line from the spec file. + (#1485002) + +* Thu Jul 20 2017 Nick Clifton 2.28-7 +- Add support for displaying new DWARF5 tags. + (#1472955) + +* Wed Jul 19 2017 Nick Clifton 2.28-6 +- Fix s390 assembler so that it remove fake local symbols from its output. + (#1460254) + (#1472486) + +* Mon Jun 26 2017 Nick Clifton 2.28-5 +- Add support for LNIA instruction to PowerPC assembler. + (#1357021) + +* Thu Jun 15 2017 Nick Clifton 2.28-4 +- Update patch to fix AArch64 copy reloc generation. + (#1452170) + +* Fri Jun 09 2017 Nick Clifton 2.28-3 +- Ignore duplicate indirect symbols generated by the GOLD linker. + (#1458003) + +* Thu Jun 08 2017 Nick Clifton 2.28-2 +- Eliminate the generation of incorrect dynamic copy relocations on AArch64. + (#1452170) + +* Mon May 22 2017 Nick Clifton 2.28-1 +- Rebase to FSF binutils 2.28 +- Retire: binutils-2.23.52.0.1-addr2line-dynsymtab.patch +- Retire: binutils-2.27-local-dynsym-count.patch +- Retire: binutils-2.27-monotonic-section-offsets.patch +- Retire: binutils-2.27-aarch64-relro-default.patch +- Retire: binutils-2.27-power9.patch +- Import FSF binutils patch to fix running readelf on debug info binaries. +- Import FSF binutils patch to fix an abort with PowerPC dynamic relocs. +- Backport patch to add support for putting name, comp_dir and + producer strings into the .debug_str section. +- Add support for GNU BUILD NOTEs. + +* Thu May 18 2017 Nick Clifton 2.27-12 +- Revert H.J.Lu's PLT elision patch. + (#1452111) + +* Thu Jan 12 2017 Nick Clifton 2.27-11 +- Version bump to allow rebuild for DTS 6.1 + +* Wed Sep 28 2016 Nick Clifton 2.27-10 +- Use correct default sysroot for native targets. +- Add Power9 ISA 3.0 support. + +* Mon Sep 05 2016 Carlos O'Donell 2.27-9 +- Enable '--sysroot' option support for all configurations. + +* Thu Sep 01 2016 Nick Clifton 2.27-8 +- Properly disable the default generation of compressed debug sections. + (#1366182) + +* Thu Aug 18 2016 Nick Clifton 2.27-7 +- Allow -z relro to be enabled by default for the AArch64 target. + (#1367862) + +* Wed Aug 17 2016 Nick Clifton 2.27-6 +- Move .shstrtab section to end of section list so that the monotonic ordering of section offsets is restored. + (#1366145) + +* Fri Aug 12 2016 Nick Clifton 2.27-5 +- Fix the computation of the sh_info field in the header of the .dynsym section. + (#1366185) + +* Thu Aug 04 2016 Nick Clifton 2.27-4 +- Rebase on official FSF binutils 2.27 release. + (#1358353) + +* Thu Jul 21 2016 Nick Clifton 2.27-3 +- Version bump so that the Brew build can be rerun, this time including ppc64 (big-endian) + (#1358353) + +* Wed Jul 20 2016 Nick Clifton 2.27-2 +- Remove sim sources from tarball. + (#1358353) + +* Mon Jul 18 2016 Nick Clifton 2.27-1 +- Rebase on FSF binutils 2.27 release. (#1356661) +- Retire: binutils-2.20.51.0.10-copy-osabi.patch +- Retire: binutils-2.23.2-aarch64-em.patch +- Retire: binutils-2.23.51.0.3-arm-ldralt.patch +- Retire: binutils-2.23.52.0.1-revert-pr15149.patch +- Retire: binutils-2.25.1-gold-testsuite-fixes.patch +- Retire: binutils-2.25-kernel-ld-r.bugfix.patch +- Retire: binutils-2.25-kernel-ld-r.patch +- Retire: binutils-2.25-only-keep-debug.patch +- Retire: binutils-2.25-x86_64-pie-relocs.patch +- Retire: binutils-pr18879.patch +- Retire: binutils-rh1224751.patch +- Retire: binutils-rh1309347.patch +- Retire: binutils-rh895241.patch + +* Mon Apr 04 2016 Patsy Franklin 2.25.1-10 +- Fix a case where a string was being used after the memory + containing the string had been freed. + +* Wed Mar 02 2016 Nick Clifton 2.25.1-9 +- Bump release number by 2 in order to enable build. + +* Wed Mar 02 2016 Nick Clifton 2.25.1-7 +- Fix GOLD testsuite failures. + (#1312376) + +* Thu Feb 25 2016 Nick Clifton 2.25.1-6 +- Change ar's default to be the creation of non-deterministic archives. + +* Thu Feb 18 2016 Nick Clifton 2.25.1-4 +- Add support for Intel Memory Protection Key instructions. + (#1309347) + +* Thu Feb 04 2016 Nick Clifton 2.25.1-2 +- Import patch for FSF PR 18879 + (#1260034) + +* Thu Jan 14 2016 Nick Clifton 2.25.1-1 +- Rebase on FSF binutils 2.25.1 release. +- Retire patch binutils-2.25-x86_64-pie-relocs.patch + +* Tue Sep 22 2015 Nick Clifton 2.25-10 +- Improved patch to preserve the sh_link and sh_info fields in stripped ELF sections. + (#1246390) + +* Wed Aug 5 2015 Nick Clifton 2.25-9 +- Import patch from FSF to preserve the sh_link and sh_info fields in stripped ELF sections. + (#1246390) + +* Tue Aug 4 2015 Jeff Law 2.25-8 +- Backport Cary's patch to silence pedantic warning in gold + (#895241) + +* Thu Jun 4 2015 Jeff Law 2.25-7 +- Resync with Fedora (binutils-2.25) + Reapply DTS specific patches + Backport testsuite patch to fix gold testsuite failure +