From 9f3c1f001f7afbd0180f8f6130413e51292413cc Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Fri, 2 Apr 2021 04:13:37 +0000 Subject: [PATCH] import binutils-2.30-99.el8 --- .binutils.metadata | 2 + .gitignore | 2 + .../binutils-2.19.50.0.1-output-format.sed | 38 + .../binutils-2.20.51.0.2-libtool-lib64.patch | 236 + ...nutils-2.22.52.0.1-export-demangle.h.patch | 21 + ...nutils-2.22.52.0.4-no-config-h-check.patch | 28 + SOURCES/binutils-2.25-set-long-long.patch | 38 + SOURCES/binutils-2.25-version.patch | 44 + SOURCES/binutils-2.26-lto.patch | 2439 + SOURCES/binutils-2.27-aarch64-ifunc.patch | 11 + ...binutils-2.28-ignore-gold-duplicates.patch | 14 + ...tils-2.29-filename-in-error-messages.patch | 124 + ...inutils-2.30-allow_R_AARCH64-symbols.patch | 147 + SOURCES/binutils-AArch64-gold.patch | 373 + SOURCES/binutils-CVE-2018-10372.patch | 22 + SOURCES/binutils-CVE-2018-10373.patch | 11 + SOURCES/binutils-CVE-2018-10534.patch | 18 + SOURCES/binutils-CVE-2018-10535.patch | 28 + SOURCES/binutils-CVE-2018-17358.patch | 101 + SOURCES/binutils-CVE-2018-6323.patch | 20 + SOURCES/binutils-CVE-2018-6759.patch | 69 + SOURCES/binutils-CVE-2018-7208.patch | 12 + SOURCES/binutils-CVE-2018-7568.patch | 37 + SOURCES/binutils-CVE-2018-7569.patch | 75 + SOURCES/binutils-CVE-2018-7570.patch | 156 + SOURCES/binutils-CVE-2018-7642.patch | 17 + SOURCES/binutils-CVE-2018-7643.patch | 16 + SOURCES/binutils-CVE-2018-8945.patch | 29 + SOURCES/binutils-CVE-2019-1010204.patch | 15 + SOURCES/binutils-CVE-2019-14444.patch | 11 + SOURCES/binutils-CVE-2019-17450.patch | 62 + SOURCES/binutils-CVE-2019-17451.patch | 20 + SOURCES/binutils-CVE-2021-20197.patch | 1287 + .../binutils-PT_GNU_PROPERTY-segment.patch | 3810 + ...ls-PowerPC-IEEE-long-double-warnings.patch | 17 + ...tils-aarch64-STO_AARCH64_VARIANT_PCS.patch | 855 + .../binutils-aarch64-armv8.6-support.patch | 146139 +++++++++++++++ SOURCES/binutils-aarch64-ld-test-fixes.patch | 122 + SOURCES/binutils-aarch64-properties.patch | 547 + SOURCES/binutils-attach-to-group.patch | 68 + SOURCES/binutils-common-sym-versioning.patch | 29 + SOURCES/binutils-copy-multiple-relocs.patch | 591 + SOURCES/binutils-coverity-fixes.patch | 2307 + SOURCES/binutils-debug-section-marking.patch | 39 + ...binutils-disable-readelf-gap-reports.patch | 16 + ...ls-do-not-link-with-static-libstdc++.patch | 83 + ...t-merge-differing-SHF_EXCLUDE-groups.patch | 18 + ...ls-do-not-warn-about-debuginfo-files.patch | 68 + SOURCES/binutils-fix-testsuite-failures.patch | 768 + SOURCES/binutils-gas-build-notes.patch | 555 + .../binutils-gold-8-byte-note-segments.patch | 99 + ...ls-gold-ignore-discarded-note-relocs.patch | 10 + SOURCES/binutils-gold-llvm-plugin.patch | 16 + ...nutils-gold-mismatched-section-flags.patch | 36 + SOURCES/binutils-gold-note-segment.patch | 1239 + SOURCES/binutils-ifunc-relocs-in-notes.patch | 296 + SOURCES/binutils-improved-note-merging.patch | 2075 + SOURCES/binutils-ld-IR-override.patch | 251 + SOURCES/binutils-linkonce-notes.patch | 127 + SOURCES/binutils-mark-all-weak-aliases.patch | 123 + .../binutils-merge-attribute-sections.patch | 23 + SOURCES/binutils-missing-notes.patch | 24 + ...ils-multiple-relocs-for-same-section.patch | 23 + SOURCES/binutils-nfp.patch | 5427 + .../binutils-note-merge-improvements.patch | 61 + ...ils-objcopy-set-section-flags-shared.patch | 97 + .../binutils-page-to-segment-assignment.patch | 77 + SOURCES/binutils-plugin-as-needed-2.patch | 212 + SOURCES/binutils-plugin-as-needed.patch | 138 + SOURCES/binutils-ppc64le-note-merge.patch | 42 + SOURCES/binutils-readelf-other-sym-info.patch | 66 + ...binutils-remove-empty-ISA-properties.patch | 314 + ...-revert-PowerPC-speculation-barriers.patch | 749 + SOURCES/binutils-s390-alignment-hints.patch | 150 + SOURCES/binutils-s390-ld-test-fixes.patch | 410 + SOURCES/binutils-s390x-arch13.patch | 1040 + SOURCES/binutils-s390x-partial-relro.patch | 899 + .../binutils-s390x-prevent-GOT-rewrite.patch | 43 + SOURCES/binutils-sanitize-uses-dlsym.patch | 11 + ...nutils-skip-dwo-search-if-not-needed.patch | 13 + SOURCES/binutils-speed-up-objdump.patch | 97 + SOURCES/binutils-strip-merge.patch | 19 + SOURCES/binutils-strip-unknown-relocs.patch | 107 + .../binutils-x86-IBT-and-missing-notes.patch | 210 + ...s-x86-gas-scaled-8-bit-displacements.patch | 116 + SOURCES/binutils-x86-local-relocs.patch | 64 + SOURCES/binutils-x86-local-version.patch | 58 + SOURCES/binutils-x86-tpause.patch | 117840 ++++++++++++ .../binutils-x86_64-disable-PLT-elision.patch | 137 + .../binutils-x86_64-ibt-enabled-tlsdesc.patch | 77 + SOURCES/binutils-x86_JCC_Erratum.patch | 3733 + SPECS/binutils.spec | 3629 + 92 files changed, 301733 insertions(+) create mode 100644 .binutils.metadata create mode 100644 .gitignore create mode 100644 SOURCES/binutils-2.19.50.0.1-output-format.sed create mode 100644 SOURCES/binutils-2.20.51.0.2-libtool-lib64.patch create mode 100644 SOURCES/binutils-2.22.52.0.1-export-demangle.h.patch create mode 100644 SOURCES/binutils-2.22.52.0.4-no-config-h-check.patch create mode 100644 SOURCES/binutils-2.25-set-long-long.patch create mode 100644 SOURCES/binutils-2.25-version.patch create mode 100644 SOURCES/binutils-2.26-lto.patch create mode 100644 SOURCES/binutils-2.27-aarch64-ifunc.patch create mode 100644 SOURCES/binutils-2.28-ignore-gold-duplicates.patch create mode 100644 SOURCES/binutils-2.29-filename-in-error-messages.patch create mode 100644 SOURCES/binutils-2.30-allow_R_AARCH64-symbols.patch create mode 100644 SOURCES/binutils-AArch64-gold.patch create mode 100644 SOURCES/binutils-CVE-2018-10372.patch create mode 100644 SOURCES/binutils-CVE-2018-10373.patch create mode 100644 SOURCES/binutils-CVE-2018-10534.patch create mode 100644 SOURCES/binutils-CVE-2018-10535.patch create mode 100644 SOURCES/binutils-CVE-2018-17358.patch create mode 100644 SOURCES/binutils-CVE-2018-6323.patch create mode 100644 SOURCES/binutils-CVE-2018-6759.patch create mode 100644 SOURCES/binutils-CVE-2018-7208.patch create mode 100644 SOURCES/binutils-CVE-2018-7568.patch create mode 100644 SOURCES/binutils-CVE-2018-7569.patch create mode 100644 SOURCES/binutils-CVE-2018-7570.patch create mode 100644 SOURCES/binutils-CVE-2018-7642.patch create mode 100644 SOURCES/binutils-CVE-2018-7643.patch create mode 100644 SOURCES/binutils-CVE-2018-8945.patch create mode 100644 SOURCES/binutils-CVE-2019-1010204.patch create mode 100644 SOURCES/binutils-CVE-2019-14444.patch create mode 100644 SOURCES/binutils-CVE-2019-17450.patch create mode 100644 SOURCES/binutils-CVE-2019-17451.patch create mode 100644 SOURCES/binutils-CVE-2021-20197.patch create mode 100644 SOURCES/binutils-PT_GNU_PROPERTY-segment.patch create mode 100644 SOURCES/binutils-PowerPC-IEEE-long-double-warnings.patch create mode 100644 SOURCES/binutils-aarch64-STO_AARCH64_VARIANT_PCS.patch create mode 100644 SOURCES/binutils-aarch64-armv8.6-support.patch create mode 100644 SOURCES/binutils-aarch64-ld-test-fixes.patch create mode 100644 SOURCES/binutils-aarch64-properties.patch create mode 100644 SOURCES/binutils-attach-to-group.patch create mode 100644 SOURCES/binutils-common-sym-versioning.patch create mode 100644 SOURCES/binutils-copy-multiple-relocs.patch create mode 100644 SOURCES/binutils-coverity-fixes.patch create mode 100644 SOURCES/binutils-debug-section-marking.patch create mode 100644 SOURCES/binutils-disable-readelf-gap-reports.patch create mode 100644 SOURCES/binutils-do-not-link-with-static-libstdc++.patch create mode 100644 SOURCES/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch create mode 100644 SOURCES/binutils-do-not-warn-about-debuginfo-files.patch create mode 100644 SOURCES/binutils-fix-testsuite-failures.patch create mode 100644 SOURCES/binutils-gas-build-notes.patch create mode 100644 SOURCES/binutils-gold-8-byte-note-segments.patch create mode 100644 SOURCES/binutils-gold-ignore-discarded-note-relocs.patch create mode 100644 SOURCES/binutils-gold-llvm-plugin.patch create mode 100644 SOURCES/binutils-gold-mismatched-section-flags.patch create mode 100644 SOURCES/binutils-gold-note-segment.patch create mode 100644 SOURCES/binutils-ifunc-relocs-in-notes.patch create mode 100644 SOURCES/binutils-improved-note-merging.patch create mode 100644 SOURCES/binutils-ld-IR-override.patch create mode 100644 SOURCES/binutils-linkonce-notes.patch create mode 100644 SOURCES/binutils-mark-all-weak-aliases.patch create mode 100644 SOURCES/binutils-merge-attribute-sections.patch create mode 100644 SOURCES/binutils-missing-notes.patch create mode 100644 SOURCES/binutils-multiple-relocs-for-same-section.patch create mode 100644 SOURCES/binutils-nfp.patch create mode 100644 SOURCES/binutils-note-merge-improvements.patch create mode 100644 SOURCES/binutils-objcopy-set-section-flags-shared.patch create mode 100644 SOURCES/binutils-page-to-segment-assignment.patch create mode 100644 SOURCES/binutils-plugin-as-needed-2.patch create mode 100644 SOURCES/binutils-plugin-as-needed.patch create mode 100644 SOURCES/binutils-ppc64le-note-merge.patch create mode 100644 SOURCES/binutils-readelf-other-sym-info.patch create mode 100644 SOURCES/binutils-remove-empty-ISA-properties.patch create mode 100644 SOURCES/binutils-revert-PowerPC-speculation-barriers.patch create mode 100644 SOURCES/binutils-s390-alignment-hints.patch create mode 100644 SOURCES/binutils-s390-ld-test-fixes.patch create mode 100644 SOURCES/binutils-s390x-arch13.patch create mode 100644 SOURCES/binutils-s390x-partial-relro.patch create mode 100644 SOURCES/binutils-s390x-prevent-GOT-rewrite.patch create mode 100644 SOURCES/binutils-sanitize-uses-dlsym.patch create mode 100644 SOURCES/binutils-skip-dwo-search-if-not-needed.patch create mode 100644 SOURCES/binutils-speed-up-objdump.patch create mode 100644 SOURCES/binutils-strip-merge.patch create mode 100644 SOURCES/binutils-strip-unknown-relocs.patch create mode 100644 SOURCES/binutils-x86-IBT-and-missing-notes.patch create mode 100644 SOURCES/binutils-x86-gas-scaled-8-bit-displacements.patch create mode 100644 SOURCES/binutils-x86-local-relocs.patch create mode 100644 SOURCES/binutils-x86-local-version.patch create mode 100644 SOURCES/binutils-x86-tpause.patch create mode 100644 SOURCES/binutils-x86_64-disable-PLT-elision.patch create mode 100644 SOURCES/binutils-x86_64-ibt-enabled-tlsdesc.patch create mode 100644 SOURCES/binutils-x86_JCC_Erratum.patch create mode 100644 SPECS/binutils.spec diff --git a/.binutils.metadata b/.binutils.metadata new file mode 100644 index 0000000..074d28a --- /dev/null +++ b/.binutils.metadata @@ -0,0 +1,2 @@ +574d3b5650413d6ee65195a4f5ecbddc3a38f718 SOURCES/binutils-2.30.tar.xz +d3e5c9fc829ed40648110da6fe46c2fb1ed8aadb SOURCES/standards.info.gz diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3ce3d88 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +SOURCES/binutils-2.30.tar.xz +SOURCES/standards.info.gz 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.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.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.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..c030f71 --- /dev/null +++ b/SOURCES/binutils-2.26-lto.patch @@ -0,0 +1,2439 @@ +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 +@@ -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/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, 0, ".text", 0); ++static asection bfd_plugin_fake_common_section ++ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, SEC_IS_COMMON, 0, ++ NULL, 0); ++ ++/* Get symbols from object only section. */ ++ ++static void ++bfd_plugin_get_symbols_in_object_only (bfd *abfd) ++{ ++ struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data; ++ const char *object_only_file; ++ bfd *nbfd; ++ long storage; ++ long object_only_nsyms, added_nsyms, i; ++ asymbol **object_only_syms, **added_syms; ++ ++ plugin_data->object_only_syms = NULL; ++ plugin_data->object_only_nsyms = 0; ++ ++ if (abfd->sections == NULL && abfd->my_archive == NULL) ++ { ++ nbfd = bfd_openr (abfd->filename, NULL); ++ if (nbfd == NULL) ++ { ++ (*_bfd_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) + 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 + in->owner, in); + } + ++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__)} : +--- binutils.orig/bfd/bfd-in2.h 2017-03-02 11:14:48.572979573 +0000 ++++ binutils-2.28/bfd/bfd-in2.h 2017-03-02 11:21:39.828458555 +0000 +@@ -1118,6 +1118,9 @@ bfd_boolean bfd_fill_in_gnu_debuglink_se + + 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. */ +--- binutils.orig/bfd/opncls.c 2017-03-02 11:14:48.586979385 +0000 ++++ binutils-2.28/bfd/opncls.c 2017-03-02 11:23:23.546065945 +0000 +@@ -1990,3 +1990,69 @@ bfd_follow_build_id_debuglink (bfd *abfd + get_build_id_name, + check_build_id_file, &build_id); + } ++ ++/* ++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 = _bfd_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; ++} +--- binutils.orig/bfd/plugin.c 2017-03-02 11:37:31.572677260 +0000 ++++ binutils-2.28/bfd/plugin.c 2017-03-02 11:40:35.246209573 +0000 +@@ -132,10 +132,10 @@ register_claim_file (ld_plugin_claim_fil + } + + static asection bfd_plugin_fake_text_section +- = BFD_FAKE_SECTION (bfd_plugin_fake_text_section, 0, 0, ".text", 0); ++= 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, SEC_IS_COMMON, 0, +- NULL, 0); ++ = BFD_FAKE_SECTION (bfd_plugin_fake_common_section, 0, ++ NULL, 0, SEC_IS_COMMON); + + /* Get symbols from object only section. */ + +--- binutils.orig/ld/emultempl/armelf.em 2017-03-02 11:58:14.632981042 +0000 ++++ binutils-2.28/ld/emultempl/armelf.em 2017-03-02 12:00:55.663819055 +0000 +@@ -414,7 +414,7 @@ gld${EMULATION_NAME}_after_allocation (v + } + + static void +-gld${EMULATION_NAME}_finish (void) ++arm_finish (void) + { + struct bfd_link_hash_entry * h; + +@@ -441,7 +441,7 @@ gld${EMULATION_NAME}_finish (void) + } + } + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + + if (params.thumb_entry_symbol) + { +@@ -790,4 +790,4 @@ LDEMUL_BEFORE_PARSE=gld"${EMULATION_NAME + LDEMUL_SET_SYMBOLS=gld"${EMULATION_NAME}"_set_symbols + + # Call the extra arm-elf function +-LDEMUL_FINISH=gld${EMULATION_NAME}_finish ++LDEMUL_FINISH=arm_finish +--- binutils.orig/ld/emultempl/ppc64elf.em 2017-03-02 11:58:14.632981042 +0000 ++++ binutils-2.28/ld/emultempl/ppc64elf.em 2017-03-02 12:01:40.961210895 +0000 +@@ -561,7 +561,7 @@ gld${EMULATION_NAME}_after_allocation (v + /* Final emulation specific call. */ + + static void +-gld${EMULATION_NAME}_finish (void) ++ppc_finish (void) + { + char *msg = NULL; + char *line, *endline; +@@ -592,7 +592,7 @@ gld${EMULATION_NAME}_finish (void) + if (msg != NULL) + free (msg); + +- finish_default (); ++ gld${EMULATION_NAME}_finish (); + } + + +@@ -926,4 +926,4 @@ LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS= + LDEMUL_AFTER_OPEN=ppc_after_open + LDEMUL_BEFORE_ALLOCATION=ppc_before_allocation + LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation +-LDEMUL_FINISH=gld${EMULATION_NAME}_finish ++LDEMUL_FINISH=ppc_finish +--- binutils.orig/bfd/format.c 2018-01-22 16:04:36.855155517 +0000 ++++ binutils-2.30.0/bfd/format.c 2018-01-22 16:11:36.546253154 +0000 +@@ -47,6 +47,7 @@ SUBSECTION + #include "bfd.h" + #include "libbfd.h" + #if BFD_SUPPORTS_PLUGINS ++#include "plugin-api.h" + #include "plugin.h" + #endif + +--- binutils.orig/ld/ldlang.c 2018-01-22 16:04:37.271150658 +0000 ++++ binutils-2.30.0/ld/ldlang.c 2018-01-22 16:14:10.653453040 +0000 +@@ -8954,6 +8954,7 @@ cmdline_object_only_list_append (cmdline + archive = abfd->my_archive; + if (archive) + break; ++ /* Fall through. */ + case cmdline_is_file_enum: + cmdline_list_append (&cmdline_object_only_file_list, type, data); + return; diff --git a/SOURCES/binutils-2.27-aarch64-ifunc.patch b/SOURCES/binutils-2.27-aarch64-ifunc.patch new file mode 100644 index 0000000..562ef18 --- /dev/null +++ b/SOURCES/binutils-2.27-aarch64-ifunc.patch @@ -0,0 +1,11 @@ +diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.27/bfd/elfnn-aarch64.c +--- binutils.orig/bfd/elfnn-aarch64.c 2017-02-21 10:45:19.311956006 +0000 ++++ binutils-2.27/bfd/elfnn-aarch64.c 2017-02-21 11:55:07.517922655 +0000 +@@ -4947,6 +4947,7 @@ elfNN_aarch64_final_link_relocate (reloc + it here if it is defined in a non-shared object. */ + if (h != NULL + && h->type == STT_GNU_IFUNC ++ && (input_section->flags & SEC_ALLOC) + && h->def_regular) + { + asection *plt; 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.29-filename-in-error-messages.patch b/SOURCES/binutils-2.29-filename-in-error-messages.patch new file mode 100644 index 0000000..d8ce241 --- /dev/null +++ b/SOURCES/binutils-2.29-filename-in-error-messages.patch @@ -0,0 +1,124 @@ +--- binutils.orig/binutils/readelf.c 2018-01-22 15:48:10.450701702 +0000 ++++ binutils-2.30.0/binutils/readelf.c 2018-01-22 15:55:26.739588657 +0000 +@@ -19019,75 +19019,85 @@ process_file (char * file_name) + Filedata * filedata = NULL; + struct stat statbuf; + char armag[SARMAG]; +- bfd_boolean ret = TRUE; ++ bfd_boolean ret = FALSE; ++ char * name; ++ char * saved_program_name; ++ ++ /* Overload program_name to include file_name. Doing this means ++ that warning/error messages will positively identify the file ++ concerned even when multiple instances of readelf are running. */ ++ name = xmalloc (strlen (program_name) + strlen (file_name) + 3); ++ sprintf (name, "%s: %s", program_name, file_name); ++ saved_program_name = program_name; ++ program_name = name; + + if (stat (file_name, &statbuf) < 0) + { + if (errno == ENOENT) +- error (_("'%s': No such file\n"), file_name); ++ error (_("No such file\n")); + else +- error (_("Could not locate '%s'. System error message: %s\n"), +- file_name, strerror (errno)); +- return FALSE; ++ error (_("Could not locate file. System error message: %s\n"), ++ strerror (errno)); ++ goto done; + } + + if (! S_ISREG (statbuf.st_mode)) + { +- error (_("'%s' is not an ordinary file\n"), file_name); +- return FALSE; ++ error (_("Not an ordinary file\n")); ++ goto done; + } + + filedata = calloc (1, sizeof * filedata); + if (filedata == NULL) + { + error (_("Out of memory allocating file data structure\n")); +- return FALSE; ++ goto done; + } + + filedata->file_name = file_name; + filedata->handle = fopen (file_name, "rb"); + if (filedata->handle == NULL) + { +- error (_("Input file '%s' is not readable.\n"), file_name); +- free (filedata); +- return FALSE; ++ error (_("Not readable\n")); ++ goto done; + } + + if (fread (armag, SARMAG, 1, filedata->handle) != 1) + { +- error (_("%s: Failed to read file's magic number\n"), file_name); +- fclose (filedata->handle); +- free (filedata); +- return FALSE; +- } +- +- filedata->file_size = (bfd_size_type) statbuf.st_size; +- +- if (memcmp (armag, ARMAG, SARMAG) == 0) +- { +- if (! process_archive (filedata, FALSE)) +- ret = FALSE; +- } +- else if (memcmp (armag, ARMAGT, SARMAG) == 0) +- { +- if ( ! process_archive (filedata, TRUE)) +- ret = FALSE; ++ error (_("Failed to read file's magic number\n")); + } + else + { +- if (do_archive_index) +- error (_("File %s is not an archive so its index cannot be displayed.\n"), +- file_name); ++ filedata->file_size = (bfd_size_type) statbuf.st_size; + +- rewind (filedata->handle); +- archive_file_size = archive_file_offset = 0; +- +- if (! process_object (filedata)) +- ret = FALSE; ++ if (memcmp (armag, ARMAG, SARMAG) == 0) ++ { ++ if (process_archive (filedata, FALSE)) ++ ret = TRUE; ++ } ++ else if (memcmp (armag, ARMAGT, SARMAG) == 0) ++ { ++ if (process_archive (filedata, TRUE)) ++ ret = TRUE; ++ } ++ else ++ { ++ if (do_archive_index) ++ error (_("Not an archive so its index cannot be displayed.\n")); ++ ++ rewind (filedata->handle); ++ archive_file_size = archive_file_offset = 0; ++ ++ if (process_object (filedata)) ++ ret = TRUE; ++ } + } + + fclose (filedata->handle); ++ done: + free (filedata); ++ free (program_name); ++ program_name = saved_program_name; + + return ret; + } diff --git a/SOURCES/binutils-2.30-allow_R_AARCH64-symbols.patch b/SOURCES/binutils-2.30-allow_R_AARCH64-symbols.patch new file mode 100644 index 0000000..213b267 --- /dev/null +++ b/SOURCES/binutils-2.30-allow_R_AARCH64-symbols.patch @@ -0,0 +1,147 @@ +From 279b2f94168ee91e02ccd070d27c983fc001fe12 Mon Sep 17 00:00:00 2001 +From: Renlin Li +Date: Sat, 3 Feb 2018 13:18:17 +0000 +Subject: [PATCH] [PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and + R_AARCH64_ABS32 against absolution symbol or undefine symbol in shared + object. + +The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi +will be used to generate an address does not hold for absolute symbol. +In this case, it is a value fixed at static linking time. + +The condition to check the relocations is relax to allow absolute symbol and +undefined symbol case. + +bfd/ + +2018-02-05 Renlin Li + + PR ld/22764 + * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the + R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the + check for writeable section as well. + +ld/ + +2018-02-05 Renlin Li + + PR ld/22764 + * testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address. + * testsuite/ld-aarch64/emit-relocs-259.s: Likewise. + * testsuite/ld-aarch64/aarch64-elf.exp: Run new test. + * testsuite/ld-aarch64/pr22764.s: New. + * testsuite/ld-aarch64/pr22764.d: New. +--- + bfd/ChangeLog | 7 +++++++ + bfd/elfnn-aarch64.c | 15 ++++++++++++--- + ld/ChangeLog | 8 ++++++++ + ld/testsuite/ld-aarch64/aarch64-elf.exp | 1 + + ld/testsuite/ld-aarch64/emit-relocs-258.s | 3 ++- + ld/testsuite/ld-aarch64/emit-relocs-259.s | 3 ++- + ld/testsuite/ld-aarch64/pr22764.d | 18 ++++++++++++++++++ + ld/testsuite/ld-aarch64/pr22764.s | 6 ++++++ + 8 files changed, 56 insertions(+), 5 deletions(-) + create mode 100644 ld/testsuite/ld-aarch64/pr22764.d + create mode 100644 ld/testsuite/ld-aarch64/pr22764.s + +diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c +index af448f9..2737773 100644 +--- a/bfd/elfnn-aarch64.c ++++ b/bfd/elfnn-aarch64.c +@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, + #if ARCH_SIZE == 64 + case BFD_RELOC_AARCH64_32: + #endif +- if (bfd_link_pic (info) +- && (sec->flags & SEC_ALLOC) != 0 +- && (sec->flags & SEC_READONLY) != 0) ++ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0) + { ++ if (h != NULL ++ /* This is an absolute symbol. It represents a value instead ++ of an address. */ ++ && ((h->root.type == bfd_link_hash_defined ++ && bfd_is_abs_section (h->root.u.def.section)) ++ /* This is an undefined symbol. */ ++ || h->root.type == bfd_link_hash_undefined)) ++ break; ++ ++ /* For local symbols, defined global symbols in a non-ABS section, ++ it is assumed that the value is an address. */ + int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; + _bfd_error_handler + /* xgettext:c-format */ +diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp +index 2602a43..c67ffb1 100644 +--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp ++++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp +@@ -285,6 +285,7 @@ run_dump_test "pr17415" + run_dump_test_lp64 "tprel_g2_overflow" + run_dump_test "tprel_add_lo12_overflow" + run_dump_test "protected-data" ++run_dump_test_lp64 "pr22764" + + # ifunc tests + run_dump_test "ifunc-1" +diff --git a/ld/testsuite/ld-aarch64/emit-relocs-258.s b/ld/testsuite/ld-aarch64/emit-relocs-258.s +index f724776..87bb657 100644 +--- a/ld/testsuite/ld-aarch64/emit-relocs-258.s ++++ b/ld/testsuite/ld-aarch64/emit-relocs-258.s +@@ -1,5 +1,6 @@ ++.global dummy + .text +- ++dummy: + ldr x0, .L1 + + .L1: +diff --git a/ld/testsuite/ld-aarch64/emit-relocs-259.s b/ld/testsuite/ld-aarch64/emit-relocs-259.s +index 7e1ba3c..0977c9d 100644 +--- a/ld/testsuite/ld-aarch64/emit-relocs-259.s ++++ b/ld/testsuite/ld-aarch64/emit-relocs-259.s +@@ -1,5 +1,6 @@ ++.global dummy + .text +- ++dummy: + ldr x0, .L1 + + .L1: +diff --git a/ld/testsuite/ld-aarch64/pr22764.d b/ld/testsuite/ld-aarch64/pr22764.d +new file mode 100644 +index 0000000..997519f +--- /dev/null ++++ b/ld/testsuite/ld-aarch64/pr22764.d +@@ -0,0 +1,18 @@ ++#source: pr22764.s ++#ld: -shared -T relocs.ld -defsym sym_abs1=0x1 -defsym sym_abs2=0x2 -defsym sym_abs3=0x3 -e0 --emit-relocs ++#notarget: aarch64_be-*-* ++#objdump: -dr ++#... ++ ++Disassembly of section \.text: ++ ++0000000000010000 \<\.text\>: ++ 10000: d503201f nop ++ ... ++ 10004: R_AARCH64_ABS64 sym_abs1 ++ 1000c: 00000002 \.word 0x00000002 ++ 1000c: R_AARCH64_ABS32 sym_abs2 ++ 10010: 0003 \.short 0x0003 ++ 10010: R_AARCH64_ABS16 sym_abs3 ++ 10012: 0000 \.short 0x0000 ++ 10014: d503201f nop +diff --git a/ld/testsuite/ld-aarch64/pr22764.s b/ld/testsuite/ld-aarch64/pr22764.s +new file mode 100644 +index 0000000..25e36b4 +--- /dev/null ++++ b/ld/testsuite/ld-aarch64/pr22764.s +@@ -0,0 +1,6 @@ ++ .text ++ nop ++ .xword sym_abs1 ++ .word sym_abs2 ++ .short sym_abs3 ++ nop +-- +2.9.3 diff --git a/SOURCES/binutils-AArch64-gold.patch b/SOURCES/binutils-AArch64-gold.patch new file mode 100644 index 0000000..2841091 --- /dev/null +++ b/SOURCES/binutils-AArch64-gold.patch @@ -0,0 +1,373 @@ +diff -pruN binutils-2.30.orig/gold/aarch64.cc binutils-2.30/gold/aarch64.cc +--- binutils-2.30.orig/gold/aarch64.cc 2019-03-28 06:50:31.813828734 -0400 ++++ binutils-2.30/gold/aarch64.cc 2019-03-28 06:50:46.993954670 -0400 +@@ -6478,6 +6478,17 @@ Target_aarch64::Scan:: + gold_error(_("%s: unsupported reloc %u in pos independent link."), + object->name().c_str(), r_type); + } ++ // Make a PLT entry if necessary. ++ if (gsym->needs_plt_entry()) ++ { ++ target->make_plt_entry(symtab, layout, gsym); ++ // Since this is not a PC-relative relocation, we may be ++ // taking the address of a function. In that case we need to ++ // set the entry in the dynamic symbol table to the address of ++ // the PLT entry. ++ if (gsym->is_from_dynobj() && !parameters->options().shared()) ++ gsym->set_needs_dynsym_value(); ++ } + break; + + case elfcpp::R_AARCH64_LD_PREL_LO19: // 273 +diff -pruN binutils-2.30.orig/gold/ChangeLog binutils-2.30/gold/ChangeLog +--- binutils-2.30.orig/gold/ChangeLog 2018-01-27 10:08:21.000000000 -0500 ++++ binutils-2.30/gold/ChangeLog 2019-03-28 06:52:51.924999245 -0400 +@@ -1,3 +1,14 @@ ++2019-02-19 Egeyar Bagcioglu ++ ++ PR gold/23870 ++ * aarch64.cc (Target_aarch64::Scan::global): Check if a symbol with ++ R_AARCH64_MOVW_.ABS_* relocations requires a PLT entry. ++ * testsuite/Makefile.am: Add aarch64_pr23870 test case. ++ * testsuite/Makefile.in: Regenerate. ++ * testsuite/aarch64_pr23870_bar.c: New file. ++ * testsuite/aarch64_pr23870_foo.c: New file. ++ * testsuite/aarch64_pr23870_main.S: New file. ++ + 2018-01-27 Nick Clifton + + This is the 2.30 release: +diff -pruN binutils-2.30.orig/gold/testsuite/aarch64_pr23870_bar.c binutils-2.30/gold/testsuite/aarch64_pr23870_bar.c +--- binutils-2.30.orig/gold/testsuite/aarch64_pr23870_bar.c 1969-12-31 19:00:00.000000000 -0500 ++++ binutils-2.30/gold/testsuite/aarch64_pr23870_bar.c 2019-03-28 06:50:46.993954670 -0400 +@@ -0,0 +1,6 @@ ++void bar (void); ++ ++void bar () ++{ ++ return; ++} +diff -pruN binutils-2.30.orig/gold/testsuite/aarch64_pr23870_foo.c binutils-2.30/gold/testsuite/aarch64_pr23870_foo.c +--- binutils-2.30.orig/gold/testsuite/aarch64_pr23870_foo.c 1969-12-31 19:00:00.000000000 -0500 ++++ binutils-2.30/gold/testsuite/aarch64_pr23870_foo.c 2019-03-28 06:50:46.993954670 -0400 +@@ -0,0 +1,6 @@ ++void foo (void (*bar)(void)); ++ ++void foo (void (*bar)(void)) ++{ ++ bar(); ++} +diff -pruN binutils-2.30.orig/gold/testsuite/aarch64_pr23870_main.S binutils-2.30/gold/testsuite/aarch64_pr23870_main.S +--- binutils-2.30.orig/gold/testsuite/aarch64_pr23870_main.S 1969-12-31 19:00:00.000000000 -0500 ++++ binutils-2.30/gold/testsuite/aarch64_pr23870_main.S 2019-03-28 06:50:46.993954670 -0400 +@@ -0,0 +1,15 @@ ++ ++ .text ++ .globl main ++ .type main,#function ++main: ++ stp x29, x30, [sp,#-16]! ++ mov x29, sp ++ movz x0, #:abs_g3:bar ++ movk x0, #:abs_g2_nc:bar ++ movk x0, #:abs_g1_nc:bar ++ movk x0, #:abs_g0_nc:bar ++ add x0, x0, #0x0 ++ bl foo ++ ldp x29, x30, [sp],#16 ++ ret +diff -pruN binutils-2.30.orig/gold/testsuite/Makefile.am binutils-2.30/gold/testsuite/Makefile.am +--- binutils-2.30.orig/gold/testsuite/Makefile.am 2019-03-28 06:50:31.563826660 -0400 ++++ binutils-2.30/gold/testsuite/Makefile.am 2019-03-28 06:50:46.993954670 -0400 +@@ -3144,6 +3144,26 @@ pr22266: pr22266_main.o pr22266_ar.o gcc + pr22266_ar.o: pr22266_a.o gcctestdir/ld + gcctestdir/ld -r -T $(srcdir)/pr22266_script.t -o $@ pr22266_a.o + ++if DEFAULT_TARGET_AARCH64 ++ ++check_PROGRAMS += aarch64_pr23870 ++aarch64_pr23870_SOURCES = aarch64_pr23870_foo.c ++aarch64_pr23870_DEPENDENCIES = \ ++ gcctestdir/ld gcctestdir/as aarch64_pr23870_main.o \ ++ aarch64_pr23870_foo.o aarch64_pr23870_bar.so ++aarch64_pr23870_LDFLAGS = -Wl,-R,. -L. -Wl,-l:aarch64_pr23870_bar.so ++aarch64_pr23870_LDADD = aarch64_pr23870_main.o ++aarch64_pr23870_main.o: aarch64_pr23870_main.S ++ $(COMPILE) -c -o $@ $< ++aarch64_pr23870_foo.o: aarch64_pr23870_foo.c ++ $(COMPILE) -c -o $@ $< ++aarch64_pr23870_bar.o: aarch64_pr23870_bar.c ++ $(COMPILE) -c -fPIC -o $@ $< ++aarch64_pr23870_bar.so: aarch64_pr23870_bar.o ++ $(COMPILE) -shared -o $@ $< ++ ++endif DEFAULT_TARGET_AARCH64 ++ + endif GCC + endif NATIVE_LINKER + +diff -pruN binutils-2.30.orig/gold/testsuite/Makefile.in binutils-2.30/gold/testsuite/Makefile.in +--- binutils-2.30.orig/gold/testsuite/Makefile.in 2019-03-28 06:50:31.573826743 -0400 ++++ binutils-2.30/gold/testsuite/Makefile.in 2019-03-28 06:59:26.518313455 -0400 +@@ -70,7 +70,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + $(am__EXEEXT_31) $(am__EXEEXT_32) $(am__EXEEXT_33) \ + $(am__EXEEXT_34) $(am__EXEEXT_35) $(am__EXEEXT_36) \ + $(am__EXEEXT_37) $(am__EXEEXT_38) $(am__EXEEXT_39) \ +- $(am__EXEEXT_40) $(am__EXEEXT_41) ++ $(am__EXEEXT_40) $(am__EXEEXT_41) $(am__EXEEXT_42) + @NATIVE_OR_CROSS_LINKER_TRUE@am__append_1 = object_unittest \ + @NATIVE_OR_CROSS_LINKER_TRUE@ binary_unittest leb128_unittest \ + @NATIVE_OR_CROSS_LINKER_TRUE@ overflow_unittest +@@ -817,27 +817,28 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_84 = gnu_property_test.sh + @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_85 = gnu_property_test.stdout + @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_86 = pr22266 ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_87 = aarch64_pr23870 + + # These tests work with native and cross linkers. + + # Test script section order. +-@NATIVE_OR_CROSS_LINKER_TRUE@am__append_87 = script_test_10.sh +-@NATIVE_OR_CROSS_LINKER_TRUE@am__append_88 = script_test_10.stdout +-@NATIVE_OR_CROSS_LINKER_TRUE@am__append_89 = script_test_10 ++@NATIVE_OR_CROSS_LINKER_TRUE@am__append_88 = script_test_10.sh ++@NATIVE_OR_CROSS_LINKER_TRUE@am__append_89 = script_test_10.stdout ++@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = script_test_10 + + # These tests work with cross linkers only. +-@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_90 = split_i386.sh +-@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = split_i386_1.stdout split_i386_2.stdout \ ++@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_91 = split_i386.sh ++@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_92 = split_i386_1.stdout split_i386_2.stdout \ + @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout + +-@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_92 = split_i386_1 split_i386_2 split_i386_3 \ ++@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_93 = split_i386_1 split_i386_2 split_i386_3 \ + @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_i386_4 split_i386_r + +-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_93 = split_x86_64.sh \ ++@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_94 = split_x86_64.sh \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_plt_1.sh \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_1.sh \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_2.sh +-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_94 = split_x86_64_1.stdout \ ++@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_95 = split_x86_64_1.stdout \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_2.stdout \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_3.stdout \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_4.stdout \ +@@ -845,14 +846,14 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_plt_1.stdout \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_1.stdout \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ bnd_ifunc_2.stdout +-@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_95 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \ ++@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_96 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \ + @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_4 split_x86_64_r + +-@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_96 = split_x32.sh +-@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_97 = split_x32_1.stdout split_x32_2.stdout \ ++@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_97 = split_x32.sh ++@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_98 = split_x32_1.stdout split_x32_2.stdout \ + @DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x32_3.stdout split_x32_4.stdout split_x32_r.stdout + +-@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_98 = split_x32_1 split_x32_2 split_x32_3 \ ++@DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_99 = split_x32_1 split_x32_2 split_x32_3 \ + @DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x32_4 split_x32_r + + +@@ -873,7 +874,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + # Check Thumb to ARM farcall veneers + + # Check handling of --target1-abs, --target1-rel and --target2 options +-@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_99 = arm_abs_global.sh \ ++@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_100 = arm_abs_global.sh \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_in_range.sh \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_out_of_range.sh \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_fix_v4bx.sh \ +@@ -896,7 +897,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel.sh + + # The test demonstrates why the constructor of a target object should not access options. +-@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_100 = arm_abs_global.stdout \ ++@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_101 = arm_abs_global.stdout \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range.stdout \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range.stdout \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ thumb_bl_in_range.stdout \ +@@ -949,7 +950,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs.stdout \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel.stdout \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target_lazy_init +-@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_101 = arm_abs_global \ ++@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_102 = arm_abs_global \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ thumb_bl_in_range \ +@@ -1000,20 +1001,20 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel \ + @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target_lazy_init +-@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_102 = aarch64_reloc_none.sh \ ++@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_103 = aarch64_reloc_none.sh \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_relocs.sh \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ pr21430.sh \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_tlsdesc.sh +-@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_103 = aarch64_reloc_none.stdout \ ++@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_104 = aarch64_reloc_none.stdout \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_relocs.stdout \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ pr21430.stdout \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_tlsdesc.stdout +-@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_104 = aarch64_reloc_none \ ++@DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_105 = aarch64_reloc_none \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_relocs \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ pr21430 \ + @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_tlsdesc +-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_105 = split_s390.sh +-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_106 = split_s390_z1.stdout split_s390_z2.stdout split_s390_z3.stdout \ ++@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_106 = split_s390.sh ++@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_107 = split_s390_z1.stdout split_s390_z2.stdout split_s390_z3.stdout \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z4.stdout split_s390_n1.stdout split_s390_n2.stdout \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_a1.stdout split_s390_a2.stdout split_s390_z1_ns.stdout \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z2_ns.stdout split_s390_z3_ns.stdout split_s390_z4_ns.stdout \ +@@ -1025,7 +1026,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z4_ns.stdout split_s390x_n1_ns.stdout \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_n2_ns.stdout split_s390x_r.stdout + +-@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_107 = split_s390_z1 split_s390_z2 split_s390_z3 \ ++@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_108 = split_s390_z1 split_s390_z2 split_s390_z3 \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z4 split_s390_n1 split_s390_n2 split_s390_a1 \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_a2 split_s390_z1_ns split_s390_z2_ns split_s390_z3_ns \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390_z4_ns split_s390_n1_ns split_s390_n2_ns split_s390_r \ +@@ -1034,10 +1035,10 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__E + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z1_ns split_s390x_z2_ns split_s390x_z3_ns \ + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z4_ns split_s390x_n1_ns split_s390x_n2_ns split_s390x_r + +-@DEFAULT_TARGET_X86_64_TRUE@am__append_108 = *.dwo *.dwp +-@DEFAULT_TARGET_X86_64_TRUE@am__append_109 = dwp_test_1.sh \ ++@DEFAULT_TARGET_X86_64_TRUE@am__append_109 = *.dwo *.dwp ++@DEFAULT_TARGET_X86_64_TRUE@am__append_110 = dwp_test_1.sh \ + @DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.sh +-@DEFAULT_TARGET_X86_64_TRUE@am__append_110 = dwp_test_1.stdout \ ++@DEFAULT_TARGET_X86_64_TRUE@am__append_111 = dwp_test_1.stdout \ + @DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.stdout + subdir = testsuite + DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am +@@ -1243,6 +1244,11 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest + @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_40 = \ + @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_x86_64_bnd_test$(EXEEXT) + @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_41 = pr22266$(EXEEXT) ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_42 = aarch64_pr23870$(EXEEXT) ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_aarch64_pr23870_OBJECTS = aarch64_pr23870_foo.$(OBJEXT) ++aarch64_pr23870_OBJECTS = $(am_aarch64_pr23870_OBJECTS) ++aarch64_pr23870_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ ++ $(aarch64_pr23870_LDFLAGS) $(LDFLAGS) -o $@ + basic_pic_test_SOURCES = basic_pic_test.c + basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT) + basic_pic_test_LDADD = $(LDADD) +@@ -2392,7 +2398,7 @@ am__depfiles_maybe = depfiles + am__mv = mv -f + CCLD = $(CC) + CXXLD = $(CXX) +-SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ ++SOURCES = $(libgoldtest_a_SOURCES) $(aarch64_pr23870_SOURCES) basic_pic_test.c basic_pie_test.c \ + basic_static_pic_test.c basic_static_test.c basic_test.c \ + $(binary_test_SOURCES) $(binary_unittest_SOURCES) \ + $(common_test_1_SOURCES) $(common_test_2_SOURCES) \ +@@ -2830,9 +2836,9 @@ MOSTLYCLEANFILES = *.so *.syms *.stdout + $(am__append_34) $(am__append_37) $(am__append_41) \ + $(am__append_47) $(am__append_51) $(am__append_52) \ + $(am__append_58) $(am__append_78) $(am__append_81) \ +- $(am__append_83) $(am__append_89) $(am__append_92) \ +- $(am__append_95) $(am__append_98) $(am__append_101) \ +- $(am__append_104) $(am__append_107) $(am__append_108) ++ $(am__append_83) $(am__append_90) $(am__append_93) \ ++ $(am__append_96) $(am__append_99) $(am__append_102) \ ++ $(am__append_105) $(am__append_108) $(am__append_109) + + # We will add to these later, for each individual test. Note + # that we add each test under check_SCRIPTS or check_PROGRAMS; +@@ -2842,17 +2848,17 @@ check_SCRIPTS = $(am__append_2) $(am__ap + $(am__append_45) $(am__append_49) $(am__append_53) \ + $(am__append_56) $(am__append_62) $(am__append_73) \ + $(am__append_76) $(am__append_79) $(am__append_84) \ +- $(am__append_87) $(am__append_90) $(am__append_93) \ +- $(am__append_96) $(am__append_99) $(am__append_102) \ +- $(am__append_105) $(am__append_109) ++ $(am__append_88) $(am__append_91) $(am__append_94) \ ++ $(am__append_97) $(am__append_100) $(am__append_103) \ ++ $(am__append_106) $(am__append_110) + check_DATA = $(am__append_3) $(am__append_20) $(am__append_24) \ + $(am__append_30) $(am__append_36) $(am__append_43) \ + $(am__append_46) $(am__append_50) $(am__append_54) \ + $(am__append_57) $(am__append_63) $(am__append_74) \ + $(am__append_77) $(am__append_80) $(am__append_85) \ +- $(am__append_88) $(am__append_91) $(am__append_94) \ +- $(am__append_97) $(am__append_100) $(am__append_103) \ +- $(am__append_106) $(am__append_110) ++ $(am__append_89) $(am__append_92) $(am__append_95) \ ++ $(am__append_98) $(am__append_101) $(am__append_104) \ ++ $(am__append_107) $(am__append_111) + BUILT_SOURCES = $(am__append_40) + TESTS = $(check_SCRIPTS) $(check_PROGRAMS) + +@@ -3408,6 +3414,13 @@ LDADD = libgoldtest.a ../libgold.a ../.. + @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_DEPENDENCIES = gcctestdir/ld exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o + @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDFLAGS = $(exception_test_LDFLAGS) -Wl,-z,bndplt + @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@exception_x86_64_bnd_test_LDADD = exception_x86_64_bnd_1.o exception_x86_64_bnd_2.o ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_SOURCES = aarch64_pr23870_foo.c ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_DEPENDENCIES = \ ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld gcctestdir/as aarch64_pr23870_main.o \ ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ aarch64_pr23870_foo.o aarch64_pr23870_bar.so ++ ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_LDFLAGS = -Wl,-R,. -L. -Wl,-l:aarch64_pr23870_bar.so ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_LDADD = aarch64_pr23870_main.o + @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 + @DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 + @DEFAULT_TARGET_X32_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@SPLIT_DEFSYMS = --defsym __morestack=0x100 --defsym __morestack_non_split=0x200 +@@ -3457,6 +3470,11 @@ libgoldtest.a: $(libgoldtest_a_OBJECTS) + + clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) ++ ++aarch64_pr23870$(EXEEXT): $(aarch64_pr23870_OBJECTS) $(aarch64_pr23870_DEPENDENCIES) $(EXTRA_aarch64_pr23870_DEPENDENCIES) ++ @rm -f aarch64_pr23870$(EXEEXT) ++ $(AM_V_CCLD)$(aarch64_pr23870_LINK) $(aarch64_pr23870_OBJECTS) $(aarch64_pr23870_LDADD) $(LIBS) ++ + @GCC_FALSE@basic_pic_test$(EXEEXT): $(basic_pic_test_OBJECTS) $(basic_pic_test_DEPENDENCIES) $(EXTRA_basic_pic_test_DEPENDENCIES) + @GCC_FALSE@ @rm -f basic_pic_test$(EXEEXT) + @GCC_FALSE@ $(LINK) $(basic_pic_test_OBJECTS) $(basic_pic_test_LDADD) $(LIBS) +@@ -4397,6 +4415,7 @@ mostlyclean-compile: + distclean-compile: + -rm -f *.tab.c + ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/aarch64_pr23870_foo.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic_pic_test.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic_pie_test.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basic_static_pic_test.Po@am__quote@ +@@ -5741,6 +5760,13 @@ pr22266.log: pr22266$(EXEEXT) + @p='pr22266$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) + gnu_property_test.sh.log: gnu_property_test.sh + @p='gnu_property_test.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) ++aarch64_pr23870.log: aarch64_pr23870$(EXEEXT) ++ @p='aarch64_pr23870$(EXEEXT)'; \ ++ b='aarch64_pr23870'; \ ++ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ ++ --log-file $$b.log --trs-file $$b.trs \ ++ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ ++ "$$tst" $(AM_TESTS_FD_REDIRECT) + .test.log: + @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post) + @am__EXEEXT_TRUE@.test$(EXEEXT).log: +@@ -7414,6 +7440,14 @@ uninstall-am: + @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(LINK) -Bgcctestdir/ pr22266_main.o pr22266_ar.o + @GCC_TRUE@@NATIVE_LINKER_TRUE@pr22266_ar.o: pr22266_a.o gcctestdir/ld + @GCC_TRUE@@NATIVE_LINKER_TRUE@ gcctestdir/ld -r -T $(srcdir)/pr22266_script.t -o $@ pr22266_a.o ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_main.o: aarch64_pr23870_main.S ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -o $@ $< ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_foo.o: aarch64_pr23870_foo.c ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -o $@ $< ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_bar.o: aarch64_pr23870_bar.c ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -c -fPIC -o $@ $< ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@aarch64_pr23870_bar.so: aarch64_pr23870_bar.o ++@DEFAULT_TARGET_AARCH64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(COMPILE) -shared -o $@ $< + @NATIVE_OR_CROSS_LINKER_TRUE@script_test_10.o: script_test_10.s + @NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $< + @NATIVE_OR_CROSS_LINKER_TRUE@script_test_10: $(srcdir)/script_test_10.t script_test_10.o gcctestdir/ld diff --git a/SOURCES/binutils-CVE-2018-10372.patch b/SOURCES/binutils-CVE-2018-10372.patch new file mode 100644 index 0000000..073a407 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-10372.patch @@ -0,0 +1,22 @@ +--- binutils.orig/binutils/dwarf.c 2018-05-01 11:42:02.656431736 +0100 ++++ binutils-2.30/binutils/dwarf.c 2018-05-01 11:43:24.210383020 +0100 +@@ -9244,7 +9244,18 @@ process_cu_tu_index (struct dwarf_sectio + } + + if (!do_display) +- memcpy (&this_set[row - 1].signature, ph, sizeof (uint64_t)); ++ { ++ size_t num_copy = sizeof (uint64_t); ++ ++ /* PR 23064: Beware of buffer overflow. */ ++ if (ph + num_copy < limit) ++ memcpy (&this_set[row - 1].signature, ph, num_copy); ++ else ++ { ++ warn (_("Signature (%p) extends beyond end of space in section\n"), ph); ++ return 0; ++ } ++ } + + prow = poffsets + (row - 1) * ncols * 4; + /* PR 17531: file: b8ce60a8. */ diff --git a/SOURCES/binutils-CVE-2018-10373.patch b/SOURCES/binutils-CVE-2018-10373.patch new file mode 100644 index 0000000..21964f8 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-10373.patch @@ -0,0 +1,11 @@ +--- binutils.orig/bfd/dwarf2.c 2018-05-01 11:42:03.152425647 +0100 ++++ binutils-2.30/bfd/dwarf2.c 2018-05-01 12:03:27.533735710 +0100 +@@ -1559,7 +1559,7 @@ concat_filename (struct line_info_table + { + char *filename; + +- if (file - 1 >= table->num_files) ++ if (table == NULL || file - 1 >= table->num_files) + { + /* FILE == 0 means unknown. */ + if (file) diff --git a/SOURCES/binutils-CVE-2018-10534.patch b/SOURCES/binutils-CVE-2018-10534.patch new file mode 100644 index 0000000..d06f9ea --- /dev/null +++ b/SOURCES/binutils-CVE-2018-10534.patch @@ -0,0 +1,18 @@ +--- binutils.orig/bfd/peXXigen.c 2018-05-10 10:09:03.619147342 +0100 ++++ binutils-2.30/bfd/peXXigen.c 2018-05-10 10:20:20.884883540 +0100 +@@ -2991,6 +2991,15 @@ _bfd_XX_bfd_copy_private_bfd_data_common + bfd_get_section_size (section) - (addr - section->vma)); + return FALSE; + } ++ /* PR 23110. */ ++ else if (ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size < 0) ++ { ++ /* xgettext:c-format */ ++ _bfd_error_handler ++ (_("%pB: Data Directory size (%#lx) is negative"), ++ obfd, ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size); ++ return FALSE; ++ } + + for (i = 0; i < ope->pe_opthdr.DataDirectory[PE_DEBUG_DATA].Size + / sizeof (struct external_IMAGE_DEBUG_DIRECTORY); i++) diff --git a/SOURCES/binutils-CVE-2018-10535.patch b/SOURCES/binutils-CVE-2018-10535.patch new file mode 100644 index 0000000..a442e47 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-10535.patch @@ -0,0 +1,28 @@ +--- binutils.orig/bfd/elf.c 2018-05-10 10:09:03.622147305 +0100 ++++ binutils-2.30/bfd/elf.c 2018-05-10 10:29:09.895577234 +0100 +@@ -4021,16 +4021,23 @@ ignore_section_sym (bfd *abfd, asymbol * + { + elf_symbol_type *type_ptr; + ++ if (sym == NULL) ++ return FALSE; ++ + if ((sym->flags & BSF_SECTION_SYM) == 0) + return FALSE; + ++ if (sym->section == NULL) ++ return TRUE; ++ + type_ptr = elf_symbol_from (abfd, sym); + return ((type_ptr != NULL + && type_ptr->internal_elf_sym.st_shndx != 0 + && bfd_is_abs_section (sym->section)) + || !(sym->section->owner == abfd +- || (sym->section->output_section->owner == abfd +- && sym->section->output_offset == 0) ++ || (sym->section->output_section != NULL ++ && sym->section->output_section->owner == abfd ++ && sym->section->output_offset == 0) + || bfd_is_abs_section (sym->section))); + } + diff --git a/SOURCES/binutils-CVE-2018-17358.patch b/SOURCES/binutils-CVE-2018-17358.patch new file mode 100644 index 0000000..df860f5 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-17358.patch @@ -0,0 +1,101 @@ +diff -rup binutils.orig/bfd/dwarf2.c binutils-2.30/bfd/dwarf2.c +--- binutils.orig/bfd/dwarf2.c 2018-09-26 15:07:47.162863937 +0100 ++++ binutils-2.30/bfd/dwarf2.c 2018-09-26 15:08:50.868368183 +0100 +@@ -527,6 +527,7 @@ read_section (bfd * abfd, + asection *msec; + const char *section_name = sec->uncompressed_name; + bfd_byte *contents = *section_buffer; ++ bfd_size_type amt; + + /* The section may have already been read. */ + if (contents == NULL) +@@ -549,7 +550,14 @@ read_section (bfd * abfd, + *section_size = msec->rawsize ? msec->rawsize : msec->size; + /* Paranoia - alloc one extra so that we can make sure a string + section is NUL terminated. */ +- contents = (bfd_byte *) bfd_malloc (*section_size + 1); ++ amt = *section_size + 1; ++ if (amt == 0) ++ { ++ bfd_set_error (bfd_error_no_memory); ++ return FALSE; ++ } ++ contents = (bfd_byte *) bfd_malloc (amt); ++ + if (contents == NULL) + return FALSE; + if (syms +diff -rup binutils.orig/bfd/syms.c binutils-2.30/bfd/syms.c +--- binutils.orig/bfd/syms.c 2018-09-26 15:07:47.162863937 +0100 ++++ binutils-2.30/bfd/syms.c 2018-09-26 15:11:41.671038993 +0100 +@@ -1035,6 +1035,10 @@ _bfd_stab_section_find_nearest_line (bfd + 0, strsize)) + return FALSE; + ++ /* Stab strings ought to be nul terminated. Ensure the last one ++ is, to prevent running off the end of the buffer. */ ++ info->strs[strsize - 1] = 0; ++ + /* If this is a relocatable object file, we have to relocate + the entries in .stab. This should always be simple 32 bit + relocations against symbols defined in this object file, so +@@ -1073,7 +1077,8 @@ _bfd_stab_section_find_nearest_line (bfd + || r->howto->bitsize != 32 + || r->howto->pc_relative + || r->howto->bitpos != 0 +- || r->howto->dst_mask != 0xffffffff) ++ || r->howto->dst_mask != 0xffffffff ++ || r->address * bfd_octets_per_byte (abfd) + 4 > stabsize) + { + _bfd_error_handler + (_("Unsupported .stab relocation")); +@@ -1195,7 +1200,8 @@ _bfd_stab_section_find_nearest_line (bfd + { + nul_fun = stab; + nul_str = str; +- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) ++ if (file_name >= (char *) info->strs + strsize ++ || file_name < (char *) str) + file_name = NULL; + if (stab + STABSIZE + TYPEOFF < info->stabs + stabsize + && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO) +@@ -1206,7 +1212,8 @@ _bfd_stab_section_find_nearest_line (bfd + directory_name = file_name; + file_name = ((char *) str + + bfd_get_32 (abfd, stab + STRDXOFF)); +- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) ++ if (file_name >= (char *) info->strs + strsize ++ || file_name < (char *) str) + file_name = NULL; + } + } +@@ -1217,7 +1224,8 @@ _bfd_stab_section_find_nearest_line (bfd + file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); + /* PR 17512: file: 0c680a1f. */ + /* PR 17512: file: 5da8aec4. */ +- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) ++ if (file_name >= (char *) info->strs + strsize ++ || file_name < (char *) str) + file_name = NULL; + break; + +@@ -1226,7 +1234,8 @@ _bfd_stab_section_find_nearest_line (bfd + function_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); + if (function_name == (char *) str) + continue; +- if (function_name >= (char *) info->strs + strsize) ++ if (function_name >= (char *) info->strs + strsize ++ || function_name < (char *) str) + function_name = NULL; + + nul_fun = NULL; +@@ -1335,7 +1344,8 @@ _bfd_stab_section_find_nearest_line (bfd + if (val <= offset) + { + file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF); +- if (file_name >= (char *) info->strs + strsize || file_name < (char *) str) ++ if (file_name >= (char *) info->strs + strsize ++ || file_name < (char *) str) + file_name = NULL; + *pline = 0; + } diff --git a/SOURCES/binutils-CVE-2018-6323.patch b/SOURCES/binutils-CVE-2018-6323.patch new file mode 100644 index 0000000..bb698b8 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-6323.patch @@ -0,0 +1,20 @@ +--- binutils.orig/bfd/elfcode.h 2018-05-01 11:42:03.250424443 +0100 ++++ binutils-2.30/bfd/elfcode.h 2018-05-01 12:41:00.745780026 +0100 +@@ -680,7 +680,7 @@ elf_object_p (bfd *abfd) + if (i_ehdrp->e_shnum > ((bfd_size_type) -1) / sizeof (*i_shdrp)) + goto got_wrong_format_error; + #endif +- amt = sizeof (*i_shdrp) * i_ehdrp->e_shnum; ++ amt = sizeof (*i_shdrp) * (bfd_size_type) i_ehdrp->e_shnum; + i_shdrp = (Elf_Internal_Shdr *) bfd_alloc (abfd, amt); + if (!i_shdrp) + goto got_no_match; +@@ -776,7 +776,7 @@ elf_object_p (bfd *abfd) + if (i_ehdrp->e_phnum > ((bfd_size_type) -1) / sizeof (*i_phdr)) + goto got_wrong_format_error; + #endif +- amt = i_ehdrp->e_phnum * sizeof (*i_phdr); ++ amt = (bfd_size_type) i_ehdrp->e_phnum * sizeof (*i_phdr); + elf_tdata (abfd)->phdr = (Elf_Internal_Phdr *) bfd_alloc (abfd, amt); + if (elf_tdata (abfd)->phdr == NULL) + goto got_no_match; diff --git a/SOURCES/binutils-CVE-2018-6759.patch b/SOURCES/binutils-CVE-2018-6759.patch new file mode 100644 index 0000000..c52a636 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-6759.patch @@ -0,0 +1,69 @@ +--- binutils.orig/bfd/opncls.c 2018-05-01 11:42:03.266424248 +0100 ++++ binutils-2.30/bfd/opncls.c 2018-05-01 12:52:36.792579838 +0100 +@@ -1179,6 +1179,7 @@ bfd_get_debug_link_info_1 (bfd *abfd, vo + bfd_byte *contents; + unsigned int crc_offset; + char *name; ++ bfd_size_type size; + + BFD_ASSERT (abfd); + BFD_ASSERT (crc32_out); +@@ -1188,6 +1189,12 @@ bfd_get_debug_link_info_1 (bfd *abfd, vo + if (sect == NULL) + return NULL; + ++ size = bfd_get_section_size (sect); ++ ++ /* PR 22794: Make sure that the section has a reasonable size. */ ++ if (size < 8 || size >= bfd_get_size (abfd)) ++ return NULL; ++ + if (!bfd_malloc_and_get_section (abfd, sect, &contents)) + { + if (contents != NULL) +@@ -1198,9 +1205,9 @@ bfd_get_debug_link_info_1 (bfd *abfd, vo + /* CRC value is stored after the filename, aligned up to 4 bytes. */ + name = (char *) contents; + /* PR 17597: avoid reading off the end of the buffer. */ +- crc_offset = strnlen (name, bfd_get_section_size (sect)) + 1; ++ crc_offset = strnlen (name, size) + 1; + crc_offset = (crc_offset + 3) & ~3; +- if (crc_offset + 4 > bfd_get_section_size (sect)) ++ if (crc_offset + 4 > size) + return NULL; + + *crc32 = bfd_get_32 (abfd, contents + crc_offset); +@@ -1261,6 +1268,7 @@ bfd_get_alt_debug_link_info (bfd * abfd, + bfd_byte *contents; + unsigned int buildid_offset; + char *name; ++ bfd_size_type size; + + BFD_ASSERT (abfd); + BFD_ASSERT (buildid_len); +@@ -1271,6 +1279,10 @@ bfd_get_alt_debug_link_info (bfd * abfd, + if (sect == NULL) + return NULL; + ++ size = bfd_get_section_size (sect); ++ if (size < 8 || size >= bfd_get_size (abfd)) ++ return NULL; ++ + if (!bfd_malloc_and_get_section (abfd, sect, & contents)) + { + if (contents != NULL) +@@ -1280,11 +1292,11 @@ bfd_get_alt_debug_link_info (bfd * abfd, + + /* BuildID value is stored after the filename. */ + name = (char *) contents; +- buildid_offset = strnlen (name, bfd_get_section_size (sect)) + 1; +- if (buildid_offset >= bfd_get_section_size (sect)) ++ buildid_offset = strnlen (name, size) + 1; ++ if (buildid_offset >= size) + return NULL; + +- *buildid_len = bfd_get_section_size (sect) - buildid_offset; ++ *buildid_len = size - buildid_offset; + *buildid_out = bfd_malloc (*buildid_len); + memcpy (*buildid_out, contents + buildid_offset, *buildid_len); + diff --git a/SOURCES/binutils-CVE-2018-7208.patch b/SOURCES/binutils-CVE-2018-7208.patch new file mode 100644 index 0000000..c817edc --- /dev/null +++ b/SOURCES/binutils-CVE-2018-7208.patch @@ -0,0 +1,12 @@ +--- binutils.orig/bfd/coffgen.c 2018-04-27 09:23:33.449859052 +0100 ++++ binutils-2.30/bfd/coffgen.c 2018-04-27 09:34:34.530135122 +0100 +@@ -1555,7 +1555,8 @@ coff_pointerize_aux (bfd *abfd, + } + /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can + generate one, so we must be careful to ignore it. */ +- if (auxent->u.auxent.x_sym.x_tagndx.l > 0) ++ if ((unsigned long) auxent->u.auxent.x_sym.x_tagndx.l ++ < obj_raw_syment_count (abfd)) + { + auxent->u.auxent.x_sym.x_tagndx.p = + table_base + auxent->u.auxent.x_sym.x_tagndx.l; diff --git a/SOURCES/binutils-CVE-2018-7568.patch b/SOURCES/binutils-CVE-2018-7568.patch new file mode 100644 index 0000000..7ce6f3e --- /dev/null +++ b/SOURCES/binutils-CVE-2018-7568.patch @@ -0,0 +1,37 @@ +--- binutils.orig/bfd/dwarf1.c 2018-05-01 13:04:35.060041875 +0100 ++++ binutils-2.30/bfd/dwarf1.c 2018-05-01 13:24:17.943833855 +0100 +@@ -213,6 +213,7 @@ parse_die (bfd * abfd, + /* Then the attributes. */ + while (xptr + 2 <= aDiePtrEnd) + { ++ unsigned int block_len; + unsigned short attr; + + /* Parse the attribute based on its form. This section +@@ -255,12 +256,24 @@ parse_die (bfd * abfd, + break; + case FORM_BLOCK2: + if (xptr + 2 <= aDiePtrEnd) +- xptr += bfd_get_16 (abfd, xptr); ++ { ++ block_len = bfd_get_16 (abfd, xptr); ++ if (xptr + block_len > aDiePtrEnd ++ || xptr + block_len < xptr) ++ return FALSE; ++ xptr += block_len; ++ } + xptr += 2; + break; + case FORM_BLOCK4: + if (xptr + 4 <= aDiePtrEnd) +- xptr += bfd_get_32 (abfd, xptr); ++ { ++ block_len = bfd_get_32 (abfd, xptr); ++ if (xptr + block_len > aDiePtrEnd ++ || xptr + block_len < xptr) ++ return FALSE; ++ xptr += block_len; ++ } + xptr += 4; + break; + case FORM_STRING: diff --git a/SOURCES/binutils-CVE-2018-7569.patch b/SOURCES/binutils-CVE-2018-7569.patch new file mode 100644 index 0000000..32962bd --- /dev/null +++ b/SOURCES/binutils-CVE-2018-7569.patch @@ -0,0 +1,75 @@ +--- binutils.orig/bfd/dwarf2.c 2018-05-01 13:04:35.055041935 +0100 ++++ binutils-2.30/bfd/dwarf2.c 2018-05-01 13:31:32.882624448 +0100 +@@ -622,14 +622,24 @@ read_8_bytes (bfd *abfd, bfd_byte *buf, + } + + static bfd_byte * +-read_n_bytes (bfd *abfd ATTRIBUTE_UNUSED, +- bfd_byte *buf, +- bfd_byte *end, +- unsigned int size ATTRIBUTE_UNUSED) +-{ +- if (buf + size > end) +- return NULL; +- return buf; ++read_n_bytes (bfd_byte * buf, ++ bfd_byte * end, ++ struct dwarf_block * block) ++{ ++ unsigned int size = block->size; ++ bfd_byte * block_end = buf + size; ++ ++ if (block_end > end || block_end < buf) ++ { ++ block->data = NULL; ++ block->size = 0; ++ return end; ++ } ++ else ++ { ++ block->data = buf; ++ return block_end; ++ } + } + + /* Scans a NUL terminated string starting at BUF, returning a pointer to it. +@@ -1127,8 +1137,7 @@ read_attribute_value (struct attribute * + return NULL; + blk->size = read_2_bytes (abfd, info_ptr, info_ptr_end); + info_ptr += 2; +- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); +- info_ptr += blk->size; ++ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); + attr->u.blk = blk; + break; + case DW_FORM_block4: +@@ -1138,8 +1147,7 @@ read_attribute_value (struct attribute * + return NULL; + blk->size = read_4_bytes (abfd, info_ptr, info_ptr_end); + info_ptr += 4; +- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); +- info_ptr += blk->size; ++ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); + attr->u.blk = blk; + break; + case DW_FORM_data2: +@@ -1179,8 +1187,7 @@ read_attribute_value (struct attribute * + blk->size = _bfd_safe_read_leb128 (abfd, info_ptr, &bytes_read, + FALSE, info_ptr_end); + info_ptr += bytes_read; +- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); +- info_ptr += blk->size; ++ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); + attr->u.blk = blk; + break; + case DW_FORM_block1: +@@ -1190,8 +1197,7 @@ read_attribute_value (struct attribute * + return NULL; + blk->size = read_1_byte (abfd, info_ptr, info_ptr_end); + info_ptr += 1; +- blk->data = read_n_bytes (abfd, info_ptr, info_ptr_end, blk->size); +- info_ptr += blk->size; ++ info_ptr = read_n_bytes (info_ptr, info_ptr_end, blk); + attr->u.blk = blk; + break; + case DW_FORM_data1: diff --git a/SOURCES/binutils-CVE-2018-7570.patch b/SOURCES/binutils-CVE-2018-7570.patch new file mode 100644 index 0000000..e057d63 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-7570.patch @@ -0,0 +1,156 @@ +--- binutils.orig/bfd/elf.c 2018-05-01 11:42:03.151425659 +0100 ++++ binutils-2.30/bfd/elf.c 2018-05-01 12:30:42.129206856 +0100 +@@ -5713,6 +5713,9 @@ assign_file_positions_for_load_sections + return TRUE; + } + ++#define IS_TBSS(s) \ ++ ((s->flags & (SEC_THREAD_LOCAL | SEC_LOAD)) == SEC_THREAD_LOCAL) ++ + /* Assign file positions for the other sections. */ + + static bfd_boolean +@@ -5862,65 +5865,100 @@ assign_file_positions_for_non_load_secti + { + if (p->p_type == PT_GNU_RELRO) + { +- const Elf_Internal_Phdr *lp; +- struct elf_segment_map *lm; ++ bfd_vma start, end; ++ bfd_boolean ok; + + if (link_info != NULL) + { + /* During linking the range of the RELRO segment is passed +- in link_info. */ ++ in link_info. Note that there may be padding between ++ relro_start and the first RELRO section. */ ++ start = link_info->relro_start; ++ end = link_info->relro_end; ++ } ++ else if (m->count != 0) ++ { ++ if (!m->p_size_valid) ++ abort (); ++ start = m->sections[0]->vma; ++ end = start + m->p_size; ++ } ++ else ++ { ++ start = 0; ++ end = 0; ++ } ++ ++ ok = FALSE; ++ if (start < end) ++ { ++ struct elf_segment_map *lm; ++ const Elf_Internal_Phdr *lp; ++ unsigned int i; ++ ++ /* Find a LOAD segment containing a section in the RELRO ++ segment. */ + for (lm = elf_seg_map (abfd), lp = phdrs; + lm != NULL; + lm = lm->next, lp++) + { + if (lp->p_type == PT_LOAD +- && lp->p_vaddr < link_info->relro_end + && lm->count != 0 +- && lm->sections[0]->vma >= link_info->relro_start) ++ && (lm->sections[lm->count - 1]->vma ++ + (!IS_TBSS (lm->sections[lm->count - 1]) ++ ? lm->sections[lm->count - 1]->size ++ : 0)) > start ++ && lm->sections[0]->vma < end) + break; + } + +- BFD_ASSERT (lm != NULL); +- } +- else +- { +- /* Otherwise we are copying an executable or shared +- library, but we need to use the same linker logic. */ +- for (lp = phdrs; lp < phdrs + count; ++lp) ++ if (lm != NULL) + { +- if (lp->p_type == PT_LOAD +- && lp->p_paddr == p->p_paddr) +- break; ++ /* Find the section starting the RELRO segment. */ ++ for (i = 0; i < lm->count; i++) ++ { ++ asection *s = lm->sections[i]; ++ if (s->vma >= start ++ && s->vma < end ++ && s->size != 0) ++ break; ++ } ++ ++ if (i < lm->count) ++ { ++ p->p_vaddr = lm->sections[i]->vma; ++ p->p_paddr = lm->sections[i]->lma; ++ p->p_offset = lm->sections[i]->filepos; ++ p->p_memsz = end - p->p_vaddr; ++ p->p_filesz = p->p_memsz; ++ ++ /* The RELRO segment typically ends a few bytes ++ into .got.plt but other layouts are possible. ++ In cases where the end does not match any ++ loaded section (for instance is in file ++ padding), trim p_filesz back to correspond to ++ the end of loaded section contents. */ ++ if (p->p_filesz > lp->p_vaddr + lp->p_filesz - p->p_vaddr) ++ p->p_filesz = lp->p_vaddr + lp->p_filesz - p->p_vaddr; ++ ++ /* Preserve the alignment and flags if they are ++ valid. The gold linker generates RW/4 for ++ the PT_GNU_RELRO section. It is better for ++ objcopy/strip to honor these attributes ++ otherwise gdb will choke when using separate ++ debug files. */ ++ if (!m->p_align_valid) ++ p->p_align = 1; ++ if (!m->p_flags_valid) ++ p->p_flags = PF_R; ++ ok = TRUE; ++ } + } + } +- +- if (lp < phdrs + count) +- { +- p->p_vaddr = lp->p_vaddr; +- p->p_paddr = lp->p_paddr; +- p->p_offset = lp->p_offset; +- if (link_info != NULL) +- p->p_filesz = link_info->relro_end - lp->p_vaddr; +- else if (m->p_size_valid) +- p->p_filesz = m->p_size; +- else +- abort (); +- p->p_memsz = p->p_filesz; +- /* Preserve the alignment and flags if they are valid. The +- gold linker generates RW/4 for the PT_GNU_RELRO section. +- It is better for objcopy/strip to honor these attributes +- otherwise gdb will choke when using separate debug files. +- */ +- if (!m->p_align_valid) +- p->p_align = 1; +- if (!m->p_flags_valid) +- p->p_flags = PF_R; +- } +- else +- { +- memset (p, 0, sizeof *p); +- p->p_type = PT_NULL; +- } ++ if (link_info != NULL) ++ BFD_ASSERT (ok); ++ if (!ok) ++ memset (p, 0, sizeof *p); + } + else if (p->p_type == PT_GNU_STACK) + { diff --git a/SOURCES/binutils-CVE-2018-7642.patch b/SOURCES/binutils-CVE-2018-7642.patch new file mode 100644 index 0000000..62178da --- /dev/null +++ b/SOURCES/binutils-CVE-2018-7642.patch @@ -0,0 +1,17 @@ +--- binutils.orig/bfd/aoutx.h 2018-04-26 15:14:18.411450291 +0100 ++++ binutils-2.30/bfd/aoutx.h 2018-04-26 17:22:38.328770529 +0100 +@@ -2283,10 +2283,12 @@ NAME (aout, swap_std_reloc_in) (bfd *abf + if (r_baserel) + r_extern = 1; + +- if (r_extern && r_index > symcount) ++ if (r_extern && r_index >= symcount) + { + /* We could arrange to return an error, but it might be useful +- to see the file even if it is bad. */ ++ to see the file even if it is bad. FIXME: Of course this ++ means that objdump -r *doesn't* see the actual reloc, and ++ objcopy silently writes a different reloc. */ + r_extern = 0; + r_index = N_ABS; + } diff --git a/SOURCES/binutils-CVE-2018-7643.patch b/SOURCES/binutils-CVE-2018-7643.patch new file mode 100644 index 0000000..6ccf257 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-7643.patch @@ -0,0 +1,16 @@ +--- binutils.orig/binutils/dwarf.c 2018-04-27 09:22:07.402864408 +0100 ++++ binutils-2.30/binutils/dwarf.c 2018-04-27 09:24:26.794235786 +0100 +@@ -6810,6 +6810,13 @@ display_debug_ranges (struct dwarf_secti + continue; + } + ++ if (next < section_begin || next >= finish) ++ { ++ warn (_("Corrupt offset (%#8.8lx) in range entry %u\n"), ++ (unsigned long) offset, i); ++ continue; ++ } ++ + if (dwarf_check != 0 && i > 0) + { + if (start < next) diff --git a/SOURCES/binutils-CVE-2018-8945.patch b/SOURCES/binutils-CVE-2018-8945.patch new file mode 100644 index 0000000..33ec9f5 --- /dev/null +++ b/SOURCES/binutils-CVE-2018-8945.patch @@ -0,0 +1,29 @@ +diff -rup binutils.orig/bfd/elf-attrs.c binutils-2.30/bfd/elf-attrs.c +--- binutils.orig/bfd/elf-attrs.c 2018-05-17 14:14:04.341805666 +0100 ++++ binutils-2.30/bfd/elf-attrs.c 2018-05-17 14:15:19.729952453 +0100 +@@ -438,6 +438,14 @@ _bfd_elf_parse_attributes (bfd *abfd, El + /* PR 17512: file: 2844a11d. */ + if (hdr->sh_size == 0) + return; ++ if (hdr->sh_size > bfd_get_file_size (abfd)) ++ { ++ _bfd_error_handler (_("%pB: error: attribute section '%pA' too big: %#llx"), ++ abfd, hdr->bfd_section, (long long) hdr->sh_size); ++ bfd_set_error (bfd_error_invalid_operation); ++ return; ++ } ++ + contents = (bfd_byte *) bfd_malloc (hdr->sh_size + 1); + if (!contents) + return; +diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c +--- binutils.orig/bfd/elf.c 2018-05-17 14:14:04.326805836 +0100 ++++ binutils-2.30/bfd/elf.c 2018-05-17 14:15:59.412503342 +0100 +@@ -298,6 +298,7 @@ bfd_elf_get_str_section (bfd *abfd, unsi + /* Allocate and clear an extra byte at the end, to prevent crashes + in case the string table is not terminated. */ + if (shstrtabsize + 1 <= 1 ++ || shstrtabsize > bfd_get_file_size (abfd) + || bfd_seek (abfd, offset, SEEK_SET) != 0 + || (shstrtab = (bfd_byte *) bfd_alloc (abfd, shstrtabsize + 1)) == NULL) + shstrtab = NULL; diff --git a/SOURCES/binutils-CVE-2019-1010204.patch b/SOURCES/binutils-CVE-2019-1010204.patch new file mode 100644 index 0000000..d1d949f --- /dev/null +++ b/SOURCES/binutils-CVE-2019-1010204.patch @@ -0,0 +1,15 @@ +--- binutils.orig/gold/fileread.cc 2019-11-08 10:33:58.911577903 +0000 ++++ binutils-2.30/gold/fileread.cc 2019-11-08 10:34:13.001470092 +0000 +@@ -381,6 +381,12 @@ File_read::do_read(off_t start, section_ + ssize_t bytes; + if (this->whole_file_view_ != NULL) + { ++ // See PR 23765 for an example of a testcase that triggers this error. ++ if (((ssize_t) start) < 0) ++ gold_fatal(_("%s: read failed, starting offset (%#llx) less than zero"), ++ this->filename().c_str(), ++ static_cast(start)); ++ + bytes = this->size_ - start; + if (static_cast(bytes) >= size) + { diff --git a/SOURCES/binutils-CVE-2019-14444.patch b/SOURCES/binutils-CVE-2019-14444.patch new file mode 100644 index 0000000..ad554f5 --- /dev/null +++ b/SOURCES/binutils-CVE-2019-14444.patch @@ -0,0 +1,11 @@ +--- binutils.orig/binutils/readelf.c 2019-08-13 10:03:33.518792590 +0100 ++++ binutils-2.32/binutils/readelf.c 2019-08-13 10:04:22.885418269 +0100 +@@ -13234,7 +13234,7 @@ apply_relocations (Filedata * + } + + rloc = start + rp->r_offset; +- if ((rloc + reloc_size) > end || (rloc < start)) ++ if (rloc >= end || (rloc + reloc_size) > end || (rloc < start)) + { + warn (_("skipping invalid relocation offset 0x%lx in section %s\n"), + (unsigned long) rp->r_offset, diff --git a/SOURCES/binutils-CVE-2019-17450.patch b/SOURCES/binutils-CVE-2019-17450.patch new file mode 100644 index 0000000..63affa9 --- /dev/null +++ b/SOURCES/binutils-CVE-2019-17450.patch @@ -0,0 +1,62 @@ +--- binutils.orig/bfd/dwarf2.c 2019-12-03 15:50:43.324118062 +0000 ++++ binutils-2.30/bfd/dwarf2.c 2019-12-03 15:54:32.545489215 +0000 +@@ -2803,8 +2803,8 @@ lookup_symbol_in_variable_table (struct + + static bfd_boolean + find_abstract_instance_name (struct comp_unit *unit, +- bfd_byte *orig_info_ptr, + struct attribute *attr_ptr, ++ unsigned int recur_count, + const char **pname, + bfd_boolean *is_linkage) + { +@@ -2817,6 +2817,14 @@ find_abstract_instance_name (struct comp + struct attribute attr; + const char *name = NULL; + ++ if (recur_count == 100) ++ { ++ _bfd_error_handler ++ (_("DWARF error: abstract instance recursion detected")); ++ bfd_set_error (bfd_error_bad_value); ++ return FALSE; ++ } ++ + /* DW_FORM_ref_addr can reference an entry in a different CU. It + is an offset from the .debug_info section, not the current CU. */ + if (attr_ptr->form == DW_FORM_ref_addr) +@@ -2934,15 +2942,7 @@ find_abstract_instance_name (struct comp + info_ptr, info_ptr_end); + if (info_ptr == NULL) + break; +- /* It doesn't ever make sense for DW_AT_specification to +- refer to the same DIE. Stop simple recursion. */ +- if (info_ptr == orig_info_ptr) +- { +- _bfd_error_handler +- (_("Dwarf Error: Abstract instance recursion detected.")); +- bfd_set_error (bfd_error_bad_value); +- return FALSE; +- } ++ + switch (attr.name) + { + case DW_AT_name: +@@ -2956,7 +2956,7 @@ find_abstract_instance_name (struct comp + } + break; + case DW_AT_specification: +- if (!find_abstract_instance_name (unit, info_ptr, &attr, ++ if (!find_abstract_instance_name (unit, &attr, recur_count + 1, + pname, is_linkage)) + return FALSE; + break; +@@ -3162,7 +3162,7 @@ scan_unit_for_symbols (struct comp_unit + + case DW_AT_abstract_origin: + case DW_AT_specification: +- if (!find_abstract_instance_name (unit, info_ptr, &attr, ++ if (!find_abstract_instance_name (unit, &attr, 0, + &func->name, + &func->is_linkage)) + goto fail; diff --git a/SOURCES/binutils-CVE-2019-17451.patch b/SOURCES/binutils-CVE-2019-17451.patch new file mode 100644 index 0000000..0f503a3 --- /dev/null +++ b/SOURCES/binutils-CVE-2019-17451.patch @@ -0,0 +1,20 @@ +--- binutils.orig/bfd/dwarf2.c 2019-11-13 11:32:09.395430104 +0000 ++++ binutils-2.33.1/bfd/dwarf2.c 2019-11-13 11:33:17.272899503 +0000 +@@ -4440,7 +4440,16 @@ _bfd_dwarf2_slurp_debug_info (bfd *abfd, + for (total_size = 0; + msec; + msec = find_debug_info (debug_bfd, debug_sections, msec)) +- total_size += msec->size; ++ { ++ /* Catch PR25070 testcase overflowing size calculation here. */ ++ if (total_size + msec->size < total_size ++ || total_size + msec->size < msec->size) ++ { ++ bfd_set_error (bfd_error_no_memory); ++ return FALSE; ++ } ++ total_size += msec->size; ++ } + + stash->info_ptr_memory = (bfd_byte *) bfd_malloc (total_size); + if (stash->info_ptr_memory == NULL) diff --git a/SOURCES/binutils-CVE-2021-20197.patch b/SOURCES/binutils-CVE-2021-20197.patch new file mode 100644 index 0000000..cea8953 --- /dev/null +++ b/SOURCES/binutils-CVE-2021-20197.patch @@ -0,0 +1,1287 @@ +diff -rup binutils.orig/bfd/bfd-in2.h binutils-2.35.1/bfd/bfd-in2.h +--- binutils.orig/bfd/bfd-in2.h 2021-01-29 11:14:51.848568548 +0000 ++++ binutils-2.35.1/bfd/bfd-in2.h 2021-01-29 11:15:33.431322133 +0000 +@@ -583,6 +583,8 @@ bfd *bfd_openr (const char *filename, co + + bfd *bfd_fdopenr (const char *filename, const char *target, int fd); + ++bfd *bfd_fdopenw (const char *filename, const char *target, int fd); ++ + bfd *bfd_openstreamr (const char * filename, const char * target, + void * stream); + +diff -rup binutils.orig/bfd/opncls.c binutils-2.35.1/bfd/opncls.c +--- binutils.orig/bfd/opncls.c 2021-01-29 11:14:51.846568560 +0000 ++++ binutils-2.35.1/bfd/opncls.c 2021-01-29 11:15:33.431322133 +0000 +@@ -395,6 +395,39 @@ bfd_fdopenr (const char *filename, const + + /* + FUNCTION ++ bfd_fdopenw ++ ++SYNOPSIS ++ bfd *bfd_fdopenw (const char *filename, const char *target, int fd); ++ ++DESCRIPTION ++ <> is exactly like <> with the exception that ++ the resulting BFD is suitable for output. ++*/ ++ ++bfd * ++bfd_fdopenw (const char *filename, const char *target, int fd) ++{ ++ bfd *out = bfd_fdopenr (filename, target, fd); ++ ++ if (out != NULL) ++ { ++ if (!bfd_write_p (out)) ++ { ++ close (fd); ++ _bfd_delete_bfd (out); ++ out = NULL; ++ bfd_set_error (bfd_error_invalid_operation); ++ } ++ else ++ out->direction = write_direction; ++ } ++ ++ return out; ++} ++ ++/* ++FUNCTION + bfd_openstreamr + + SYNOPSIS +diff -rup binutils.orig/binutils/ar.c binutils-2.35.1/binutils/ar.c +--- binutils.orig/binutils/ar.c 2021-01-29 11:14:51.344571539 +0000 ++++ binutils-2.35.1/binutils/ar.c 2021-01-29 11:15:56.174187367 +0000 +@@ -25,6 +25,7 @@ + + #include "sysdep.h" + #include "bfd.h" ++#include "libbfd.h" + #include "libiberty.h" + #include "progress.h" + #include "getopt.h" +@@ -1195,20 +1196,26 @@ write_archive (bfd *iarch) + bfd *obfd; + char *old_name, *new_name; + bfd *contents_head = iarch->archive_next; ++ int ofd = -1; ++ struct stat target_stat; ++ bfd_boolean skip_stat = FALSE; + + old_name = (char *) xmalloc (strlen (bfd_get_filename (iarch)) + 1); + strcpy (old_name, bfd_get_filename (iarch)); +- new_name = make_tempname (old_name); ++ new_name = make_tempname (old_name, &ofd); + + if (new_name == NULL) + bfd_fatal (_("could not create temporary file whilst writing archive")); + + output_filename = new_name; + +- obfd = bfd_openw (new_name, bfd_get_target (iarch)); ++ obfd = bfd_fdopenw (new_name, bfd_get_target (iarch), ofd); + + if (obfd == NULL) +- bfd_fatal (old_name); ++ { ++ close (ofd); ++ bfd_fatal (old_name); ++ } + + output_bfd = obfd; + +@@ -1237,6 +1244,14 @@ write_archive (bfd *iarch) + if (!bfd_set_archive_head (obfd, contents_head)) + bfd_fatal (old_name); + ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++ ofd = dup (ofd); ++ if (iarch == NULL || iarch->iostream == NULL) ++ skip_stat = TRUE; ++ else if (ofd == -1 || fstat (fileno (iarch->iostream), &target_stat) != 0) ++ bfd_fatal (old_name); ++#endif ++ + if (!bfd_close (obfd)) + bfd_fatal (old_name); + +@@ -1246,7 +1261,7 @@ write_archive (bfd *iarch) + /* We don't care if this fails; we might be creating the archive. */ + bfd_close (iarch); + +- if (smart_rename (new_name, old_name, 0) != 0) ++ if (smart_rename (new_name, old_name, ofd, skip_stat ? NULL : &target_stat, 0) != 0) + xexit (1); + free (old_name); + free (new_name); +diff -rup binutils.orig/binutils/arsup.c binutils-2.35.1/binutils/arsup.c +--- binutils.orig/binutils/arsup.c 2021-01-29 11:14:51.350571503 +0000 ++++ binutils-2.35.1/binutils/arsup.c 2021-01-29 11:15:56.174187367 +0000 +@@ -345,13 +345,25 @@ ar_save (void) + else + { + char *ofilename = xstrdup (bfd_get_filename (obfd)); ++ bfd_boolean skip_stat = FALSE; ++ struct stat target_stat; ++ int ofd = -1; + + if (deterministic > 0) + obfd->flags |= BFD_DETERMINISTIC_OUTPUT; + ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++ /* It's OK to fail; at worst it will result in SMART_RENAME using a slow ++ copy fallback to write the output. */ ++ ofd = dup (fileno (obfd->iostream)); ++ if (lstat (real_name, &target_stat) != 0) ++ skip_stat = TRUE; ++#endif ++ + bfd_close (obfd); + +- smart_rename (ofilename, real_name, 0); ++ smart_rename (ofilename, real_name, ofd, ++ skip_stat ? NULL : &target_stat, 0); + obfd = 0; + free (ofilename); + } +diff -rup binutils.orig/binutils/bucomm.c binutils-2.35.1/binutils/bucomm.c +--- binutils.orig/binutils/bucomm.c 2021-01-29 11:14:51.422571073 +0000 ++++ binutils-2.35.1/binutils/bucomm.c 2021-01-29 11:15:33.431322133 +0000 +@@ -532,7 +532,7 @@ template_in_dir (const char *path) + as FILENAME. */ + + char * +-make_tempname (char *filename) ++make_tempname (const char *filename, int *ofd) + { + char *tmpname = template_in_dir (filename); + int fd; +@@ -550,7 +550,7 @@ make_tempname (const char *filename) + free (tmpname); + return NULL; + } +- close (fd); ++ *ofd = fd; + return tmpname; + } + +diff -rup binutils.orig/binutils/bucomm.h binutils-2.35.1/binutils/bucomm.h +--- binutils.orig/binutils/bucomm.h 2021-01-29 11:14:51.350571503 +0000 ++++ binutils-2.35.1/binutils/bucomm.h 2021-01-29 11:15:56.174187367 +0000 +@@ -51,7 +51,7 @@ int display_info (void); + + void print_arelt_descr (FILE *, bfd *, bfd_boolean); + +-char *make_tempname (char *); ++char *make_tempname (const char *, int *); + char *make_tempdir (char *); + + bfd_vma parse_vma (const char *, const char *); +@@ -71,7 +71,8 @@ extern void print_version (const char *) + /* In rename.c. */ + extern void set_times (const char *, const struct stat *); + +-extern int smart_rename (const char *, const char *, int); ++extern int smart_rename (const char *, const char *, int, struct stat *, int); ++ + + /* In libiberty. */ + void *xmalloc (size_t); +diff -rup binutils.orig/binutils/objcopy.c binutils-2.35.1/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2021-01-29 11:14:51.342571551 +0000 ++++ binutils-2.35.1/binutils/objcopy.c 2021-01-29 11:15:56.175187361 +0000 +@@ -20,6 +20,7 @@ + + #include "sysdep.h" + #include "bfd.h" ++#include "libbfd.h" + #include "progress.h" + #include "getopt.h" + #include "libiberty.h" +@@ -3711,9 +3712,9 @@ set_long_section_mode (bfd *output_bfd, + /* The top-level control. */ + + static void +-copy_file (const char *input_filename, const char *output_filename, +- const char *input_target, const char *output_target, +- const bfd_arch_info_type *input_arch) ++copy_file (const char *input_filename, const char *output_filename, int ofd, ++ struct stat *in_stat, const char *input_target, ++ const char *output_target, const bfd_arch_info_type *input_arch) + { + bfd *ibfd; + char **obj_matching; +@@ -3732,7 +3733,7 @@ copy_file (const char *input_filename, c + /* To allow us to do "strip *" without dying on the first + non-object file, failures are nonfatal. */ + ibfd = bfd_openr (input_filename, input_target); +- if (ibfd == NULL) ++ if (ibfd == NULL || fstat (fileno (ibfd->iostream), in_stat) != 0) + { + bfd_nonfatal_message (input_filename, NULL, NULL, NULL); + status = 1; +@@ -3786,9 +3787,14 @@ copy_file (const char *input_filename, c + else + force_output_target = TRUE; + +- obfd = bfd_openw (output_filename, output_target); ++ if (ofd >= 0) ++ obfd = bfd_fdopenw (output_filename, output_target, ofd); ++ else ++ obfd = bfd_openw (output_filename, output_target); ++ + if (obfd == NULL) + { ++ close (ofd); + bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + status = 1; + return; +@@ -3816,13 +3822,19 @@ copy_file (const char *input_filename, c + if (output_target == NULL) + output_target = bfd_get_target (ibfd); + +- obfd = bfd_openw (output_filename, output_target); ++ if (ofd >= 0) ++ obfd = bfd_fdopenw (output_filename, output_target, ofd); ++ else ++ obfd = bfd_openw (output_filename, output_target); ++ + if (obfd == NULL) + { ++ close (ofd); + bfd_nonfatal_message (output_filename, NULL, NULL, NULL); + status = 1; + return; + } ++ + /* This is a no-op on non-Coff targets. */ + set_long_section_mode (obfd, ibfd, long_section_names); + +@@ -4786,6 +4798,8 @@ strip_main (int argc, char *argv[]) + int hold_status = status; + struct stat statbuf; + char *tmpname; ++ int tmpfd = -1; ++ int copyfd = -1; + + if (get_file_size (argv[i]) < 1) + { +@@ -4793,18 +4807,18 @@ strip_main (int argc, char *argv[]) + continue; + } + +- if (preserve_dates) +- /* No need to check the return value of stat(). +- It has already been checked in get_file_size(). */ +- stat (argv[i], &statbuf); +- + if (output_file == NULL + || filename_cmp (argv[i], output_file) == 0) +- tmpname = make_tempname (argv[i]); ++ tmpname = make_tempname (argv[i], &tmpfd); + else + tmpname = output_file; + +- if (tmpname == NULL) ++ if (tmpname == NULL ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++ /* Retain a copy of TMPFD since we will need it for SMART_RENAME. */ ++ || (tmpfd >= 0 && (copyfd = dup (tmpfd)) == -1) ++#endif ++ ) + { + bfd_nonfatal_message (argv[i], NULL, NULL, + _("could not create temporary file to hold stripped copy")); +@@ -4813,7 +4827,8 @@ strip_main (int argc, char *argv[]) + } + + status = 0; +- copy_file (argv[i], tmpname, input_target, output_target, NULL); ++ copy_file (argv[i], tmpname, tmpfd, &statbuf, input_target, ++ output_target, NULL); + if (status == 0) + { + if (preserve_dates) +@@ -4821,12 +4836,18 @@ strip_main (int argc, char *argv[]) + if (output_file != tmpname) + status = (smart_rename (tmpname, + output_file ? output_file : argv[i], +- preserve_dates) != 0); ++ copyfd, &statbuf, preserve_dates) != 0); + if (status == 0) + status = hold_status; + } + else +- unlink_if_ordinary (tmpname); ++ { ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++ if (copyfd >= 0) ++ close (copyfd); ++#endif ++ unlink_if_ordinary (tmpname); ++ } + if (output_file != tmpname) + free (tmpname); + } +@@ -5033,7 +5054,8 @@ copy_main (int argc, char *argv[]) + bfd_boolean show_version = FALSE; + bfd_boolean change_warn = TRUE; + bfd_boolean formats_info = FALSE; +- int c; ++ int c, tmpfd = -1; ++ int copyfd = -1; + struct stat statbuf; + const bfd_arch_info_type *input_arch = NULL; + +@@ -5870,34 +5892,43 @@ copy_main (int argc, char *argv[]) + convert_efi_target (efi); + } + +- if (preserve_dates) +- if (stat (input_filename, & statbuf) < 0) +- fatal (_("warning: could not locate '%s'. System error message: %s"), +- input_filename, strerror (errno)); +- + /* If there is no destination file, or the source and destination files + are the same, then create a temp and rename the result into the input. */ + if (output_filename == NULL + || filename_cmp (input_filename, output_filename) == 0) +- tmpname = make_tempname (input_filename); ++ tmpname = make_tempname (input_filename, &tmpfd); + else + tmpname = output_filename; + +- if (tmpname == NULL) +- fatal (_("warning: could not create temporary file whilst copying '%s', (error: %s)"), +- input_filename, strerror (errno)); ++ if (tmpname == NULL ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++ /* Retain a copy of TMPFD since we will need it for SMART_RENAME. */ ++ || (tmpfd >= 0 && (copyfd = dup (tmpfd)) == -1) ++#endif ++ ) ++ { ++ fatal (_("warning: could not create temporary file whilst copying '%s', (error: %s)"), ++ input_filename, strerror (errno)); ++ } + +- copy_file (input_filename, tmpname, input_target, output_target, input_arch); ++ copy_file (input_filename, tmpname, tmpfd, &statbuf, input_target, ++ output_target, input_arch); + if (status == 0) + { + if (preserve_dates) + set_times (tmpname, &statbuf); + if (tmpname != output_filename) +- status = (smart_rename (tmpname, input_filename, ++ status = (smart_rename (tmpname, input_filename, copyfd, &statbuf, + preserve_dates) != 0); + } + else +- unlink_if_ordinary (tmpname); ++ { ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++ if (copyfd >= 0) ++ close (copyfd); ++#endif ++ unlink_if_ordinary (tmpname); ++ } + + if (tmpname != output_filename) + free (tmpname); +diff -rup binutils.orig/binutils/rename.c binutils-2.35.1/binutils/rename.c +--- binutils.orig/binutils/rename.c 2021-01-29 11:14:51.422571073 +0000 ++++ binutils-2.35.1/binutils/rename.c 2021-01-29 11:15:56.175187361 +0000 +@@ -131,17 +131,55 @@ set_times (const char *destination, cons + #endif + #endif + +-/* Rename FROM to TO, copying if TO is a link. +- Return 0 if ok, -1 if error. */ ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++/* Try to preserve the permission bits and ownership of an existing file when ++ rename overwrites it. FD is the file being renamed and TARGET_STAT has the ++ status of the file that was overwritten. */ ++static void ++try_preserve_permissions (int fd, struct stat *target_stat) ++{ ++ struct stat from_stat; ++ int ret = 0; ++ ++ if (fstat (fd, &from_stat) != 0) ++ return; ++ ++ int from_mode = from_stat.st_mode & 0777; ++ int to_mode = target_stat->st_mode & 0777; ++ ++ /* Fix up permissions before we potentially lose ownership with fchown. ++ Clear the setxid bits because in case the fchown below fails then we don't ++ want to end up with a sxid file owned by the invoking user. If the user ++ hasn't changed or if fchown succeeded, we add back the sxid bits at the ++ end. */ ++ if (from_mode != to_mode) ++ fchmod (fd, to_mode); ++ ++ /* Fix up ownership, this will clear the setxid bits. */ ++ if (from_stat.st_uid != target_stat->st_uid ++ || from_stat.st_gid != target_stat->st_gid) ++ ret = fchown (fd, target_stat->st_uid, target_stat->st_gid); ++ ++ /* Fix up the sxid bits if either the fchown wasn't needed or it ++ succeeded. */ ++ if (ret == 0) ++ fchmod (fd, target_stat->st_mode & 07777); ++} ++#endif ++ ++/* Rename FROM to TO, copying if TO is either a link or is not a regular file. ++ FD is an open file descriptor pointing to FROM that we can use to safely fix ++ up permissions of the file after renaming. TARGET_STAT has the file status ++ that is used to fix up permissions and timestamps after rename. Return 0 if ++ ok, -1 if error and FD is closed before returning. */ + + int +-smart_rename (const char *from, const char *to, int preserve_dates ATTRIBUTE_UNUSED) ++smart_rename (const char *from, const char *to, int fd ATTRIBUTE_UNUSED, ++ struct stat *target_stat ATTRIBUTE_UNUSED, ++ int preserve_dates ATTRIBUTE_UNUSED) + { +- bfd_boolean exists; +- struct stat s; + int ret = 0; +- +- exists = lstat (to, &s) == 0; ++ bfd_boolean exists = target_stat != NULL; + + #if defined (_WIN32) && !defined (__CYGWIN32__) + /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but +@@ -158,36 +196,35 @@ smart_rename (const char *from, const ch + unlink (from); + } + #else +- /* Use rename only if TO is not a symbolic link and has +- only one hard link, and we have permission to write to it. */ ++ /* Avoid a full copy and use rename if we can fix up permissions of the ++ file after renaming, i.e.: ++ ++ - TO is not a symbolic link ++ - TO is a regular file with only one hard link ++ - We have permission to write to TO ++ - FD is available to safely fix up permissions to be the same as the file ++ we overwrote with the rename. ++ ++ Note though that the actual file on disk that TARGET_STAT describes may ++ have changed and we're only trying to preserve the status we know about. ++ At no point do we try to interact with the new file changes, so there can ++ only be two outcomes, i.e. either the external file change survives ++ without knowledge of our change (if it happens after the rename syscall) ++ or our rename and permissions fixup survive without any knowledge of the ++ external change. */ + if (! exists +- || (!S_ISLNK (s.st_mode) +- && S_ISREG (s.st_mode) +- && (s.st_mode & S_IWUSR) +- && s.st_nlink == 1) ++ || (fd >= 0 ++ && !S_ISLNK (target_stat->st_mode) ++ && S_ISREG (target_stat->st_mode) ++ && (target_stat->st_mode & S_IWUSR) ++ && target_stat->st_nlink == 1) + ) + { + ret = rename (from, to); + if (ret == 0) + { + if (exists) +- { +- /* Try to preserve the permission bits and ownership of +- TO. First get the mode right except for the setuid +- bit. Then change the ownership. Then fix the setuid +- bit. We do the chmod before the chown because if the +- chown succeeds, and we are a normal user, we won't be +- able to do the chmod afterward. We don't bother to +- fix the setuid bit first because that might introduce +- a fleeting security problem, and because the chown +- will clear the setuid bit anyhow. We only fix the +- setuid bit if the chown succeeds, because we don't +- want to introduce an unexpected setuid file owned by +- the user running objcopy. */ +- chmod (to, s.st_mode & 0777); +- if (chown (to, s.st_uid, s.st_gid) >= 0) +- chmod (to, s.st_mode & 07777); +- } ++ try_preserve_permissions (fd, target_stat); + } + else + { +@@ -203,9 +240,11 @@ smart_rename (const char *from, const ch + non_fatal (_("unable to copy file '%s'; reason: %s"), to, strerror (errno)); + + if (preserve_dates) +- set_times (to, &s); ++ set_times (to, target_stat); + unlink (from); + } ++ if (fd >= 0) ++ close (fd); + #endif /* _WIN32 && !__CYGWIN32__ */ + + return ret; +diff -rup binutils.orig/binutils/ar.c binutils-2.35.1/binutils/ar.c +--- binutils.orig/binutils/ar.c 2021-02-02 13:01:42.257734944 +0000 ++++ binutils-2.35.1/binutils/ar.c 2021-02-02 13:11:13.340958352 +0000 +@@ -25,7 +25,6 @@ + + #include "sysdep.h" + #include "bfd.h" +-#include "libbfd.h" + #include "libiberty.h" + #include "progress.h" + #include "getopt.h" +@@ -1198,10 +1197,8 @@ write_archive (bfd *iarch) + bfd *contents_head = iarch->archive_next; + int ofd = -1; + struct stat target_stat; +- bfd_boolean skip_stat = FALSE; + +- old_name = (char *) xmalloc (strlen (bfd_get_filename (iarch)) + 1); +- strcpy (old_name, bfd_get_filename (iarch)); ++ old_name = xstrdup (bfd_get_filename (iarch)); + new_name = make_tempname (old_name, &ofd); + + if (new_name == NULL) +@@ -1246,11 +1243,9 @@ write_archive (bfd *iarch) + + #if !defined (_WIN32) || defined (__CYGWIN32__) + ofd = dup (ofd); +- if (iarch == NULL || iarch->iostream == NULL) +- skip_stat = TRUE; +- else if (ofd == -1 || fstat (fileno (iarch->iostream), &target_stat) != 0) +- bfd_fatal (old_name); + #endif ++ if (ofd == -1 || bfd_stat (iarch, &target_stat) != 0) ++ bfd_fatal (old_name); + + if (!bfd_close (obfd)) + bfd_fatal (old_name); +@@ -1261,7 +1256,7 @@ write_archive (bfd *iarch) + /* We don't care if this fails; we might be creating the archive. */ + bfd_close (iarch); + +- if (smart_rename (new_name, old_name, ofd, skip_stat ? NULL : &target_stat, 0) != 0) ++ if (smart_rename (new_name, old_name, ofd, &target_stat, 0) != 0) + xexit (1); + free (old_name); + free (new_name); +Only in binutils-2.35.1/binutils/: ar.c.orig +Only in binutils-2.35.1/binutils/: ar.c.rej +diff -rup binutils.orig/binutils/arsup.c binutils-2.35.1/binutils/arsup.c +--- binutils.orig/binutils/arsup.c 2021-02-02 13:01:42.208735269 +0000 ++++ binutils-2.35.1/binutils/arsup.c 2021-02-02 13:11:55.725678308 +0000 +@@ -42,6 +42,8 @@ extern int deterministic; + + static bfd *obfd; + static char *real_name; ++static char *temp_name; ++static int real_ofd; + static FILE *outfile; + + static void +@@ -149,20 +151,24 @@ maybequit (void) + void + ar_open (char *name, int t) + { +- char *tname = (char *) xmalloc (strlen (name) + 10); +- const char *bname = lbasename (name); +- real_name = name; +- +- /* Prepend tmp- to the beginning, to avoid file-name clashes after +- truncation on filesystems with limited namespaces (DOS). */ +- sprintf (tname, "%.*stmp-%s", (int) (bname - name), name, bname); ++ real_name = xstrdup (name); ++ temp_name = make_tempname (real_name, &real_ofd); ++ ++ if (temp_name == NULL) ++ { ++ fprintf (stderr, _("%s: Can't open temporary file (%s)\n"), ++ program_name, strerror(errno)); ++ maybequit (); ++ return; ++ } ++ +- obfd = bfd_openw (tname, NULL); ++ obfd = bfd_fdopenw (temp_name, NULL, real_ofd); + + if (!obfd) + { + fprintf (stderr, + _("%s: Can't open output archive %s\n"), +- program_name, tname); ++ program_name, temp_name); + + maybequit (); + } +@@ -344,10 +343,9 @@ ar_save (void) + } + else + { +- char *ofilename = xstrdup (bfd_get_filename (obfd)); + bfd_boolean skip_stat = FALSE; + struct stat target_stat; +- int ofd = -1; ++ int ofd = real_ofd; + + if (deterministic > 0) + obfd->flags |= BFD_DETERMINISTIC_OUTPUT; +@@ -355,17 +353,18 @@ ar_save (void) + #if !defined (_WIN32) || defined (__CYGWIN32__) + /* It's OK to fail; at worst it will result in SMART_RENAME using a slow + copy fallback to write the output. */ +- ofd = dup (fileno (obfd->iostream)); +- if (lstat (real_name, &target_stat) != 0) +- skip_stat = TRUE; ++ ofd = dup (ofd); + #endif +- + bfd_close (obfd); + +- smart_rename (ofilename, real_name, ofd, ++ if (ofd == -1 || fstat (ofd, &target_stat) != 0) ++ skip_stat = TRUE; ++ ++ smart_rename (temp_name, real_name, ofd, + skip_stat ? NULL : &target_stat, 0); + obfd = 0; +- free (ofilename); ++ free (temp_name); ++ free (real_name); + } + } + +diff -rup binutils.orig/binutils/objcopy.c binutils-2.35.1/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2021-02-02 13:01:42.214735229 +0000 ++++ binutils-2.35.1/binutils/objcopy.c 2021-02-02 13:13:27.613071192 +0000 +@@ -20,7 +20,6 @@ + + #include "sysdep.h" + #include "bfd.h" +-#include "libbfd.h" + #include "progress.h" + #include "getopt.h" + #include "libiberty.h" +@@ -3733,7 +3732,7 @@ copy_file (const char *input_filename, c + /* To allow us to do "strip *" without dying on the first + non-object file, failures are nonfatal. */ + ibfd = bfd_openr (input_filename, input_target); +- if (ibfd == NULL || fstat (fileno (ibfd->iostream), in_stat) != 0) ++ if (ibfd == NULL || bfd_stat (ibfd, in_stat) != 0) + { + bfd_nonfatal_message (input_filename, NULL, NULL, NULL); + status = 1; +--- binutils.orig/binutils/arsup.c 2021-02-04 10:42:03.265729780 +0000 ++++ binutils-2.35.1/binutils/arsup.c 2021-02-04 10:45:48.439166658 +0000 +@@ -357,8 +357,21 @@ ar_save (void) + #endif + bfd_close (obfd); + +- if (ofd == -1 || fstat (ofd, &target_stat) != 0) +- skip_stat = TRUE; ++ if (lstat (real_name, &target_stat) != 0) ++ { ++ /* The temp file created in ar_open has mode 0600 as per mkstemp. ++ Create the real empty output file here so smart_rename will ++ update the mode according to the process umask. */ ++ obfd = bfd_openw (real_name, NULL); ++ if (obfd == NULL ++ || bfd_stat (obfd, &target_stat) != 0) ++ skip_stat = TRUE; ++ if (obfd != NULL) ++ { ++ bfd_set_format (obfd, bfd_archive); ++ bfd_close (obfd); ++ } ++ } + + smart_rename (temp_name, real_name, ofd, + skip_stat ? NULL : &target_stat, 0); +--- binutils.orig/binutils/rename.c 2021-02-08 11:02:58.767933783 +0000 ++++ binutils-2.35.1/binutils/rename.c 2021-02-08 11:20:37.539179363 +0000 +@@ -179,7 +179,10 @@ smart_rename (const char *from, const ch + int preserve_dates ATTRIBUTE_UNUSED) + { + int ret = 0; +- bfd_boolean exists = target_stat != NULL; ++ struct stat to_stat; ++ bfd_boolean exists; ++ ++ exists = lstat (to, &to_stat) == 0; + + #if defined (_WIN32) && !defined (__CYGWIN32__) + /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but +@@ -214,16 +217,16 @@ smart_rename (const char *from, const ch + external change. */ + if (! exists + || (fd >= 0 +- && !S_ISLNK (target_stat->st_mode) +- && S_ISREG (target_stat->st_mode) +- && (target_stat->st_mode & S_IWUSR) +- && target_stat->st_nlink == 1) ++ && !S_ISLNK (to_stat.st_mode) ++ && S_ISREG (to_stat.st_mode) ++ && (to_stat.st_mode & S_IWUSR) ++ && to_stat.st_nlink == 1) + ) + { + ret = rename (from, to); + if (ret == 0) + { +- if (exists) ++ if (exists && target_stat != NULL) + try_preserve_permissions (fd, target_stat); + } + else +@@ -239,7 +242,7 @@ smart_rename (const char *from, const ch + if (ret != 0) + non_fatal (_("unable to copy file '%s'; reason: %s"), to, strerror (errno)); + +- if (preserve_dates) ++ if (preserve_dates && target_stat != NULL) + set_times (to, target_stat); + unlink (from); + } +diff -rup binutils.orig/binutils/ar.c binutils-2.35.1/binutils/ar.c +--- binutils.orig/binutils/ar.c 2021-03-11 12:38:18.183422774 +0000 ++++ binutils-2.35.1/binutils/ar.c 2021-03-11 12:45:09.279716067 +0000 +@@ -1195,22 +1195,21 @@ write_archive (bfd *iarch) + bfd *obfd; + char *old_name, *new_name; + bfd *contents_head = iarch->archive_next; +- int ofd = -1; +- struct stat target_stat; ++ int tmpfd = -1; + + old_name = xstrdup (bfd_get_filename (iarch)); +- new_name = make_tempname (old_name, &ofd); ++ new_name = make_tempname (old_name, &tmpfd); + + if (new_name == NULL) + bfd_fatal (_("could not create temporary file whilst writing archive")); + + output_filename = new_name; + +- obfd = bfd_fdopenw (new_name, bfd_get_target (iarch), ofd); ++ obfd = bfd_fdopenw (new_name, bfd_get_target (iarch), tmpfd); + + if (obfd == NULL) + { +- close (ofd); ++ close (tmpfd); + bfd_fatal (old_name); + } + +@@ -1241,12 +1240,7 @@ write_archive (bfd *iarch) + if (!bfd_set_archive_head (obfd, contents_head)) + bfd_fatal (old_name); + +-#if !defined (_WIN32) || defined (__CYGWIN32__) +- ofd = dup (ofd); +-#endif +- if (ofd == -1 || bfd_stat (iarch, &target_stat) != 0) +- bfd_fatal (old_name); +- ++ tmpfd = dup (tmpfd); + if (!bfd_close (obfd)) + bfd_fatal (old_name); + +@@ -1256,7 +1250,7 @@ write_archive (bfd *iarch) + /* We don't care if this fails; we might be creating the archive. */ + bfd_close (iarch); + +- if (smart_rename (new_name, old_name, ofd, &target_stat, 0) != 0) ++ if (smart_rename (new_name, old_name, tmpfd, NULL, FALSE) != 0) + xexit (1); + free (old_name); + free (new_name); +diff -rup binutils.orig/binutils/arsup.c binutils-2.35.1/binutils/arsup.c +--- binutils.orig/binutils/arsup.c 2021-03-11 12:38:18.182422781 +0000 ++++ binutils-2.35.1/binutils/arsup.c 2021-03-11 12:47:43.246702325 +0000 +@@ -43,7 +43,7 @@ extern int deterministic; + static bfd *obfd; + static char *real_name; + static char *temp_name; +-static int real_ofd; ++static int temp_fd; + static FILE *outfile; + + static void +@@ -152,7 +152,7 @@ void + ar_open (char *name, int t) + { + real_name = xstrdup (name); +- temp_name = make_tempname (real_name, &real_ofd); ++ temp_name = make_tempname (real_name, &temp_fd); + + if (temp_name == NULL) + { +@@ -162,7 +162,7 @@ ar_open (char *name, int t) + return; + } + +- obfd = bfd_fdopenw (temp_name, NULL, real_ofd); ++ obfd = bfd_fdopenw (temp_name, NULL, temp_fd); + + if (!obfd) + { +@@ -343,29 +343,20 @@ ar_save (void) + } + else + { +- bfd_boolean skip_stat = FALSE; + struct stat target_stat; +- int ofd = real_ofd; + + if (deterministic > 0) + obfd->flags |= BFD_DETERMINISTIC_OUTPUT; + +-#if !defined (_WIN32) || defined (__CYGWIN32__) +- /* It's OK to fail; at worst it will result in SMART_RENAME using a slow +- copy fallback to write the output. */ +- ofd = dup (ofd); +-#endif ++ temp_fd = dup (temp_fd); + bfd_close (obfd); + +- if (lstat (real_name, &target_stat) != 0) ++ if (stat (real_name, &target_stat) != 0) + { + /* The temp file created in ar_open has mode 0600 as per mkstemp. + Create the real empty output file here so smart_rename will + update the mode according to the process umask. */ + obfd = bfd_openw (real_name, NULL); +- if (obfd == NULL +- || bfd_stat (obfd, &target_stat) != 0) +- skip_stat = TRUE; + if (obfd != NULL) + { + bfd_set_format (obfd, bfd_archive); +@@ -373,9 +364,8 @@ ar_save (void) + } + } + +- smart_rename (temp_name, real_name, ofd, +- skip_stat ? NULL : &target_stat, 0); +- obfd = 0; ++ smart_rename (temp_name, real_name, temp_fd, NULL, FALSE); ++ obfd = NULL; + free (temp_name); + free (real_name); + } +diff -rup binutils.orig/binutils/bucomm.h binutils-2.35.1/binutils/bucomm.h +--- binutils.orig/binutils/bucomm.h 2021-03-11 12:38:18.183422774 +0000 ++++ binutils-2.35.1/binutils/bucomm.h 2021-03-11 12:42:22.320815334 +0000 +@@ -71,7 +71,8 @@ extern void print_version (const char *) + /* In rename.c. */ + extern void set_times (const char *, const struct stat *); + +-extern int smart_rename (const char *, const char *, int, struct stat *, int); ++extern int smart_rename (const char *, const char *, int, ++ struct stat *, bfd_boolean); + + + /* In libiberty. */ +diff -rup binutils.orig/binutils/objcopy.c binutils-2.35.1/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2021-03-11 12:38:18.181422787 +0000 ++++ binutils-2.35.1/binutils/objcopy.c 2021-03-11 12:51:09.486344417 +0000 +@@ -4802,12 +4802,7 @@ strip_main (int argc, char *argv[]) + else + tmpname = output_file; + +- if (tmpname == NULL +-#if !defined (_WIN32) || defined (__CYGWIN32__) +- /* Retain a copy of TMPFD since we will need it for SMART_RENAME. */ +- || (tmpfd >= 0 && (copyfd = dup (tmpfd)) == -1) +-#endif +- ) ++ if (tmpname == NULL) + { + bfd_nonfatal_message (argv[i], NULL, NULL, + _("could not create temporary file to hold stripped copy")); +@@ -4820,21 +4815,17 @@ strip_main (int argc, char *argv[]) + output_target, NULL); + if (status == 0) + { +- if (preserve_dates) +- set_times (tmpname, &statbuf); + if (output_file != tmpname) +- status = (smart_rename (tmpname, +- output_file ? output_file : argv[i], +- copyfd, &statbuf, preserve_dates) != 0); ++ status = smart_rename (tmpname, ++ output_file ? output_file : argv[i], ++ copyfd, &statbuf, preserve_dates) != 0; + if (status == 0) + status = hold_status; + } + else + { +-#if !defined (_WIN32) || defined (__CYGWIN32__) + if (copyfd >= 0) + close (copyfd); +-#endif + unlink_if_ordinary (tmpname); + } + if (output_file != tmpname) +@@ -5043,8 +5034,9 @@ copy_main (int argc, char *argv[]) + bfd_boolean show_version = FALSE; + bfd_boolean change_warn = TRUE; + bfd_boolean formats_info = FALSE; +- int c, tmpfd = -1; +- int copyfd = -1; ++ int c; ++ int tmpfd = -1; ++ int copyfd; + struct stat statbuf; + const bfd_arch_info_type *input_arch = NULL; + +@@ -5882,19 +5874,19 @@ copy_main (int argc, char *argv[]) + } + + /* If there is no destination file, or the source and destination files +- are the same, then create a temp and rename the result into the input. */ ++ are the same, then create a temp and copy the result into the input. */ ++ copyfd = -1; + if (output_filename == NULL + || filename_cmp (input_filename, output_filename) == 0) +- tmpname = make_tempname (input_filename, &tmpfd); ++ { ++ tmpname = make_tempname (input_filename, &tmpfd); ++ if (tmpfd >= 0) ++ copyfd = dup (tmpfd); ++ } + else + tmpname = output_filename; + +- if (tmpname == NULL +-#if !defined (_WIN32) || defined (__CYGWIN32__) +- /* Retain a copy of TMPFD since we will need it for SMART_RENAME. */ +- || (tmpfd >= 0 && (copyfd = dup (tmpfd)) == -1) +-#endif +- ) ++ if (tmpname == NULL) + { + fatal (_("warning: could not create temporary file whilst copying '%s', (error: %s)"), + input_filename, strerror (errno)); +@@ -5904,18 +5896,14 @@ copy_main (int argc, char *argv[]) + output_target, input_arch); + if (status == 0) + { +- if (preserve_dates) +- set_times (tmpname, &statbuf); + if (tmpname != output_filename) +- status = (smart_rename (tmpname, input_filename, copyfd, &statbuf, +- preserve_dates) != 0); ++ status = smart_rename (tmpname, input_filename, copyfd, ++ &statbuf, preserve_dates) != 0; + } + else + { +-#if !defined (_WIN32) || defined (__CYGWIN32__) + if (copyfd >= 0) + close (copyfd); +-#endif + unlink_if_ordinary (tmpname); + } + +diff -rup binutils.orig/binutils/rename.c binutils-2.35.1/binutils/rename.c +--- binutils.orig/binutils/rename.c 2021-03-11 12:38:18.183422774 +0000 ++++ binutils-2.35.1/binutils/rename.c 2021-03-11 12:41:41.824081969 +0000 +@@ -30,30 +30,25 @@ + #endif /* HAVE_UTIMES */ + #endif /* ! HAVE_GOOD_UTIME_H */ + +-#if ! defined (_WIN32) || defined (__CYGWIN32__) +-static int simple_copy (const char *, const char *); +- + /* The number of bytes to copy at once. */ + #define COPY_BUF 8192 + +-/* Copy file FROM to file TO, performing no translations. ++/* Copy file FROMFD to file TO, performing no translations. + Return 0 if ok, -1 if error. */ + + static int +-simple_copy (const char *from, const char *to) ++simple_copy (int fromfd, const char *to, ++ struct stat *target_stat ATTRIBUTE_UNUSED) + { +- int fromfd, tofd, nread; ++ int tofd, nread; + int saved; + char buf[COPY_BUF]; + +- fromfd = open (from, O_RDONLY | O_BINARY); +- if (fromfd < 0) ++ if (fromfd < 0 ++ || lseek (fromfd, 0, SEEK_SET) != 0) + return -1; +-#ifdef O_CREAT +- tofd = open (to, O_CREAT | O_WRONLY | O_TRUNC | O_BINARY, 0777); +-#else +- tofd = creat (to, 0777); +-#endif ++ ++ tofd = open (to, O_WRONLY | O_TRUNC | O_BINARY); + if (tofd < 0) + { + saved = errno; +@@ -61,6 +56,7 @@ simple_copy (const char *from, const cha + errno = saved; + return -1; + } ++ + while ((nread = read (fromfd, buf, sizeof buf)) > 0) + { + if (write (tofd, buf, nread) != nread) +@@ -72,7 +68,16 @@ simple_copy (const char *from, const cha + return -1; + } + } ++ + saved = errno; ++ ++#if !defined (_WIN32) || defined (__CYGWIN32__) ++ /* Writing to a setuid/setgid file may clear S_ISUID and S_ISGID. ++ Try to restore them, ignoring failure. */ ++ if (target_stat != NULL) ++ fchmod (tofd, target_stat->st_mode); ++#endif ++ + close (fromfd); + close (tofd); + if (nread < 0) +@@ -82,7 +87,6 @@ simple_copy (const char *from, const cha + } + return 0; + } +-#endif /* __CYGWIN32__ or not _WIN32 */ + + /* Set the times of the file DESTINATION to be the same as those in + STATBUF. */ +@@ -91,164 +95,52 @@ void + set_times (const char *destination, const struct stat *statbuf) + { + int result; +- +- { + #ifdef HAVE_GOOD_UTIME_H +- struct utimbuf tb; ++ struct utimbuf tb; + +- tb.actime = statbuf->st_atime; +- tb.modtime = statbuf->st_mtime; +- result = utime (destination, &tb); +-#else /* ! HAVE_GOOD_UTIME_H */ +-#ifndef HAVE_UTIMES +- long tb[2]; +- +- tb[0] = statbuf->st_atime; +- tb[1] = statbuf->st_mtime; +- result = utime (destination, tb); +-#else /* HAVE_UTIMES */ +- struct timeval tv[2]; +- +- tv[0].tv_sec = statbuf->st_atime; +- tv[0].tv_usec = 0; +- tv[1].tv_sec = statbuf->st_mtime; +- tv[1].tv_usec = 0; +- result = utimes (destination, tv); +-#endif /* HAVE_UTIMES */ +-#endif /* ! HAVE_GOOD_UTIME_H */ +- } +- +- if (result != 0) +- non_fatal (_("%s: cannot set time: %s"), destination, strerror (errno)); +-} +- +-#ifndef S_ISLNK +-#ifdef S_IFLNK +-#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) ++ tb.actime = statbuf->st_atime; ++ tb.modtime = statbuf->st_mtime; ++ result = utime (destination, &tb); ++#elif defined HAVE_UTIMES ++ struct timeval tv[2]; ++ ++ tv[0].tv_sec = statbuf->st_atime; ++ tv[0].tv_usec = 0; ++ tv[1].tv_sec = statbuf->st_mtime; ++ tv[1].tv_usec = 0; ++ result = utimes (destination, tv); + #else +-#define S_ISLNK(m) 0 +-#define lstat stat +-#endif +-#endif +- +-#if !defined (_WIN32) || defined (__CYGWIN32__) +-/* Try to preserve the permission bits and ownership of an existing file when +- rename overwrites it. FD is the file being renamed and TARGET_STAT has the +- status of the file that was overwritten. */ +-static void +-try_preserve_permissions (int fd, struct stat *target_stat) +-{ +- struct stat from_stat; +- int ret = 0; +- +- if (fstat (fd, &from_stat) != 0) +- return; ++ long tb[2]; + +- int from_mode = from_stat.st_mode & 0777; +- int to_mode = target_stat->st_mode & 0777; ++ tb[0] = statbuf->st_atime; ++ tb[1] = statbuf->st_mtime; ++ result = utime (destination, tb); ++#endif + +- /* Fix up permissions before we potentially lose ownership with fchown. +- Clear the setxid bits because in case the fchown below fails then we don't +- want to end up with a sxid file owned by the invoking user. If the user +- hasn't changed or if fchown succeeded, we add back the sxid bits at the +- end. */ +- if (from_mode != to_mode) +- fchmod (fd, to_mode); +- +- /* Fix up ownership, this will clear the setxid bits. */ +- if (from_stat.st_uid != target_stat->st_uid +- || from_stat.st_gid != target_stat->st_gid) +- ret = fchown (fd, target_stat->st_uid, target_stat->st_gid); +- +- /* Fix up the sxid bits if either the fchown wasn't needed or it +- succeeded. */ +- if (ret == 0) +- fchmod (fd, target_stat->st_mode & 07777); ++ if (result != 0) ++ non_fatal (_("%s: cannot set time: %s"), destination, strerror (errno)); + } +-#endif + +-/* Rename FROM to TO, copying if TO is either a link or is not a regular file. +- FD is an open file descriptor pointing to FROM that we can use to safely fix +- up permissions of the file after renaming. TARGET_STAT has the file status +- that is used to fix up permissions and timestamps after rename. Return 0 if +- ok, -1 if error and FD is closed before returning. */ ++/* Copy FROM to TO. TARGET_STAT has the file status that, if non-NULL, ++ is used to fix up timestamps. Return 0 if ok, -1 if error. ++ At one time this function renamed files, but file permissions are ++ tricky to update given the number of different schemes used by ++ various systems. So now we just copy. */ + + int +-smart_rename (const char *from, const char *to, int fd ATTRIBUTE_UNUSED, +- struct stat *target_stat ATTRIBUTE_UNUSED, +- int preserve_dates ATTRIBUTE_UNUSED) ++smart_rename (const char *from, const char *to, int fromfd, ++ struct stat *target_stat, bfd_boolean preserve_dates) + { +- int ret = 0; +- struct stat to_stat; +- bfd_boolean exists; +- +- exists = lstat (to, &to_stat) == 0; +- +-#if defined (_WIN32) && !defined (__CYGWIN32__) +- /* Win32, unlike unix, will not erase `to' in `rename(from, to)' but +- fail instead. Also, chown is not present. */ ++ int ret; + +- if (exists) +- remove (to); +- +- ret = rename (from, to); ++ ret = simple_copy (fromfd, to, target_stat); + if (ret != 0) +- { +- /* We have to clean up here. */ +- non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno)); +- unlink (from); +- } +-#else +- /* Avoid a full copy and use rename if we can fix up permissions of the +- file after renaming, i.e.: ++ non_fatal (_("unable to copy file '%s'; reason: %s"), ++ to, strerror (errno)); + +- - TO is not a symbolic link +- - TO is a regular file with only one hard link +- - We have permission to write to TO +- - FD is available to safely fix up permissions to be the same as the file +- we overwrote with the rename. +- +- Note though that the actual file on disk that TARGET_STAT describes may +- have changed and we're only trying to preserve the status we know about. +- At no point do we try to interact with the new file changes, so there can +- only be two outcomes, i.e. either the external file change survives +- without knowledge of our change (if it happens after the rename syscall) +- or our rename and permissions fixup survive without any knowledge of the +- external change. */ +- if (! exists +- || (fd >= 0 +- && !S_ISLNK (to_stat.st_mode) +- && S_ISREG (to_stat.st_mode) +- && (to_stat.st_mode & S_IWUSR) +- && to_stat.st_nlink == 1) +- ) +- { +- ret = rename (from, to); +- if (ret == 0) +- { +- if (exists && target_stat != NULL) +- try_preserve_permissions (fd, target_stat); +- } +- else +- { +- /* We have to clean up here. */ +- non_fatal (_("unable to rename '%s'; reason: %s"), to, strerror (errno)); +- unlink (from); +- } +- } +- else +- { +- ret = simple_copy (from, to); +- if (ret != 0) +- non_fatal (_("unable to copy file '%s'; reason: %s"), to, strerror (errno)); +- +- if (preserve_dates && target_stat != NULL) +- set_times (to, target_stat); +- unlink (from); +- } +- if (fd >= 0) +- close (fd); +-#endif /* _WIN32 && !__CYGWIN32__ */ ++ if (preserve_dates) ++ set_times (to, target_stat); ++ unlink (from); + + return ret; + } +diff -rup binutils.orig/binutils/objcopy.c binutils-2.35.1/binutils/objcopy.c +--- binutils.orig/binutils/objcopy.c 2021-03-11 13:21:44.780223078 +0000 ++++ binutils-2.35.1/binutils/objcopy.c 2021-03-11 13:23:01.041718818 +0000 +@@ -4798,7 +4798,11 @@ strip_main (int argc, char *argv[]) + + if (output_file == NULL + || filename_cmp (argv[i], output_file) == 0) +- tmpname = make_tempname (argv[i], &tmpfd); ++ { ++ tmpname = make_tempname (argv[i], &tmpfd); ++ if (tmpfd >= 0) ++ copyfd = dup (tmpfd); ++ } + else + tmpname = output_file; + diff --git a/SOURCES/binutils-PT_GNU_PROPERTY-segment.patch b/SOURCES/binutils-PT_GNU_PROPERTY-segment.patch new file mode 100644 index 0000000..ce82848 --- /dev/null +++ b/SOURCES/binutils-PT_GNU_PROPERTY-segment.patch @@ -0,0 +1,3810 @@ +diff -rup binutils.orig/bfd/elf-bfd.h binutils-2.30/bfd/elf-bfd.h +--- binutils.orig/bfd/elf-bfd.h 2020-04-07 11:32:17.269776457 +0100 ++++ binutils-2.30/bfd/elf-bfd.h 2020-04-07 13:34:03.897784103 +0100 +@@ -1467,12 +1467,16 @@ struct elf_backend_data + unsigned int); + + /* Merge GNU properties. Return TRUE if property is updated. */ +- bfd_boolean (*merge_gnu_properties) (struct bfd_link_info *, bfd *, ++ bfd_boolean (*merge_gnu_properties) (struct bfd_link_info *, bfd *, bfd *, + elf_property *, elf_property *); + + /* Set up GNU properties. */ + bfd *(*setup_gnu_properties) (struct bfd_link_info *); + ++ /* Fix up GNU properties. */ ++ void (*fixup_gnu_properties) (struct bfd_link_info *, ++ elf_property_list **); ++ + /* Encoding used for compact EH tables. */ + int (*compact_eh_encoding) (struct bfd_link_info *); + +@@ -2673,6 +2677,10 @@ extern elf_property * _bfd_elf_get_prope + (bfd *, unsigned int, unsigned int); + extern bfd *_bfd_elf_link_setup_gnu_properties + (struct bfd_link_info *); ++extern bfd_size_type _bfd_elf_convert_gnu_property_size ++ (bfd *, bfd *); ++extern bfd_boolean _bfd_elf_convert_gnu_properties ++ (bfd *, asection *, bfd *, bfd_byte **, bfd_size_type *); + + /* The linker may need to keep track of the number of relocs that it + decides to copy as dynamic relocs in check_relocs for each symbol. +diff -rup binutils.orig/bfd/elf-properties.c binutils-2.30/bfd/elf-properties.c +--- binutils.orig/bfd/elf-properties.c 2020-04-07 11:32:17.280776377 +0100 ++++ binutils-2.30/bfd/elf-properties.c 2020-04-07 13:34:03.899784089 +0100 +@@ -198,7 +198,7 @@ next: + with ABFD. */ + + static bfd_boolean +-elf_merge_gnu_properties (struct bfd_link_info *info, bfd *abfd, ++elf_merge_gnu_properties (struct bfd_link_info *info, bfd *abfd, bfd *bbfd, + elf_property *aprop, elf_property *bprop) + { + const struct elf_backend_data *bed = get_elf_backend_data (abfd); +@@ -207,7 +207,7 @@ elf_merge_gnu_properties (struct bfd_lin + if (bed->merge_gnu_properties != NULL + && pr_type >= GNU_PROPERTY_LOPROC + && pr_type < GNU_PROPERTY_LOUSER) +- return bed->merge_gnu_properties (info, abfd, aprop, bprop); ++ return bed->merge_gnu_properties (info, abfd, bbfd, aprop, bprop); + + switch (pr_type) + { +@@ -241,7 +241,7 @@ elf_merge_gnu_properties (struct bfd_lin + + static elf_property * + elf_find_and_remove_property (elf_property_list **listp, +- unsigned int type) ++ unsigned int type, bfd_boolean remove) + { + elf_property_list *list; + +@@ -250,7 +250,8 @@ elf_find_and_remove_property (elf_proper + if (type == list->property.pr_type) + { + /* Remove this property. */ +- *listp = list->next; ++ if (remove) ++ *listp = list->next; + return &list->property; + } + else if (type < list->property.pr_type) +@@ -261,47 +262,241 @@ elf_find_and_remove_property (elf_proper + return NULL; + } + +-/* Merge GNU property list *LISTP with ABFD. */ ++/* Merge GNU property list *LISTP in ABFD with FIRST_PBFD. */ + + static void +-elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *abfd, +- elf_property_list **listp) ++elf_merge_gnu_property_list (struct bfd_link_info *info, bfd *first_pbfd, ++ bfd *abfd, elf_property_list **listp) + { + elf_property_list *p, **lastp; + elf_property *pr; ++ bfd_boolean number_p; ++ bfd_vma number = 0; + +- /* Merge each GNU property in ABFD with the one on *LISTP. */ +- lastp = &elf_properties (abfd); ++ /* Merge each GNU property in FIRST_PBFD with the one on *LISTP. */ ++ lastp = &elf_properties (first_pbfd); + for (p = *lastp; p; p = p->next) ++ if (p->property.pr_kind != property_remove) ++ { ++ if (p->property.pr_kind == property_number) ++ { ++ number_p = TRUE; ++ number = p->property.u.number; ++ } ++ else ++ number_p = FALSE; ++ pr = elf_find_and_remove_property (listp, p->property.pr_type, ++ TRUE); ++ /* Pass NULL to elf_merge_gnu_properties for the property which ++ isn't on *LISTP. */ ++ elf_merge_gnu_properties (info, first_pbfd, abfd, &p->property, pr); ++ if (p->property.pr_kind == property_remove) ++ { ++ if (number_p) ++ { ++ if (pr != NULL) ++ info->callbacks->minfo ++ (_("Removed property %W to merge %pB (0x%v) " ++ "and %pB (0x%v)\n"), ++ (bfd_vma) p->property.pr_type, first_pbfd, ++ number, abfd, pr->u.number); ++ else ++ info->callbacks->minfo ++ (_("Removed property %W to merge %pB (0x%v) " ++ "and %pB (not found)\n"), ++ (bfd_vma) p->property.pr_type, first_pbfd, ++ number, abfd); ++ } ++ else ++ { ++ if (pr != NULL) ++ info->callbacks->minfo ++ (_("Removed property %W to merge %pB and %pB\n"), ++ (bfd_vma) p->property.pr_type, first_pbfd, abfd); ++ else ++ info->callbacks->minfo ++ (_("Removed property %W to merge %pB and %pB " ++ "(not found)\n"), ++ (bfd_vma) p->property.pr_type, first_pbfd, abfd); ++ } ++ ++ /* Remove this property. */ ++ *lastp = p->next; ++ continue; ++ } ++ else if (number_p) ++ { ++ if (pr != NULL) ++ { ++ if (p->property.u.number != number ++ || p->property.u.number != pr->u.number) ++ info->callbacks->minfo ++ (_("Updated property %W (0x%v) to merge %pB (0x%v) " ++ "and %pB (0x%v)\n"), ++ (bfd_vma) p->property.pr_type, p->property.u.number, ++ first_pbfd, number, abfd, pr->u.number); ++ } ++ else ++ { ++ if (p->property.u.number != number) ++ info->callbacks->minfo ++ (_("Updated property %W (%v) to merge %pB (0x%v) " ++ "and %pB (not found)\n"), ++ (bfd_vma) p->property.pr_type, p->property.u.number, ++ first_pbfd, number, abfd); ++ } ++ } ++ lastp = &p->next; ++ } ++ ++ /* Merge the remaining properties on *LISTP with FIRST_PBFD. */ ++ for (p = *listp; p != NULL; p = p->next) + { +- pr = elf_find_and_remove_property (listp, p->property.pr_type); +- /* Pass NULL to elf_merge_gnu_properties for the property which +- isn't on *LISTP. */ +- elf_merge_gnu_properties (info, abfd, &p->property, pr); +- if (p->property.pr_kind == property_remove) ++ if (p->property.pr_kind == property_number) + { +- /* Remove this property. */ +- *lastp = p->next; +- continue; ++ number_p = TRUE; ++ number = p->property.u.number; ++ } ++ else ++ number_p = FALSE; ++ ++ if (elf_merge_gnu_properties (info, first_pbfd, abfd, NULL, &p->property)) ++ { ++ if (p->property.pr_type == GNU_PROPERTY_NO_COPY_ON_PROTECTED) ++ elf_has_no_copy_on_protected (first_pbfd) = TRUE; ++ ++ pr = _bfd_elf_get_property (first_pbfd, p->property.pr_type, ++ p->property.pr_datasz); ++ /* It must be a new property. */ ++ if (pr->pr_kind != property_unknown) ++ abort (); ++ /* Add a new property. */ ++ *pr = p->property; ++ } ++ else ++ { ++ pr = elf_find_and_remove_property (&elf_properties (first_pbfd), ++ p->property.pr_type, ++ FALSE); ++ if (pr == NULL) ++ { ++ if (number_p) ++ info->callbacks->minfo ++ (_("Removed property %W to merge %pB (not found) and " ++ "%pB (0x%v)\n"), ++ (bfd_vma) p->property.pr_type, first_pbfd, abfd, ++ number); ++ else ++ info->callbacks->minfo ++ (_("Removed property %W to merge %pB and %pB\n"), ++ (bfd_vma) p->property.pr_type, first_pbfd, abfd); ++ } ++ else if (pr->pr_kind != property_remove) ++ abort (); + } +- lastp = &p->next; + } ++} + +- /* Merge the remaining properties on *LISTP with ABFD. */ +- for (p = *listp; p != NULL; p = p->next) +- if (elf_merge_gnu_properties (info, abfd, NULL, &p->property)) +- { +- if (p->property.pr_type == GNU_PROPERTY_NO_COPY_ON_PROTECTED) +- elf_has_no_copy_on_protected (abfd) = TRUE; ++/* Get GNU property section size. */ ++ ++static bfd_size_type ++elf_get_gnu_property_section_size (elf_property_list *list, ++ unsigned int align_size) ++{ ++ bfd_size_type size; ++ unsigned int descsz; ++ ++ /* Compute the output section size. */ ++ descsz = offsetof (Elf_External_Note, name[sizeof "GNU"]); ++ descsz = (descsz + 3) & -(unsigned int) 4; ++ size = descsz; ++ for (; list != NULL; list = list->next) ++ { ++ unsigned int datasz; ++ /* Check if this property should be skipped. */ ++ if (list->property.pr_kind == property_remove) ++ continue; ++ /* There are 4 byte type + 4 byte datasz for each property. */ ++ if (list->property.pr_type == GNU_PROPERTY_STACK_SIZE) ++ datasz = align_size; ++ else ++ datasz = list->property.pr_datasz; ++ size += 4 + 4 + datasz; ++ /* Align each property. */ ++ size = (size + (align_size - 1)) & ~(align_size - 1); ++ } ++ ++ return size; ++} ++ ++/* Write GNU properties. */ ++ ++static void ++elf_write_gnu_properties (bfd *abfd, bfd_byte *contents, ++ elf_property_list *list, unsigned int size, ++ unsigned int align_size) ++{ ++ unsigned int descsz; ++ unsigned int datasz; ++ Elf_External_Note *e_note; ++ ++ e_note = (Elf_External_Note *) contents; ++ descsz = offsetof (Elf_External_Note, name[sizeof "GNU"]); ++ descsz = (descsz + 3) & -(unsigned int) 4; ++ bfd_h_put_32 (abfd, sizeof "GNU", &e_note->namesz); ++ bfd_h_put_32 (abfd, size - descsz, &e_note->descsz); ++ bfd_h_put_32 (abfd, NT_GNU_PROPERTY_TYPE_0, &e_note->type); ++ memcpy (e_note->name, "GNU", sizeof "GNU"); ++ ++ size = descsz; ++ for (; list != NULL; list = list->next) ++ { ++ /* Check if this property should be skipped. */ ++ if (list->property.pr_kind == property_remove) ++ continue; ++ /* There are 4 byte type + 4 byte datasz for each property. */ ++ if (list->property.pr_type == GNU_PROPERTY_STACK_SIZE) ++ datasz = align_size; ++ else ++ datasz = list->property.pr_datasz; ++ bfd_h_put_32 (abfd, list->property.pr_type, contents + size); ++ bfd_h_put_32 (abfd, datasz, contents + size + 4); ++ size += 4 + 4; ++ ++ /* Write out property value. */ ++ switch (list->property.pr_kind) ++ { ++ case property_number: ++ switch (datasz) ++ { ++ default: ++ /* Never should happen. */ ++ abort (); ++ ++ case 0: ++ break; ++ ++ case 4: ++ bfd_h_put_32 (abfd, list->property.u.number, ++ contents + size); ++ break; + +- pr = _bfd_elf_get_property (abfd, p->property.pr_type, +- p->property.pr_datasz); +- /* It must be a new property. */ +- if (pr->pr_kind != property_unknown) ++ case 8: ++ bfd_h_put_64 (abfd, list->property.u.number, ++ contents + size); ++ break; ++ } ++ break; ++ ++ default: ++ /* Never should happen. */ + abort (); +- /* Add a new property. */ +- *pr = p->property; +- } ++ } ++ size += datasz; ++ ++ /* Align each property. */ ++ size = (size + (align_size - 1)) & ~ (align_size - 1); ++ } + } + + /* Set up GNU properties. Return the first relocatable ELF input with +@@ -349,8 +544,13 @@ _bfd_elf_link_setup_gnu_properties (stru + return NULL; + + /* Merge .note.gnu.property sections. */ ++ info->callbacks->minfo (_("\n")); ++ info->callbacks->minfo (_("Merging program properties\n")); ++ info->callbacks->minfo (_("\n")); ++ + for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) +- if (abfd != first_pbfd && (abfd->flags & DYNAMIC) == 0) ++ if (abfd != first_pbfd ++ && (abfd->flags & (DYNAMIC | BFD_PLUGIN | BFD_LINKER_CREATED)) == 0) + { + elf_property_list *null_ptr = NULL; + elf_property_list **listp = &null_ptr; +@@ -374,7 +574,7 @@ _bfd_elf_link_setup_gnu_properties (stru + when all properties are from ELF objects with different + machine code or class. */ + if (first_pbfd != NULL) +- elf_merge_gnu_property_list (info, first_pbfd, listp); ++ elf_merge_gnu_property_list (info, first_pbfd, abfd, listp); + + if (list != NULL) + { +@@ -390,11 +590,9 @@ _bfd_elf_link_setup_gnu_properties (stru + always sorted by type even if input GNU properties aren't sorted. */ + if (first_pbfd != NULL) + { +- unsigned int size; +- unsigned int descsz; ++ bfd_size_type size; + bfd_byte *contents; +- Elf_External_Note *e_note; +- unsigned int align_size = bed->s->elfclass == ELFCLASS64 ? 8 : 4; ++ unsigned int align_size = elfclass == ELFCLASS64 ? 8 : 4; + + sec = bfd_get_section_by_name (first_pbfd, + NOTE_GNU_PROPERTY_SECTION_NAME); +@@ -426,76 +624,28 @@ _bfd_elf_link_setup_gnu_properties (stru + return NULL; + } + +- /* Compute the section size. */ +- descsz = offsetof (Elf_External_Note, name[sizeof "GNU"]); +- descsz = (descsz + 3) & -(unsigned int) 4; +- size = descsz; +- for (list = elf_properties (first_pbfd); +- list != NULL; +- list = list->next) ++ /* Fix up GNU properties. */ ++ if (bed->fixup_gnu_properties) ++ bed->fixup_gnu_properties (info, &elf_properties (first_pbfd)); ++ ++ if (elf_properties (first_pbfd) == NULL) + { +- /* There are 4 byte type + 4 byte datasz for each property. */ +- size += 4 + 4 + list->property.pr_datasz; +- /* Align each property. */ +- size = (size + (align_size - 1)) & ~(align_size - 1); ++ /* Discard .note.gnu.property section if all properties have ++ been removed. */ ++ sec->output_section = bfd_abs_section_ptr; ++ return NULL; + } + ++ /* Compute the section size. */ ++ list = elf_properties (first_pbfd); ++ size = elf_get_gnu_property_section_size (list, align_size); ++ + /* Update .note.gnu.property section now. */ + sec->size = size; + contents = (bfd_byte *) bfd_zalloc (first_pbfd, size); + +- e_note = (Elf_External_Note *) contents; +- bfd_h_put_32 (first_pbfd, sizeof "GNU", &e_note->namesz); +- bfd_h_put_32 (first_pbfd, size - descsz, &e_note->descsz); +- bfd_h_put_32 (first_pbfd, NT_GNU_PROPERTY_TYPE_0, &e_note->type); +- memcpy (e_note->name, "GNU", sizeof "GNU"); +- +- size = descsz; +- for (list = elf_properties (first_pbfd); +- list != NULL; +- list = list->next) +- { +- /* There are 4 byte type + 4 byte datasz for each property. */ +- bfd_h_put_32 (first_pbfd, list->property.pr_type, +- contents + size); +- bfd_h_put_32 (first_pbfd, list->property.pr_datasz, +- contents + size + 4); +- size += 4 + 4; +- +- /* Write out property value. */ +- switch (list->property.pr_kind) +- { +- case property_number: +- switch (list->property.pr_datasz) +- { +- default: +- /* Never should happen. */ +- abort (); +- +- case 0: +- break; +- +- case 4: +- bfd_h_put_32 (first_pbfd, list->property.u.number, +- contents + size); +- break; +- +- case 8: +- bfd_h_put_64 (first_pbfd, list->property.u.number, +- contents + size); +- break; +- } +- break; +- +- default: +- /* Never should happen. */ +- abort (); +- } +- size += list->property.pr_datasz; +- +- /* Align each property. */ +- size = (size + (align_size - 1)) & ~ (align_size - 1); +- } ++ elf_write_gnu_properties (first_pbfd, contents, list, size, ++ align_size); + + /* Cache the section contents for elf_link_input_bfd. */ + elf_section_data (sec)->this_hdr.contents = contents; +@@ -508,3 +658,58 @@ _bfd_elf_link_setup_gnu_properties (stru + + return first_pbfd; + } ++ ++/* Convert GNU property size. */ ++ ++bfd_size_type ++_bfd_elf_convert_gnu_property_size (bfd *ibfd, bfd *obfd) ++{ ++ unsigned int align_size; ++ const struct elf_backend_data *bed; ++ elf_property_list *list = elf_properties (ibfd); ++ ++ bed = get_elf_backend_data (obfd); ++ align_size = bed->s->elfclass == ELFCLASS64 ? 8 : 4; ++ ++ /* Get the output .note.gnu.property section size. */ ++ return elf_get_gnu_property_section_size (list, align_size); ++} ++ ++/* Convert GNU properties. */ ++ ++bfd_boolean ++_bfd_elf_convert_gnu_properties (bfd *ibfd, asection *isec, ++ bfd *obfd, bfd_byte **ptr, ++ bfd_size_type *ptr_size) ++{ ++ unsigned int size; ++ bfd_byte *contents; ++ unsigned int align_shift; ++ const struct elf_backend_data *bed; ++ elf_property_list *list = elf_properties (ibfd); ++ ++ bed = get_elf_backend_data (obfd); ++ align_shift = bed->s->elfclass == ELFCLASS64 ? 3 : 2; ++ ++ /* Get the output .note.gnu.property section size. */ ++ size = bfd_get_section_size (isec->output_section); ++ ++ /* Update the output .note.gnu.property section alignment. */ ++ bfd_set_section_alignment (obfd, isec->output_section, align_shift); ++ ++ if (size > bfd_get_section_size (isec)) ++ { ++ contents = (bfd_byte *) bfd_malloc (size); ++ free (*ptr); ++ *ptr = contents; ++ } ++ else ++ contents = *ptr; ++ ++ *ptr_size = size; ++ ++ /* Generate the output .note.gnu.property section. */ ++ elf_write_gnu_properties (ibfd, contents, list, size, 1 << align_shift); ++ ++ return TRUE; ++} +diff -rup binutils.orig/bfd/elf.c binutils-2.30/bfd/elf.c +--- binutils.orig/bfd/elf.c 2020-04-07 11:32:17.260776522 +0100 ++++ binutils-2.30/bfd/elf.c 2020-04-07 13:34:03.898784096 +0100 +@@ -4376,6 +4376,14 @@ get_program_header_size (bfd *abfd, stru + ++segs; + } + ++ s = bfd_get_section_by_name (abfd, ++ NOTE_GNU_PROPERTY_SECTION_NAME); ++ if (s != NULL && s->size != 0) ++ { ++ /* We need a PT_GNU_PROPERTY segment. */ ++ ++segs; ++ } ++ + for (s = abfd->sections; s != NULL; s = s->next) + { + if ((s->flags & SEC_LOAD) != 0 +@@ -5028,6 +5036,24 @@ _bfd_elf_map_sections_to_segments (bfd * + pm = &m->next; + } + ++ s = bfd_get_section_by_name (abfd, ++ NOTE_GNU_PROPERTY_SECTION_NAME); ++ if (s != NULL && s->size != 0) ++ { ++ amt = sizeof (struct elf_segment_map) + sizeof (asection *); ++ m = bfd_zalloc (abfd, amt); ++ if (m == NULL) ++ goto error_return; ++ m->next = NULL; ++ m->p_type = PT_GNU_PROPERTY; ++ m->count = 1; ++ m->p_flags_valid = 1; ++ m->sections[0] = s; ++ m->p_flags = PF_R; ++ *pm = m; ++ pm = &m->next; ++ } ++ + /* If there is a .eh_frame_hdr section, throw in a PT_GNU_EH_FRAME + segment. */ + eh_frame_hdr = elf_eh_frame_hdr (abfd); +diff -rup binutils.orig/bfd/elfxx-target.h binutils-2.30/bfd/elfxx-target.h +--- binutils.orig/bfd/elfxx-target.h 2020-04-07 11:32:17.267776472 +0100 ++++ binutils-2.30/bfd/elfxx-target.h 2020-04-07 13:34:03.899784089 +0100 +@@ -543,6 +543,9 @@ + #ifndef elf_backend_setup_gnu_properties + #define elf_backend_setup_gnu_properties _bfd_elf_link_setup_gnu_properties + #endif ++#ifndef elf_backend_fixup_gnu_properties ++#define elf_backend_fixup_gnu_properties NULL ++#endif + #ifndef elf_backend_static_tls_alignment + #define elf_backend_static_tls_alignment 1 + #endif +@@ -884,6 +887,7 @@ static struct elf_backend_data elfNN_bed + elf_backend_parse_gnu_properties, + elf_backend_merge_gnu_properties, + elf_backend_setup_gnu_properties, ++ elf_backend_fixup_gnu_properties, + elf_backend_compact_eh_encoding, + elf_backend_cant_unwind_opcode, + elf_backend_init_secondary_reloc_section, +diff -rup binutils.orig/bfd/elfxx-x86.c binutils-2.30/bfd/elfxx-x86.c +--- binutils.orig/bfd/elfxx-x86.c 2020-04-07 11:32:17.271776442 +0100 ++++ binutils-2.30/bfd/elfxx-x86.c 2020-04-07 13:34:03.899784089 +0100 +@@ -2271,33 +2271,29 @@ _bfd_x86_elf_parse_gnu_properties (bfd * + { + elf_property *prop; + +- switch (type) ++ if (type == GNU_PROPERTY_X86_COMPAT_ISA_1_USED ++ || type == GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED ++ || (type >= GNU_PROPERTY_X86_UINT32_AND_LO ++ && type <= GNU_PROPERTY_X86_UINT32_AND_HI) ++ || (type >= GNU_PROPERTY_X86_UINT32_OR_LO ++ && type <= GNU_PROPERTY_X86_UINT32_OR_HI) ++ || (type >= GNU_PROPERTY_X86_UINT32_OR_AND_LO ++ && type <= GNU_PROPERTY_X86_UINT32_OR_AND_HI)) + { +- case GNU_PROPERTY_X86_ISA_1_USED: +- case GNU_PROPERTY_X86_ISA_1_NEEDED: +- case GNU_PROPERTY_X86_FEATURE_1_AND: + if (datasz != 4) + { + _bfd_error_handler +- ((type == GNU_PROPERTY_X86_ISA_1_USED +- ? _("error: %B: ") +- : (type == GNU_PROPERTY_X86_ISA_1_NEEDED +- ? _("error: %B: ") +- : _("error: %B: "))), +- abfd, datasz); ++ (_("error: %pB: "), ++ abfd, type, datasz); + return property_corrupt; + } + prop = _bfd_elf_get_property (abfd, type, datasz); +- /* Combine properties of the same type. */ + prop->u.number |= bfd_h_get_32 (abfd, ptr); + prop->pr_kind = property_number; +- break; +- +- default: +- return property_ignored; ++ return property_number; + } + +- return property_number; ++ return property_ignored; + } + + /* Merge x86 GNU property BPROP with APROP. If APROP isn't NULL, +@@ -2307,6 +2303,7 @@ _bfd_x86_elf_parse_gnu_properties (bfd * + bfd_boolean + _bfd_x86_elf_merge_gnu_properties (struct bfd_link_info *info, + bfd *abfd ATTRIBUTE_UNUSED, ++ bfd *bbfd ATTRIBUTE_UNUSED, + elf_property *aprop, + elf_property *bprop) + { +@@ -2314,15 +2311,38 @@ _bfd_x86_elf_merge_gnu_properties (struc + bfd_boolean updated = FALSE; + unsigned int pr_type = aprop != NULL ? aprop->pr_type : bprop->pr_type; + +- switch (pr_type) ++ if (pr_type == GNU_PROPERTY_X86_COMPAT_ISA_1_USED ++ || (pr_type >= GNU_PROPERTY_X86_UINT32_OR_AND_LO ++ && pr_type <= GNU_PROPERTY_X86_UINT32_OR_AND_HI)) ++ { ++ if (aprop == NULL || bprop == NULL) ++ { ++ /* Only one of APROP and BPROP can be NULL. */ ++ if (aprop != NULL) ++ { ++ /* Remove this property since the other input file doesn't ++ have it. */ ++ aprop->pr_kind = property_remove; ++ updated = TRUE; ++ } ++ } ++ else ++ { ++ number = aprop->u.number; ++ aprop->u.number = number | bprop->u.number; ++ updated = number != (unsigned int) aprop->u.number; ++ } ++ return updated; ++ } ++ else if (pr_type == GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED ++ || (pr_type >= GNU_PROPERTY_X86_UINT32_OR_LO ++ && pr_type <= GNU_PROPERTY_X86_UINT32_OR_HI)) + { +- case GNU_PROPERTY_X86_ISA_1_USED: +- case GNU_PROPERTY_X86_ISA_1_NEEDED: + if (aprop != NULL && bprop != NULL) + { + number = aprop->u.number; + aprop->u.number = number | bprop->u.number; +- /* Remove the property if ISA bits are empty. */ ++ /* Remove the property if all bits are empty. */ + if (aprop->u.number == 0) + { + aprop->pr_kind = property_remove; +@@ -2338,27 +2358,35 @@ _bfd_x86_elf_merge_gnu_properties (struc + { + if (aprop->u.number == 0) + { +- /* Remove APROP if ISA bits are empty. */ ++ /* Remove APROP if all bits are empty. */ + aprop->pr_kind = property_remove; + updated = TRUE; + } + } + else + { +- /* Return TRUE if APROP is NULL and ISA bits of BPROP ++ /* Return TRUE if APROP is NULL and all bits of BPROP + aren't empty to indicate that BPROP should be added + to ABFD. */ + updated = bprop->u.number != 0; + } + } +- break; +- +- case GNU_PROPERTY_X86_FEATURE_1_AND: ++ return updated; ++ } ++ else if (pr_type >= GNU_PROPERTY_X86_UINT32_AND_LO ++ && pr_type <= GNU_PROPERTY_X86_UINT32_AND_HI) ++ { + /* Only one of APROP and BPROP can be NULL: + 1. APROP & BPROP when both APROP and BPROP aren't NULL. + 2. If APROP is NULL, remove x86 feature. + 3. Otherwise, do nothing. + */ ++ const struct elf_backend_data *bed ++ = get_elf_backend_data (info->output_bfd); ++ struct elf_x86_link_hash_table *htab ++ = elf_x86_hash_table (info, bed->target_id); ++ if (!htab) ++ abort (); + if (aprop != NULL && bprop != NULL) + { + features = 0; +@@ -2404,9 +2432,10 @@ _bfd_x86_elf_merge_gnu_properties (struc + updated = TRUE; + } + } +- break; +- +- default: ++ return updated; ++ } ++ else ++ { + /* Never should happen. */ + abort (); + } +@@ -2434,12 +2463,12 @@ _bfd_x86_elf_link_setup_gnu_properties + const struct elf_backend_data *bed; + unsigned int class_align = ABI_64_P (info->output_bfd) ? 3 : 2; + unsigned int got_align; +- +- features = 0; +- if (info->ibt) +- features = GNU_PROPERTY_X86_FEATURE_1_IBT; +- if (info->shstk) +- features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK; ++ enum report ++ { ++ report_none = 0, /* Do nothing. */ ++ report_ibt = 1 << 2, /* Report missing IBT property. */ ++ report_shstk = 1 << 3 /* Report missing SHSTK property. */ ++ } report; + + /* Find a normal input file with GNU property note. */ + for (pbfd = info->input_bfds; +@@ -2454,18 +2483,46 @@ _bfd_x86_elf_link_setup_gnu_properties + break; + } + +- if (ebfd != NULL && features) ++ bed = get_elf_backend_data (info->output_bfd); ++ ++ htab = elf_x86_hash_table (info, bed->target_id); ++ if (htab == NULL) ++ return pbfd; ++ ++ features = 0; ++ report = report_ibt | report_shstk; ++ ++ if (info->ibt) + { +- /* If features is set, add GNU_PROPERTY_X86_FEATURE_1_IBT and +- GNU_PROPERTY_X86_FEATURE_1_SHSTK. */ +- prop = _bfd_elf_get_property (ebfd, +- GNU_PROPERTY_X86_FEATURE_1_AND, +- 4); +- prop->u.number |= features; +- prop->pr_kind = property_number; ++ features = GNU_PROPERTY_X86_FEATURE_1_IBT; ++ report &= ~ report_ibt; ++ } ++ ++ if (info->shstk) ++ { ++ features |= GNU_PROPERTY_X86_FEATURE_1_SHSTK; ++ report &= ~ report_shstk; ++ } ++ ++ if (report == 0) ++ info->cet_report = 0; ++ ++ if (ebfd != NULL) ++ { ++ prop = NULL; ++ if (features) ++ { ++ /* If features is set, add GNU_PROPERTY_X86_FEATURE_1_IBT and ++ GNU_PROPERTY_X86_FEATURE_1_SHSTK. */ ++ prop = _bfd_elf_get_property (ebfd, ++ GNU_PROPERTY_X86_FEATURE_1_AND, ++ 4); ++ prop->u.number |= features; ++ prop->pr_kind = property_number; ++ } + + /* Create the GNU property note section if needed. */ +- if (pbfd == NULL) ++ if (prop != NULL && pbfd == NULL) + { + sec = bfd_make_section_with_flags (ebfd, + NOTE_GNU_PROPERTY_SECTION_NAME, +@@ -2481,7 +2538,7 @@ _bfd_x86_elf_link_setup_gnu_properties + if (!bfd_set_section_alignment (ebfd, sec, class_align)) + { + error_alignment: +- info->callbacks->einfo (_("%F%A: failed to align section\n"), ++ info->callbacks->einfo (_("%F%pA: failed to align section\n"), + sec); + } + +@@ -2489,13 +2546,53 @@ error_alignment: + } + } + +- pbfd = _bfd_elf_link_setup_gnu_properties (info); ++ if (info->cet_report) ++ { ++ /* Report missing IBT and SHSTK properties. */ ++ bfd *abfd; ++ const char *msg; ++ elf_property_list *p; ++ bfd_boolean missing_ibt, missing_shstk; ++ bfd_boolean check_ibt = !!(report & report_ibt); ++ bfd_boolean check_shstk = !!(report & report_shstk); + +- bed = get_elf_backend_data (info->output_bfd); ++ if (info->cet_report == 1) ++ msg = _("%P: %B: warning: missing %s\n"); ++ else ++ msg = _("%X%P: %B: error: missing %s\n"); + +- htab = elf_x86_hash_table (info, bed->target_id); +- if (htab == NULL) +- return pbfd; ++ for (abfd = info->input_bfds; abfd != NULL; abfd = abfd->link.next) ++ if (!(abfd->flags & (DYNAMIC | BFD_PLUGIN | BFD_LINKER_CREATED)) ++ && bfd_get_flavour (abfd) == bfd_target_elf_flavour) ++ { ++ for (p = elf_properties (abfd); p; p = p->next) ++ if (p->property.pr_type == GNU_PROPERTY_X86_FEATURE_1_AND) ++ break; ++ ++ missing_ibt = check_ibt; ++ missing_shstk = check_shstk; ++ if (p) ++ { ++ missing_ibt &= !(p->property.u.number ++ & GNU_PROPERTY_X86_FEATURE_1_IBT); ++ missing_shstk &= !(p->property.u.number ++ & GNU_PROPERTY_X86_FEATURE_1_SHSTK); ++ } ++ if (missing_ibt || missing_shstk) ++ { ++ const char *missing; ++ if (missing_ibt && missing_shstk) ++ missing = _("IBT and SHSTK properties"); ++ else if (missing_ibt) ++ missing = _("IBT property"); ++ else ++ missing = _("SHSTK property"); ++ info->callbacks->einfo (msg, abfd, missing); ++ } ++ } ++ } ++ ++ pbfd = _bfd_elf_link_setup_gnu_properties (info); + + htab->r_info = init_table->r_info; + htab->r_sym = init_table->r_sym; +@@ -2806,3 +2903,47 @@ error_alignment: + + return pbfd; + } ++ ++/* Fix up x86 GNU properties. */ ++ ++void ++_bfd_x86_elf_link_fixup_gnu_properties ++ (struct bfd_link_info *info ATTRIBUTE_UNUSED, ++ elf_property_list **listp) ++{ ++ elf_property_list *p; ++ ++ for (p = *listp; p; p = p->next) ++ { ++ unsigned int type = p->property.pr_type; ++ ++ if (type == GNU_PROPERTY_X86_COMPAT_ISA_1_USED ++ || type == GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED ++ || (type >= GNU_PROPERTY_X86_UINT32_AND_LO ++ && type <= GNU_PROPERTY_X86_UINT32_AND_HI) ++ || (type >= GNU_PROPERTY_X86_UINT32_OR_LO ++ && type <= GNU_PROPERTY_X86_UINT32_OR_HI) ++ || (type >= GNU_PROPERTY_X86_UINT32_OR_AND_LO ++ && type <= GNU_PROPERTY_X86_UINT32_OR_AND_HI)) ++ { ++ if (p->property.u.number == 0 ++ && (type == GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED ++ || (type >= GNU_PROPERTY_X86_UINT32_AND_LO ++ && type <= GNU_PROPERTY_X86_UINT32_AND_HI) ++ || (type >= GNU_PROPERTY_X86_UINT32_OR_LO ++ && type <= GNU_PROPERTY_X86_UINT32_OR_HI))) ++ { ++ /* Remove empty property. */ ++ *listp = p->next; ++ continue; ++ } ++ ++ listp = &p->next; ++ } ++ else if (type > GNU_PROPERTY_HIPROC) ++ { ++ /* The property list is sorted in order of type. */ ++ break; ++ } ++ } ++} +diff -rup binutils.orig/bfd/elfxx-x86.h binutils-2.30/bfd/elfxx-x86.h +--- binutils.orig/bfd/elfxx-x86.h 2020-04-07 11:32:17.280776377 +0100 ++++ binutils-2.30/bfd/elfxx-x86.h 2020-04-07 13:34:03.900784082 +0100 +@@ -653,11 +653,14 @@ extern enum elf_property_kind _bfd_x86_e + (bfd *, unsigned int, bfd_byte *, unsigned int); + + extern bfd_boolean _bfd_x86_elf_merge_gnu_properties +- (struct bfd_link_info *, bfd *, elf_property *, elf_property *); ++ (struct bfd_link_info *, bfd *, bfd *, elf_property *, elf_property *); + + extern bfd * _bfd_x86_elf_link_setup_gnu_properties + (struct bfd_link_info *, struct elf_x86_init_table *); + ++extern void _bfd_x86_elf_link_fixup_gnu_properties ++ (struct bfd_link_info *, elf_property_list **); ++ + #define bfd_elf64_mkobject \ + _bfd_x86_elf_mkobject + #define bfd_elf32_mkobject \ +@@ -693,3 +696,5 @@ extern bfd * _bfd_x86_elf_link_setup_gnu + _bfd_x86_elf_parse_gnu_properties + #define elf_backend_merge_gnu_properties \ + _bfd_x86_elf_merge_gnu_properties ++#define elf_backend_fixup_gnu_properties \ ++ _bfd_x86_elf_link_fixup_gnu_properties +diff -rup binutils.orig/binutils/readelf.c binutils-2.30/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2020-04-07 11:32:17.244776638 +0100 ++++ binutils-2.30/binutils/readelf.c 2020-04-07 13:34:03.901784074 +0100 +@@ -3910,6 +3910,7 @@ get_segment_type (Filedata * filedata, u + case PT_GNU_EH_FRAME: return "GNU_EH_FRAME"; + case PT_GNU_STACK: return "GNU_STACK"; + case PT_GNU_RELRO: return "GNU_RELRO"; ++ case PT_GNU_PROPERTY: return "GNU_PROPERTY"; + + default: + if (p_type >= PT_GNU_MBIND_LO && p_type <= PT_GNU_MBIND_HI) +@@ -16843,8 +16844,87 @@ get_gnu_elf_note_type (unsigned e_type) + } + + static void ++decode_x86_compat_isa (unsigned int bitmask) ++{ ++ while (bitmask) ++ { ++ unsigned int bit = bitmask & (- bitmask); ++ ++ bitmask &= ~ bit; ++ switch (bit) ++ { ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_486: ++ printf ("i486"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_586: ++ printf ("586"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_686: ++ printf ("686"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE: ++ printf ("SSE"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE2: ++ printf ("SSE2"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE3: ++ printf ("SSE3"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_SSSE3: ++ printf ("SSSE3"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE4_1: ++ printf ("SSE4_1"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_SSE4_2: ++ printf ("SSE4_2"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX: ++ printf ("AVX"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX2: ++ printf ("AVX2"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512F: ++ printf ("AVX512F"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512CD: ++ printf ("AVX512CD"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512ER: ++ printf ("AVX512ER"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512PF: ++ printf ("AVX512PF"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512VL: ++ printf ("AVX512VL"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512DQ: ++ printf ("AVX512DQ"); ++ break; ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512BW: ++ printf ("AVX512BW"); ++ break; ++ default: ++ printf (_(""), bit); ++ break; ++ } ++ if (bitmask) ++ printf (", "); ++ } ++} ++ ++static void + decode_x86_isa (unsigned int bitmask) + { ++ if (!bitmask) ++ { ++ printf (_("")); ++ return; ++ } ++ + while (bitmask) + { + unsigned int bit = bitmask & (- bitmask); +@@ -16852,25 +16932,84 @@ decode_x86_isa (unsigned int 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; ++ case GNU_PROPERTY_X86_ISA_1_CMOV: ++ printf ("CMOV"); ++ 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_FMA: ++ printf ("FMA"); ++ 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; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS: ++ printf ("AVX512_4FMAPS"); ++ break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW: ++ printf ("AVX512_4VNNIW"); ++ break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_BITALG: ++ printf ("AVX512_BITALG"); ++ break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_IFMA: ++ printf ("AVX512_IFMA"); ++ break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_VBMI: ++ printf ("AVX512_VBMI"); ++ break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2: ++ printf ("AVX512_VBMI2"); ++ break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_VNNI: ++ printf ("AVX512_VNNI"); ++ break; ++ case GNU_PROPERTY_X86_ISA_1_AVX512_BF16: ++ printf ("AVX512_BF16"); ++ break; ++ default: ++ printf (_(""), bit); ++ break; + } + if (bitmask) + printf (", "); +@@ -16878,8 +17017,14 @@ decode_x86_isa (unsigned int bitmask) + } + + static void +-decode_x86_feature (unsigned int type, unsigned int bitmask) ++decode_x86_feature_1 (unsigned int bitmask) + { ++ if (!bitmask) ++ { ++ printf (_("")); ++ return; ++ } ++ + while (bitmask) + { + unsigned int bit = bitmask & (- bitmask); +@@ -16888,26 +17033,65 @@ decode_x86_feature (unsigned int type, u + switch (bit) + { + case GNU_PROPERTY_X86_FEATURE_1_IBT: +- switch (type) +- { +- case GNU_PROPERTY_X86_FEATURE_1_AND: +- printf ("IBT"); +- break; +- default: +- /* This should never happen. */ +- abort (); +- } ++ printf ("IBT"); + break; + case GNU_PROPERTY_X86_FEATURE_1_SHSTK: +- switch (type) +- { +- case GNU_PROPERTY_X86_FEATURE_1_AND: +- printf ("SHSTK"); +- break; +- default: +- /* This should never happen. */ +- abort (); +- } ++ printf ("SHSTK"); ++ break; ++ default: ++ printf (_(""), bit); ++ break; ++ } ++ if (bitmask) ++ printf (", "); ++ } ++} ++ ++static void ++decode_x86_feature_2 (unsigned int bitmask) ++{ ++ if (!bitmask) ++ { ++ printf (_("")); ++ return; ++ } ++ ++ while (bitmask) ++ { ++ unsigned int bit = bitmask & (- bitmask); ++ ++ bitmask &= ~ bit; ++ switch (bit) ++ { ++ case GNU_PROPERTY_X86_FEATURE_2_X86: ++ printf ("x86"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_X87: ++ printf ("x87"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_MMX: ++ printf ("MMX"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_XMM: ++ printf ("XMM"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_YMM: ++ printf ("YMM"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_ZMM: ++ printf ("ZMM"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_FXSR: ++ printf ("FXSR"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_XSAVE: ++ printf ("XSAVE"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT: ++ printf ("XSAVEOPT"); ++ break; ++ case GNU_PROPERTY_X86_FEATURE_2_XSAVEC: ++ printf ("XSAVEC"); + break; + default: + printf (_(""), bit); +@@ -16963,30 +17147,89 @@ print_gnu_property_note (Filedata * file + || filedata->file_header.e_machine == EM_IAMCU + || filedata->file_header.e_machine == EM_386) + { ++ unsigned int bitmask; ++ ++ if (datasz == 4) ++ bitmask = byte_get (ptr, 4); ++ else ++ bitmask = 0; ++ + switch (type) + { + case GNU_PROPERTY_X86_ISA_1_USED: +- printf ("x86 ISA used: "); + if (datasz != 4) +- printf (_(" "), datasz); ++ printf (_("x86 ISA used: "), ++ datasz); + else +- decode_x86_isa (byte_get (ptr, 4)); ++ { ++ printf ("x86 ISA used: "); ++ decode_x86_isa (bitmask); ++ } + goto next; + + case GNU_PROPERTY_X86_ISA_1_NEEDED: +- printf ("x86 ISA needed: "); + if (datasz != 4) +- printf (_(" "), datasz); ++ printf (_("x86 ISA needed: "), ++ datasz); + else +- decode_x86_isa (byte_get (ptr, 4)); ++ { ++ printf ("x86 ISA needed: "); ++ decode_x86_isa (bitmask); ++ } + goto next; + + case GNU_PROPERTY_X86_FEATURE_1_AND: +- printf ("x86 feature: "); + if (datasz != 4) +- printf (_(" "), datasz); ++ printf (_("x86 feature: "), ++ datasz); + else +- decode_x86_feature (type, byte_get (ptr, 4)); ++ { ++ printf ("x86 feature: "); ++ decode_x86_feature_1 (bitmask); ++ } ++ goto next; ++ ++ case GNU_PROPERTY_X86_FEATURE_2_USED: ++ if (datasz != 4) ++ printf (_("x86 feature used: "), ++ datasz); ++ else ++ { ++ printf ("x86 feature used: "); ++ decode_x86_feature_2 (bitmask); ++ } ++ goto next; ++ ++ case GNU_PROPERTY_X86_FEATURE_2_NEEDED: ++ if (datasz != 4) ++ printf (_("x86 feature needed: "), datasz); ++ else ++ { ++ printf ("x86 feature needed: "); ++ decode_x86_feature_2 (bitmask); ++ } ++ goto next; ++ ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_USED: ++ if (datasz != 4) ++ printf (_("x86 ISA used: "), ++ datasz); ++ else ++ { ++ printf ("x86 ISA used: "); ++ decode_x86_compat_isa (bitmask); ++ } ++ goto next; ++ ++ case GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED: ++ if (datasz != 4) ++ printf (_("x86 ISA needed: "), ++ datasz); ++ else ++ { ++ printf ("x86 ISA needed: "); ++ decode_x86_compat_isa (bitmask); ++ } + goto next; + + default: +@@ -17144,7 +17387,7 @@ print_gnu_note (Filedata * filedata, Elf + case NT_GNU_PROPERTY_TYPE_0: + print_gnu_property_note (filedata, 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 +diff -rup binutils.orig/binutils/testsuite/binutils-all/i386/empty.d binutils-2.30/binutils/testsuite/binutils-all/i386/empty.d +--- binutils.orig/binutils/testsuite/binutils-all/i386/empty.d 2020-04-07 11:32:17.248776609 +0100 ++++ binutils-2.30/binutils/testsuite/binutils-all/i386/empty.d 2020-04-07 13:34:03.901784074 +0100 +@@ -6,4 +6,4 @@ + Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 feature: ++ Properties: x86 feature: +diff -rup binutils.orig/binutils/testsuite/binutils-all/i386/pr21231b.d binutils-2.30/binutils/testsuite/binutils-all/i386/pr21231b.d +--- binutils.orig/binutils/testsuite/binutils-all/i386/pr21231b.d 2020-04-07 11:32:17.248776609 +0100 ++++ binutils-2.30/binutils/testsuite/binutils-all/i386/pr21231b.d 2020-04-07 13:34:03.901784074 +0100 +@@ -1,5 +1,5 @@ + #PROG: objcopy +-#as: --32 ++#as: --32 -mx86-used-note=yes + #objcopy: + #readelf: -n + +@@ -8,5 +8,8 @@ Displaying notes found in: .note.gnu.pro + GNU 0x0000002c NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + no copy on protected +- x86 ISA used: i486, 586, 686, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, , , , , , , , , , , , , , +- x86 ISA needed: i486, 586, 686, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL ++ x86 ISA used: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, AVX512_4FMAPS, AVX512_4VNNIW, AVX512_BITALG, AVX512_IFMA, AVX512_VBMI, AVX512_VBMI2, AVX512_VNNI, AVX512_BF16, , , , , , ++ x86 ISA needed: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ ++ GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/binutils/testsuite/binutils-all/i386/pr21231b.s binutils-2.30/binutils/testsuite/binutils-all/i386/pr21231b.s +--- binutils.orig/binutils/testsuite/binutils-all/i386/pr21231b.s 2020-04-07 11:32:17.248776609 +0100 ++++ binutils-2.30/binutils/testsuite/binutils-all/i386/pr21231b.s 2020-04-07 13:34:03.902784067 +0100 +@@ -19,14 +19,14 @@ + .long 0 /* pr_datasz. */ + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_USED */ +- .long 0xc0000000 /* pr_type. */ ++ .long 0xc0010000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ + 3: +- .long -1 ++ .long 0x7fffffff + 4: + .p2align 2 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ +- .long 0xc0000001 /* pr_type. */ ++ .long 0xc0008000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ + 3: + .long 0xffff +diff -rup binutils.orig/binutils/testsuite/binutils-all/x86-64/empty-x32.d binutils-2.30/binutils/testsuite/binutils-all/x86-64/empty-x32.d +--- binutils.orig/binutils/testsuite/binutils-all/x86-64/empty-x32.d 2020-04-07 11:32:17.250776595 +0100 ++++ binutils-2.30/binutils/testsuite/binutils-all/x86-64/empty-x32.d 2020-04-07 13:34:03.902784067 +0100 +@@ -7,4 +7,4 @@ + Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 feature: ++ Properties: x86 feature: +diff -rup binutils.orig/binutils/testsuite/binutils-all/x86-64/empty.d binutils-2.30/binutils/testsuite/binutils-all/x86-64/empty.d +--- binutils.orig/binutils/testsuite/binutils-all/x86-64/empty.d 2020-04-07 11:32:17.250776595 +0100 ++++ binutils-2.30/binutils/testsuite/binutils-all/x86-64/empty.d 2020-04-07 13:34:03.902784067 +0100 +@@ -6,4 +6,4 @@ + Displaying notes found in: .note.gnu.property + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 feature: ++ Properties: x86 feature: +diff -rup binutils.orig/binutils/testsuite/binutils-all/x86-64/pr21231b.d binutils-2.30/binutils/testsuite/binutils-all/x86-64/pr21231b.d +--- binutils.orig/binutils/testsuite/binutils-all/x86-64/pr21231b.d 2020-04-07 11:32:17.250776595 +0100 ++++ binutils-2.30/binutils/testsuite/binutils-all/x86-64/pr21231b.d 2020-04-07 13:34:03.902784067 +0100 +@@ -1,5 +1,5 @@ + #PROG: objcopy +-#as: --64 ++#as: --64 -mx86-used-note=yes + #objcopy: + #readelf: -n + +@@ -8,5 +8,8 @@ Displaying notes found in: .note.gnu.pro + GNU 0x00000038 NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 + no copy on protected +- x86 ISA used: i486, 586, 686, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, , , , , , , , , , , , , , +- x86 ISA needed: i486, 586, 686, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL ++ x86 ISA used: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, AVX512_4FMAPS, AVX512_4VNNIW, AVX512_BITALG, AVX512_IFMA, AVX512_VBMI, AVX512_VBMI2, AVX512_VNNI, AVX512_BF16, , , , , , ++ x86 ISA needed: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ ++ GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/binutils/testsuite/binutils-all/x86-64/pr21231b.s binutils-2.30/binutils/testsuite/binutils-all/x86-64/pr21231b.s +--- binutils.orig/binutils/testsuite/binutils-all/x86-64/pr21231b.s 2020-04-07 11:32:17.250776595 +0100 ++++ binutils-2.30/binutils/testsuite/binutils-all/x86-64/pr21231b.s 2020-04-07 13:34:03.902784067 +0100 +@@ -19,14 +19,14 @@ + .long 0 /* pr_datasz. */ + .p2align 3 + /* GNU_PROPERTY_X86_ISA_1_USED */ +- .long 0xc0000000 /* pr_type. */ ++ .long 0xc0010000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ + 3: +- .long -1 ++ .long 0x7fffffff + 4: + .p2align 3 + /* GNU_PROPERTY_X86_ISA_1_NEEDED */ +- .long 0xc0000001 /* pr_type. */ ++ .long 0xc0008000 /* pr_type. */ + .long 4f - 3f /* pr_datasz. */ + 3: + .long 0xffff +diff -rup binutils.orig/gas/config/tc-i386.c binutils-2.30/gas/config/tc-i386.c +--- binutils.orig/gas/config/tc-i386.c 2020-04-07 11:32:17.528774573 +0100 ++++ binutils-2.30/gas/config/tc-i386.c 2020-04-07 13:36:05.123911315 +0100 +@@ -191,6 +191,13 @@ static void s_bss (int); + #endif + #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) + static void handle_large_common (int small ATTRIBUTE_UNUSED); ++ ++/* GNU_PROPERTY_X86_ISA_1_USED. */ ++static unsigned int x86_isa_1_used; ++/* GNU_PROPERTY_X86_FEATURE_2_USED. */ ++static unsigned int x86_feature_2_used; ++/* Generate x86 used ISA and feature properties. */ ++static unsigned int x86_used_note = DEFAULT_X86_USED_NOTE; + #endif + + static const char *default_arch = DEFAULT_ARCH; +@@ -7421,6 +7428,127 @@ encoding_length (const fragS *start_frag + return len - start_off + (frag_now_ptr - frag_now->fr_literal); + } + ++#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) ++void ++x86_cleanup (void) ++{ ++ char *p; ++ asection *seg = now_seg; ++ subsegT subseg = now_subseg; ++ asection *sec; ++ unsigned int alignment, align_size_1; ++ unsigned int isa_1_descsz, feature_2_descsz, descsz; ++ unsigned int isa_1_descsz_raw, feature_2_descsz_raw; ++ unsigned int padding; ++ ++ if (!IS_ELF || !x86_used_note) ++ return; ++ ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_X86; ++ ++ /* The .note.gnu.property section layout: ++ ++ Field Length Contents ++ ---- ---- ---- ++ n_namsz 4 4 ++ n_descsz 4 The note descriptor size ++ n_type 4 NT_GNU_PROPERTY_TYPE_0 ++ n_name 4 "GNU" ++ n_desc n_descsz The program property array ++ .... .... .... ++ */ ++ ++ /* Create the .note.gnu.property section. */ ++ sec = subseg_new (NOTE_GNU_PROPERTY_SECTION_NAME, 0); ++ bfd_set_section_flags (stdoutput, sec, ++ (SEC_ALLOC ++ | SEC_LOAD ++ | SEC_DATA ++ | SEC_HAS_CONTENTS ++ | SEC_READONLY)); ++ ++ if (get_elf_backend_data (stdoutput)->s->elfclass == ELFCLASS64) ++ { ++ align_size_1 = 7; ++ alignment = 3; ++ } ++ else ++ { ++ align_size_1 = 3; ++ alignment = 2; ++ } ++ ++ bfd_set_section_alignment (stdoutput, sec, alignment); ++ elf_section_type (sec) = SHT_NOTE; ++ ++ /* GNU_PROPERTY_X86_ISA_1_USED: 4-byte type + 4-byte data size ++ + 4-byte data */ ++ isa_1_descsz_raw = 4 + 4 + 4; ++ /* Align GNU_PROPERTY_X86_ISA_1_USED. */ ++ isa_1_descsz = (isa_1_descsz_raw + align_size_1) & ~align_size_1; ++ ++ feature_2_descsz_raw = isa_1_descsz; ++ /* GNU_PROPERTY_X86_FEATURE_2_USED: 4-byte type + 4-byte data size ++ + 4-byte data */ ++ feature_2_descsz_raw += 4 + 4 + 4; ++ /* Align GNU_PROPERTY_X86_FEATURE_2_USED. */ ++ feature_2_descsz = ((feature_2_descsz_raw + align_size_1) ++ & ~align_size_1); ++ ++ descsz = feature_2_descsz; ++ /* Section size: n_namsz + n_descsz + n_type + n_name + n_descsz. */ ++ p = frag_more (4 + 4 + 4 + 4 + descsz); ++ ++ /* Write n_namsz. */ ++ md_number_to_chars (p, (valueT) 4, 4); ++ ++ /* Write n_descsz. */ ++ md_number_to_chars (p + 4, (valueT) descsz, 4); ++ ++ /* Write n_type. */ ++ md_number_to_chars (p + 4 * 2, (valueT) NT_GNU_PROPERTY_TYPE_0, 4); ++ ++ /* Write n_name. */ ++ memcpy (p + 4 * 3, "GNU", 4); ++ ++ /* Write 4-byte type. */ ++ md_number_to_chars (p + 4 * 4, ++ (valueT) GNU_PROPERTY_X86_ISA_1_USED, 4); ++ ++ /* Write 4-byte data size. */ ++ md_number_to_chars (p + 4 * 5, (valueT) 4, 4); ++ ++ /* Write 4-byte data. */ ++ md_number_to_chars (p + 4 * 6, (valueT) x86_isa_1_used, 4); ++ ++ /* Zero out paddings. */ ++ padding = isa_1_descsz - isa_1_descsz_raw; ++ if (padding) ++ memset (p + 4 * 7, 0, padding); ++ ++ /* Write 4-byte type. */ ++ md_number_to_chars (p + isa_1_descsz + 4 * 4, ++ (valueT) GNU_PROPERTY_X86_FEATURE_2_USED, 4); ++ ++ /* Write 4-byte data size. */ ++ md_number_to_chars (p + isa_1_descsz + 4 * 5, (valueT) 4, 4); ++ ++ /* Write 4-byte data. */ ++ md_number_to_chars (p + isa_1_descsz + 4 * 6, ++ (valueT) x86_feature_2_used, 4); ++ ++ /* Zero out paddings. */ ++ padding = feature_2_descsz - feature_2_descsz_raw; ++ if (padding) ++ memset (p + isa_1_descsz + 4 * 7, 0, padding); ++ ++ /* We probably can't restore the current segment, for there likely ++ isn't one yet... */ ++ if (seg && subseg) ++ subseg_set (seg, subseg); ++} ++#endif ++ + static void + output_insn (void) + { +@@ -7429,6 +7557,99 @@ output_insn (void) + fragS *fragP = NULL; + enum align_branch_kind branch = align_branch_none; + ++#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) ++ if (IS_ELF && x86_used_note) ++ { ++#if 0 ++ if (i.tm.cpu_flags.bitfield.cpucmov) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_CMOV; ++#endif ++ if (i.tm.cpu_flags.bitfield.cpusse) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE; ++ if (i.tm.cpu_flags.bitfield.cpusse2) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE2; ++ if (i.tm.cpu_flags.bitfield.cpusse3) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE3; ++ if (i.tm.cpu_flags.bitfield.cpussse3) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSSE3; ++ if (i.tm.cpu_flags.bitfield.cpusse4_1) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE4_1; ++ if (i.tm.cpu_flags.bitfield.cpusse4_2) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_SSE4_2; ++ if (i.tm.cpu_flags.bitfield.cpuavx) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX; ++ if (i.tm.cpu_flags.bitfield.cpuavx2) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX2; ++ if (i.tm.cpu_flags.bitfield.cpufma) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_FMA; ++ if (i.tm.cpu_flags.bitfield.cpuavx512f) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512F; ++ if (i.tm.cpu_flags.bitfield.cpuavx512cd) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512CD; ++ if (i.tm.cpu_flags.bitfield.cpuavx512er) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512ER; ++ if (i.tm.cpu_flags.bitfield.cpuavx512pf) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512PF; ++ if (i.tm.cpu_flags.bitfield.cpuavx512vl) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512VL; ++ if (i.tm.cpu_flags.bitfield.cpuavx512dq) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512DQ; ++ if (i.tm.cpu_flags.bitfield.cpuavx512bw) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512BW; ++ if (i.tm.cpu_flags.bitfield.cpuavx512_4fmaps) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS; ++ if (i.tm.cpu_flags.bitfield.cpuavx512_4vnniw) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW; ++ if (i.tm.cpu_flags.bitfield.cpuavx512_bitalg) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_BITALG; ++ if (i.tm.cpu_flags.bitfield.cpuavx512ifma) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_IFMA; ++ if (i.tm.cpu_flags.bitfield.cpuavx512vbmi) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_VBMI; ++ if (i.tm.cpu_flags.bitfield.cpuavx512_vbmi2) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2; ++ if (i.tm.cpu_flags.bitfield.cpuavx512_vnni) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_VNNI; ++#if 0 ++ if (i.tm.cpu_flags.bitfield.cpuavx512_bf16) ++ x86_isa_1_used |= GNU_PROPERTY_X86_ISA_1_AVX512_BF16; ++#endif ++ ++ if (i.tm.cpu_flags.bitfield.cpu8087 ++ || i.tm.cpu_flags.bitfield.cpu287 ++ || i.tm.cpu_flags.bitfield.cpu387 ++ || i.tm.cpu_flags.bitfield.cpu687 ++ || i.tm.cpu_flags.bitfield.cpufisttp) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_X87; ++#if 0 ++ /* Don't set GNU_PROPERTY_X86_FEATURE_2_MMX for prefetchtXXX nor ++ Xfence instructions. */ ++ if (i.tm.base_opcode != 0xf18 ++ && i.tm.base_opcode != 0xf0d ++ && i.tm.base_opcode != 0xfae ++ && (i.has_regmmx ++ || i.tm.cpu_flags.bitfield.cpummx ++ || i.tm.cpu_flags.bitfield.cpua3dnow ++ || i.tm.cpu_flags.bitfield.cpua3dnowa)) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_MMX; ++ if (i.has_regxmm) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XMM; ++ if (i.has_regymm) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_YMM; ++ if (i.has_regzmm) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_ZMM; ++ if (i.tm.cpu_flags.bitfield.cpufxsr) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_FXSR; ++#endif ++ if (i.tm.cpu_flags.bitfield.cpuxsave) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XSAVE; ++ if (i.tm.cpu_flags.bitfield.cpuxsaveopt) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT; ++ if (i.tm.cpu_flags.bitfield.cpuxsavec) ++ x86_feature_2_used |= GNU_PROPERTY_X86_FEATURE_2_XSAVEC; ++ } ++#endif ++ + /* Tie dwarf2 debug info to the address at the start of the insn. + We can't do this after the insn has been output as the current + frag may have been closed off. eg. by frag_var. */ +@@ -10829,6 +11050,7 @@ const char *md_shortopts = "qn"; + #define OPTION_MALIGN_BRANCH_PREFIX_SIZE (OPTION_MD_BASE + 28) + #define OPTION_MALIGN_BRANCH (OPTION_MD_BASE + 29) + #define OPTION_MBRANCHES_WITH_32B_BOUNDARIES (OPTION_MD_BASE + 30) ++#define OPTION_X86_USED_NOTE (OPTION_MD_BASE + 31) + + struct option md_longopts[] = + { +@@ -10840,6 +11062,7 @@ struct option md_longopts[] = + #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) + {"x32", no_argument, NULL, OPTION_X32}, + {"mshared", no_argument, NULL, OPTION_MSHARED}, ++ {"mx86-used-note", required_argument, NULL, OPTION_X86_USED_NOTE}, + #endif + {"divide", no_argument, NULL, OPTION_DIVIDE}, + {"march", required_argument, NULL, OPTION_MARCH}, +@@ -10957,6 +11180,15 @@ md_parse_option (int c, const char *arg) + else + as_fatal (_("32bit x86_64 is only supported for ELF")); + break; ++ ++ case OPTION_X86_USED_NOTE: ++ if (strcasecmp (arg, "yes") == 0) ++ x86_used_note = 1; ++ else if (strcasecmp (arg, "no") == 0) ++ x86_used_note = 0; ++ else ++ as_fatal (_("invalid -mx86-used-note= option: `%s'"), arg); ++ break; + #endif + + case OPTION_32: +@@ -11448,6 +11680,14 @@ md_show_usage (FILE *stream) + #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) + fprintf (stream, _("\ + -s ignored\n")); ++ fprintf (stream, _("\ ++ -mx86-used-note=[no|yes] ")); ++ if (DEFAULT_X86_USED_NOTE) ++ fprintf (stream, _("(default: yes)\n")); ++ else ++ fprintf (stream, _("(default: no)\n")); ++ fprintf (stream, _("\ ++ generate x86 used ISA and feature properties\n")); + #endif + #if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \ + || defined (TE_PE) || defined (TE_PEP)) +diff -rup binutils.orig/gas/config/tc-i386.h binutils-2.30/gas/config/tc-i386.h +--- binutils.orig/gas/config/tc-i386.h 2020-04-07 11:32:17.526774588 +0100 ++++ binutils-2.30/gas/config/tc-i386.h 2020-04-07 13:34:03.904784053 +0100 +@@ -346,6 +346,11 @@ extern bfd_vma x86_64_section_letter (in + #define md_elf_section_letter(LETTER, PTR_MSG) x86_64_section_letter (LETTER, PTR_MSG) + #define md_elf_section_word(STR, LEN) x86_64_section_word (STR, LEN) + ++#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) ++extern void x86_cleanup (void); ++#define md_cleanup() x86_cleanup () ++#endif ++ + #ifdef TE_PE + + #define O_secrel O_md1 +diff -rup binutils.orig/gas/config.in binutils-2.30/gas/config.in +--- binutils.orig/gas/config.in 2020-04-07 11:32:17.532774544 +0100 ++++ binutils-2.30/gas/config.in 2020-04-07 13:34:03.904784053 +0100 +@@ -50,6 +50,10 @@ + /* Define to 1 if you want to generate x86 relax relocations by default. */ + #undef DEFAULT_GENERATE_X86_RELAX_RELOCATIONS + ++/* Define to 1 if you want to generate GNU x86 used ISA and feature properties ++ by default. */ ++#undef DEFAULT_X86_USED_NOTE ++ + /* Supported emulations. */ + #undef EMULATIONS + +diff -rup binutils.orig/gas/configure binutils-2.30/gas/configure +--- binutils.orig/gas/configure 2020-04-07 11:32:17.519774639 +0100 ++++ binutils-2.30/gas/configure 2020-04-07 13:34:03.905784046 +0100 +@@ -772,6 +772,7 @@ enable_compressed_debug_sections + enable_x86_relax_relocations + enable_elf_stt_common + enable_generate_build_notes ++enable_x86_used_note + enable_werror + enable_build_warnings + with_cpu +@@ -11788,6 +11789,18 @@ if test "${enable_generate_build_notes+s + esac + fi + ++# Decide if the x86 ELF assembler should default to generating GNU x86 ++# used ISA and feature properties. ++ac_default_generate_x86_used_note=unset ++# Provide a configuration option to override the default. ++# Check whether --enable-x86-used-note was given. ++if test "${enable_x86_used_note+set}" = set; then : ++ enableval=$enable_x86_used_note; case "${enableval}" in ++ yes) ac_default_generate_x86_used_note=1 ;; ++ no) ac_default_generate_x86_used_note=0 ;; ++esac ++fi ++ + + using_cgen=no + +@@ -12736,6 +12749,14 @@ cat >>confdefs.h <<_ACEOF + #define DEFAULT_GENERATE_BUILD_NOTES $ac_default_generate_build_notes + _ACEOF + ++if test ${ac_default_generate_x86_used_note} = unset; then ++ ac_default_generate_x86_used_note=0 ++fi ++ ++cat >>confdefs.h <<_ACEOF ++#define DEFAULT_X86_USED_NOTE $ac_default_generate_x86_used_note ++_ACEOF ++ + + if test x$ac_default_compressed_debug_sections = xyes ; then + +diff -rup binutils.orig/gas/configure.ac binutils-2.30/gas/configure.ac +--- binutils.orig/gas/configure.ac 2020-04-07 11:32:17.533774537 +0100 ++++ binutils-2.30/gas/configure.ac 2020-04-07 13:34:03.905784046 +0100 +@@ -113,6 +113,17 @@ AC_ARG_ENABLE(generate_build_notes, + no) ac_default_generate_build_notes=0 ;; + esac])dnl + ++# Decide if the x86 ELF assembler should default to generating GNU x86 ++# used ISA and feature properties. ++ac_default_generate_x86_used_note=unset ++# Provide a configuration option to override the default. ++AC_ARG_ENABLE(x86-used-note, ++ AS_HELP_STRING([--enable-x86-used-note], ++ [generate GNU x86 used ISA and feature properties]), ++[case "${enableval}" in ++ yes) ac_default_generate_x86_used_note=1 ;; ++ no) ac_default_generate_x86_used_note=0 ;; ++esac])dnl + + using_cgen=no + +@@ -629,6 +640,25 @@ AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_BUIL + [Define to 1 if you want to generate GNU Build attribute notes + by default, if none are contained in the input.]) + ++if test ${ac_default_generate_x86_used_note} = unset; then ++ ac_default_generate_x86_used_note=0 ++fi ++AC_DEFINE_UNQUOTED(DEFAULT_X86_USED_NOTE, ++ $ac_default_generate_x86_used_note, ++ [Define to 1 if you want to generate GNU x86 used ISA and feature ++ properties by default.]) ++ ++if test ${ac_default_generate_riscv_attr} = unset; then ++ case ${target_os} in ++ elf) ++ ac_default_generate_riscv_attr=1 ++ ;; ++ *) ++ ac_default_generate_riscv_attr=0 ++ ;; ++ esac ++fi ++ + if test x$ac_default_compressed_debug_sections = xyes ; then + AC_DEFINE(DEFAULT_FLAG_COMPRESS_DEBUG, 1, [Define if you want compressed debug sections by default.]) + fi +diff -rup binutils.orig/gas/testsuite/gas/i386/i386.exp binutils-2.30/gas/testsuite/gas/i386/i386.exp +--- binutils.orig/gas/testsuite/gas/i386/i386.exp 2020-04-07 11:32:17.596774079 +0100 ++++ binutils-2.30/gas/testsuite/gas/i386/i386.exp 2020-04-07 13:34:03.906784038 +0100 +@@ -507,6 +507,9 @@ if [expr ([istarget "i*86-*-*"] || [ist + run_dump_test "align-branch-3" + } + ++ run_dump_test "property-1" ++ # run_dump_test "property-2" ++ + if { [gas_64_check] } then { + run_dump_test "att-regs" + run_dump_test "intel-regs" +diff -rup binutils.orig/include/bfdlink.h binutils-2.30/include/bfdlink.h +--- binutils.orig/include/bfdlink.h 2020-04-07 11:32:17.506774733 +0100 ++++ binutils-2.30/include/bfdlink.h 2020-04-07 13:34:03.906784038 +0100 +@@ -489,6 +489,9 @@ struct bfd_link_info + /* TRUE if GNU_PROPERTY_X86_FEATURE_1_SHSTK should be generated. */ + unsigned int shstk: 1; + ++ /* 0 = > no report, 1 => warn, 2=> error. */ ++ unsigned int cet_report: 2; ++ + /* TRUE if generation of .interp/PT_INTERP should be suppressed. */ + unsigned int nointerp: 1; + +diff -rup binutils.orig/include/elf/common.h binutils-2.30/include/elf/common.h +--- binutils.orig/include/elf/common.h 2020-04-07 11:32:17.511774697 +0100 ++++ binutils-2.30/include/elf/common.h 2020-04-07 13:34:03.906784038 +0100 +@@ -460,6 +460,7 @@ + #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */ + #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */ + #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */ ++#define PT_GNU_PROPERTY (PT_LOOS + 0x474e553) /* GNU property */ + + /* Mbind segments */ + #define PT_GNU_MBIND_NUM 4096 +@@ -740,31 +741,96 @@ + /* 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_FEATURE_1_AND 0xc0000002 +- +-#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) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_USED 0xc0000000 ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_NEEDED 0xc0000001 + +-#define GNU_PROPERTY_X86_FEATURE_1_IBT (1U << 0) +-#define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_486 (1U << 0) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_586 (1U << 1) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_686 (1U << 2) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_SSE (1U << 3) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_SSE2 (1U << 4) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_SSE3 (1U << 5) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_SSSE3 (1U << 6) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_SSE4_1 (1U << 7) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_SSE4_2 (1U << 8) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX (1U << 9) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX2 (1U << 10) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512F (1U << 11) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512CD (1U << 12) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512ER (1U << 13) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512PF (1U << 14) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512VL (1U << 15) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512DQ (1U << 16) ++#define GNU_PROPERTY_X86_COMPAT_ISA_1_AVX512BW (1U << 17) ++ ++/* A 4-byte unsigned integer property: A bit is set if it is set in all ++ relocatable inputs. */ ++#define GNU_PROPERTY_X86_UINT32_AND_LO 0xc0000002 ++#define GNU_PROPERTY_X86_UINT32_AND_HI 0xc0007fff ++ ++/* A 4-byte unsigned integer property: A bit is set if it is set in any ++ relocatable inputs. */ ++#define GNU_PROPERTY_X86_UINT32_OR_LO 0xc0008000 ++#define GNU_PROPERTY_X86_UINT32_OR_HI 0xc000ffff ++ ++/* A 4-byte unsigned integer property: A bit is set if it is set in any ++ relocatable inputs and the property is present in all relocatable ++ inputs. */ ++#define GNU_PROPERTY_X86_UINT32_OR_AND_LO 0xc0010000 ++#define GNU_PROPERTY_X86_UINT32_OR_AND_HI 0xc0017fff ++ ++#define GNU_PROPERTY_X86_FEATURE_1_AND \ ++ (GNU_PROPERTY_X86_UINT32_AND_LO + 0) ++ ++#define GNU_PROPERTY_X86_ISA_1_NEEDED \ ++ (GNU_PROPERTY_X86_UINT32_OR_LO + 0) ++#define GNU_PROPERTY_X86_FEATURE_2_NEEDED \ ++ (GNU_PROPERTY_X86_UINT32_OR_LO + 1) ++ ++#define GNU_PROPERTY_X86_ISA_1_USED \ ++ (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 0) ++#define GNU_PROPERTY_X86_FEATURE_2_USED \ ++ (GNU_PROPERTY_X86_UINT32_OR_AND_LO + 1) ++ ++#define GNU_PROPERTY_X86_FEATURE_1_IBT (1U << 0) ++#define GNU_PROPERTY_X86_FEATURE_1_SHSTK (1U << 1) ++ ++#define GNU_PROPERTY_X86_ISA_1_CMOV (1U << 0) ++#define GNU_PROPERTY_X86_ISA_1_SSE (1U << 1) ++#define GNU_PROPERTY_X86_ISA_1_SSE2 (1U << 2) ++#define GNU_PROPERTY_X86_ISA_1_SSE3 (1U << 3) ++#define GNU_PROPERTY_X86_ISA_1_SSSE3 (1U << 4) ++#define GNU_PROPERTY_X86_ISA_1_SSE4_1 (1U << 5) ++#define GNU_PROPERTY_X86_ISA_1_SSE4_2 (1U << 6) ++#define GNU_PROPERTY_X86_ISA_1_AVX (1U << 7) ++#define GNU_PROPERTY_X86_ISA_1_AVX2 (1U << 8) ++#define GNU_PROPERTY_X86_ISA_1_FMA (1U << 9) ++#define GNU_PROPERTY_X86_ISA_1_AVX512F (1U << 10) ++#define GNU_PROPERTY_X86_ISA_1_AVX512CD (1U << 11) ++#define GNU_PROPERTY_X86_ISA_1_AVX512ER (1U << 12) ++#define GNU_PROPERTY_X86_ISA_1_AVX512PF (1U << 13) ++#define GNU_PROPERTY_X86_ISA_1_AVX512VL (1U << 14) ++#define GNU_PROPERTY_X86_ISA_1_AVX512DQ (1U << 15) ++#define GNU_PROPERTY_X86_ISA_1_AVX512BW (1U << 16) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_4FMAPS (1U << 17) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_4VNNIW (1U << 18) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_BITALG (1U << 19) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_IFMA (1U << 20) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_VBMI (1U << 21) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_VBMI2 (1U << 22) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_VNNI (1U << 23) ++#define GNU_PROPERTY_X86_ISA_1_AVX512_BF16 (1U << 24) ++ ++#define GNU_PROPERTY_X86_FEATURE_2_X86 (1U << 0) ++#define GNU_PROPERTY_X86_FEATURE_2_X87 (1U << 1) ++#define GNU_PROPERTY_X86_FEATURE_2_MMX (1U << 2) ++#define GNU_PROPERTY_X86_FEATURE_2_XMM (1U << 3) ++#define GNU_PROPERTY_X86_FEATURE_2_YMM (1U << 4) ++#define GNU_PROPERTY_X86_FEATURE_2_ZMM (1U << 5) ++#define GNU_PROPERTY_X86_FEATURE_2_FXSR (1U << 6) ++#define GNU_PROPERTY_X86_FEATURE_2_XSAVE (1U << 7) ++#define GNU_PROPERTY_X86_FEATURE_2_XSAVEOPT (1U << 8) ++#define GNU_PROPERTY_X86_FEATURE_2_XSAVEC (1U << 9) + + /* Values used in GNU .note.ABI-tag notes (NT_GNU_ABI_TAG). */ + #define GNU_ABI_TAG_LINUX 0 +diff -rup binutils.orig/ld/emulparams/cet.sh binutils-2.30/ld/emulparams/cet.sh +--- binutils.orig/ld/emulparams/cet.sh 2020-04-07 11:32:17.320776086 +0100 ++++ binutils-2.30/ld/emulparams/cet.sh 2020-04-07 13:34:03.907784031 +0100 +@@ -2,7 +2,8 @@ PARSE_AND_LIST_OPTIONS_CET=' + fprintf (file, _("\ + -z ibtplt Generate IBT-enabled PLT entries\n\ + -z ibt Generate GNU_PROPERTY_X86_FEATURE_1_IBT\n\ +- -z shstk Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK\n")); ++ -z shstk Generate GNU_PROPERTY_X86_FEATURE_1_SHSTK\n\ ++ -z cet-report=[none|warning|error] (default: none)\n")); + ' + PARSE_AND_LIST_ARGS_CASE_Z_CET=' + else if (strcmp (optarg, "ibtplt") == 0) +@@ -11,6 +12,18 @@ PARSE_AND_LIST_ARGS_CASE_Z_CET=' + link_info.ibt = TRUE; + else if (strcmp (optarg, "shstk") == 0) + link_info.shstk = TRUE; ++ else if (strncmp (optarg, "cet-report=", 11) == 0) ++ { ++ if (strcmp (optarg + 11, "none") == 0) ++ link_info.cet_report = 0; ++ else if (strcmp (optarg + 11, "warning") == 0) ++ link_info.cet_report = 1; ++ else if (strcmp (optarg + 11, "error") == 0) ++ link_info.cet_report = 2; ++ else ++ einfo (_("%F%P: invalid option for -z cet-report=: %s\n"), ++ optarg + 11); ++ } + ' + + PARSE_AND_LIST_OPTIONS="$PARSE_AND_LIST_OPTIONS $PARSE_AND_LIST_OPTIONS_CET" +diff -rup binutils.orig/ld/testsuite/ld-elf/elf.exp binutils-2.30/ld/testsuite/ld-elf/elf.exp +--- binutils.orig/ld/testsuite/ld-elf/elf.exp 2020-04-07 11:32:17.454775112 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/elf.exp 2020-04-07 13:34:03.907784031 +0100 +@@ -101,8 +101,10 @@ proc is_elf64 { binary_file } { + + if [is_elf64 tmpdir/symbol3w.a] { + set ASFLAGS "$ASFLAGS --defsym ALIGN=3" ++ set pr23900_1_exp "pr23900-1-64.rd" + } else { + set ASFLAGS "$ASFLAGS --defsym ALIGN=2" ++ set pr23900_1_exp "pr23900-1-32.rd" + } + + +@@ -317,12 +319,36 @@ if { [check_gc_sections_available] && ![ + if { [istarget *-*-*linux*] + || [istarget *-*-nacl*] + || [istarget *-*-gnu*] } { +- run_ld_link_tests { +- {"stack exec" "-z execstack" "" "" {stack.s} +- {{readelf {-Wl} stack-exec.rd}} "stack-exec.exe"} +- {"stack size" "-z stack-size=0x123400" "" "" {stack.s} +- {{readelf {-Wl} stack-size.rd}} "stack-size.exe"} +- } ++ run_ld_link_tests [list \ ++ [list "stack exec" \ ++ "-z execstack" \ ++ "" \ ++ "" \ ++ {stack.s} \ ++ {{readelf {-Wl} stack-exec.rd}} \ ++ "stack-exec.exe"] \ ++ [list "stack noexec" \ ++ "-z noexecstack" \ ++ "" \ ++ "" \ ++ {stack.s} \ ++ {{readelf {-Wl} stack-noexec.rd}} \ ++ "stack-noexec.exe"] \ ++ [list "stack size" \ ++ "-z stack-size=0x123400" \ ++ "" \ ++ "" \ ++ {stack.s} \ ++ {{readelf {-Wl} stack-size.rd}} \ ++ "stack-size.exe"] \ ++ [list "PT_GNU_PROPERTY alignment" \ ++ "" \ ++ "" \ ++ "" \ ++ {pr23900-1.s} \ ++ [list [list "readelf" {-Wl} $pr23900_1_exp]] \ ++ "pr23900-1.exe"] \ ++ ] + } + + set LDFLAGS $old_ldflags +diff -rup binutils.orig/ld/testsuite/ld-i386/ibt-plt-1.d binutils-2.30/ld/testsuite/ld-i386/ibt-plt-1.d +--- binutils.orig/ld/testsuite/ld-i386/ibt-plt-1.d 2020-04-07 11:32:17.358775810 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/ibt-plt-1.d 2020-04-07 13:34:03.907784031 +0100 +@@ -1,5 +1,5 @@ + #as: --32 +-#ld: -shared -m elf_i386 --hash-style=sysv ++#ld: -shared -m elf_i386 --hash-style=sysv -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -7,45 +7,45 @@ + + Disassembly of section .plt: + +-0+1b0 <.plt>: ++[a-f0-9]+ <.plt>: + +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\) + +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\) + +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\) + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: 68 00 00 00 00 push \$0x0 +- +[a-f0-9]+: e9 e2 ff ff ff jmp 1b0 <.plt> ++ +[a-f0-9]+: e9 e2 ff ff ff jmp [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: 68 08 00 00 00 push \$0x8 +- +[a-f0-9]+: e9 d2 ff ff ff jmp 1b0 <.plt> ++ +[a-f0-9]+: e9 d2 ff ff ff jmp [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + + Disassembly of section .plt.sec: + +-0+1e0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\) + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) + +-0+1f0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\) + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) + + Disassembly of section .text: + +-0+200 : ++[a-f0-9]+ : + +[a-f0-9]+: 53 push %ebx +- +[a-f0-9]+: e8 18 00 00 00 call 21e <__x86.get_pc_thunk.bx> +- +[a-f0-9]+: 81 c3 36 11 00 00 add \$0x1136,%ebx ++ +[a-f0-9]+: e8 18 00 00 00 call [a-f0-9]+ <__x86.get_pc_thunk.bx> ++ +[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add \$0x[a-f0-9]+,%ebx + +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp +- +[a-f0-9]+: e8 dc ff ff ff call 1f0 +- +[a-f0-9]+: e8 c7 ff ff ff call 1e0 ++ +[a-f0-9]+: e8 dc ff ff ff call [a-f0-9]+ ++ +[a-f0-9]+: e8 c7 ff ff ff call [a-f0-9]+ + +[a-f0-9]+: 83 c4 08 add \$0x8,%esp + +[a-f0-9]+: 5b pop %ebx + +[a-f0-9]+: c3 ret + +-0+21e <__x86.get_pc_thunk.bx>: ++[a-f0-9]+ <__x86.get_pc_thunk.bx>: + +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx + +[a-f0-9]+: c3 ret + #pass +diff -rup binutils.orig/ld/testsuite/ld-i386/ibt-plt-2a.d binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2a.d +--- binutils.orig/ld/testsuite/ld-i386/ibt-plt-2a.d 2020-04-07 11:32:17.361775788 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2a.d 2020-04-07 13:34:03.907784031 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --32 +-#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv ++#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,45 +8,45 @@ + + Disassembly of section .plt: + +-0+1b0 <.plt>: ++0+1.0 <.plt>: + +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\) + +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\) + +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\) + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: 68 00 00 00 00 push \$0x0 +- +[a-f0-9]+: e9 e2 ff ff ff jmp 1b0 <.plt> ++ +[a-f0-9]+: e9 e2 ff ff ff jmp 1.0 <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: 68 08 00 00 00 push \$0x8 +- +[a-f0-9]+: e9 d2 ff ff ff jmp 1b0 <.plt> ++ +[a-f0-9]+: e9 d2 ff ff ff jmp 1.0 <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + + Disassembly of section .plt.sec: + +-0+1e0 : ++0+1.0 : + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\) + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) + +-0+1f0 : ++0+1.0 : + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\) + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) + + Disassembly of section .text: + +-0+200 : ++0+1.0 : + +[a-f0-9]+: 53 push %ebx +- +[a-f0-9]+: e8 18 00 00 00 call 21e <__x86.get_pc_thunk.bx> +- +[a-f0-9]+: 81 c3 36 11 00 00 add \$0x1136,%ebx ++ +[a-f0-9]+: e8 18 00 00 00 call 1.e <__x86.get_pc_thunk.bx> ++ +[a-f0-9]+: 81 c3 1a 11 00 00 add \$0x111a,%ebx + +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp +- +[a-f0-9]+: e8 dc ff ff ff call 1f0 +- +[a-f0-9]+: e8 c7 ff ff ff call 1e0 ++ +[a-f0-9]+: e8 dc ff ff ff call 1.0 ++ +[a-f0-9]+: e8 c7 ff ff ff call 1.0 + +[a-f0-9]+: 83 c4 08 add \$0x8,%esp + +[a-f0-9]+: 5b pop %ebx + +[a-f0-9]+: c3 ret + +-0+21e <__x86.get_pc_thunk.bx>: ++0+1.e <__x86.get_pc_thunk.bx>: + +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx + +[a-f0-9]+: c3 ret + #pass +diff -rup binutils.orig/ld/testsuite/ld-i386/ibt-plt-2b.d binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2b.d +--- binutils.orig/ld/testsuite/ld-i386/ibt-plt-2b.d 2020-04-07 11:32:17.355775832 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2b.d 2020-04-07 13:34:03.907784031 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --32 +-#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv ++#ld: -shared -m elf_i386 -z ibtplt --hash-style=sysv -z noseparate-code + #readelf: -n -wf + + Contents of the .eh_frame section: +@@ -18,37 +18,31 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 0000001c 0000001c FDE cie=00000000 pc=00000200..0000021e +- DW_CFA_advance_loc: 1 to 00000201 ++0+18 0000001c 0000001c FDE cie=00000000 pc=000001.0..000001.e ++ DW_CFA_advance_loc: 1 to 000001.1 + DW_CFA_def_cfa_offset: 8 + DW_CFA_offset: r3 \(ebx\) at cfa-8 +- DW_CFA_advance_loc: 14 to 0000020f ++ DW_CFA_advance_loc: 14 to 000001.f + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 13 to 0000021c ++ DW_CFA_advance_loc: 13 to 000001.c + DW_CFA_def_cfa_offset: 8 +- DW_CFA_advance_loc: 1 to 0000021d ++ DW_CFA_advance_loc: 1 to 000001.d + DW_CFA_restore: r3 \(ebx\) + DW_CFA_def_cfa_offset: 4 + +-0+38 00000010 0000003c FDE cie=00000000 pc=0000021e..00000222 ++0+38 00000010 0000003c FDE cie=00000000 pc=000001.e..00000..2 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +-0+4c 00000020 00000050 FDE cie=00000000 pc=000001b0..000001e0 ++0+4c 00000020 00000050 FDE cie=00000000 pc=000001.0..000001.0 + DW_CFA_def_cfa_offset: 8 +- DW_CFA_advance_loc: 6 to 000001b6 ++ DW_CFA_advance_loc: 6 to 000001.6 + DW_CFA_def_cfa_offset: 12 +- DW_CFA_advance_loc: 10 to 000001c0 ++ DW_CFA_advance_loc: 10 to 000001.0 + DW_CFA_def_cfa_expression \(DW_OP_breg4 \(esp\): 4; DW_OP_breg8 \(eip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit2; DW_OP_shl; DW_OP_plus\) + +-0+70 00000010 00000074 FDE cie=00000000 pc=000001e0..00000200 ++0+70 00000010 00000074 FDE cie=00000000 pc=000001.0..000001.0 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +- +- +-Displaying notes found in: .note.gnu.property +- Owner Data size Description +- GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 feature: +diff -rup binutils.orig/ld/testsuite/ld-i386/ibt-plt-2c.d binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2c.d +--- binutils.orig/ld/testsuite/ld-i386/ibt-plt-2c.d 2020-04-07 11:32:17.357775817 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2c.d 2020-04-07 13:34:03.907784031 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --32 +-#ld: -shared -m elf_i386 -z ibt --hash-style=sysv ++#ld: -shared -m elf_i386 -z ibt --hash-style=sysv -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,45 +8,45 @@ + + Disassembly of section .plt: + +-0+1b0 <.plt>: ++[a-f0-9]+ <.plt>: + +[a-f0-9]+: ff b3 04 00 00 00 pushl 0x4\(%ebx\) + +[a-f0-9]+: ff a3 08 00 00 00 jmp \*0x8\(%ebx\) + +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%eax\) + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: 68 00 00 00 00 push \$0x0 +- +[a-f0-9]+: e9 e2 ff ff ff jmp 1b0 <.plt> ++ +[a-f0-9]+: e9 e2 ff ff ff jmp [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: 68 08 00 00 00 push \$0x8 +- +[a-f0-9]+: e9 d2 ff ff ff jmp 1b0 <.plt> ++ +[a-f0-9]+: e9 d2 ff ff ff jmp [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + + Disassembly of section .plt.sec: + +-0+1e0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: ff a3 0c 00 00 00 jmp \*0xc\(%ebx\) + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) + +-0+1f0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fb endbr32 + +[a-f0-9]+: ff a3 10 00 00 00 jmp \*0x10\(%ebx\) + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%eax,%eax,1\) + + Disassembly of section .text: + +-0+200 : ++[a-f0-9]+ : + +[a-f0-9]+: 53 push %ebx +- +[a-f0-9]+: e8 18 00 00 00 call 21e <__x86.get_pc_thunk.bx> +- +[a-f0-9]+: 81 c3 36 11 00 00 add \$0x1136,%ebx ++ +[a-f0-9]+: e8 18 00 00 00 call [0-9a-f]+ <__x86.get_pc_thunk.bx> ++ +[a-f0-9]+: 81 c3 ([0-9a-f]{2} ){4}[ ]+add \$0x[a-f0-9]+,%ebx + +[a-f0-9]+: 83 ec 08 sub \$0x8,%esp +- +[a-f0-9]+: e8 dc ff ff ff call 1f0 +- +[a-f0-9]+: e8 c7 ff ff ff call 1e0 ++ +[a-f0-9]+: e8 dc ff ff ff call [a-f0-9]+ ++ +[a-f0-9]+: e8 c7 ff ff ff call [a-f0-9]+ + +[a-f0-9]+: 83 c4 08 add \$0x8,%esp + +[a-f0-9]+: 5b pop %ebx + +[a-f0-9]+: c3 ret + +-0+21e <__x86.get_pc_thunk.bx>: ++[a-f0-9]+ <__x86.get_pc_thunk.bx>: + +[a-f0-9]+: 8b 1c 24 mov \(%esp\),%ebx + +[a-f0-9]+: c3 ret + #pass +diff -rup binutils.orig/ld/testsuite/ld-i386/ibt-plt-2d.d binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2d.d +--- binutils.orig/ld/testsuite/ld-i386/ibt-plt-2d.d 2020-04-07 11:32:17.354775839 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/ibt-plt-2d.d 2020-04-07 13:34:03.907784031 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --32 +-#ld: -shared -m elf_i386 -z ibt --hash-style=sysv ++#ld: -shared -m elf_i386 -z ibt --hash-style=sysv -z noseparate-code + #readelf: -n -wf + + Contents of the .eh_frame section: +@@ -18,31 +18,31 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 0000001c 0000001c FDE cie=00000000 pc=00000200..0000021e +- DW_CFA_advance_loc: 1 to 00000201 ++0+18 0000001c 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ ++ DW_CFA_advance_loc: 1 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 + DW_CFA_offset: r3 \(ebx\) at cfa-8 +- DW_CFA_advance_loc: 14 to 0000020f ++ DW_CFA_advance_loc: 14 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 13 to 0000021c ++ DW_CFA_advance_loc: 13 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 +- DW_CFA_advance_loc: 1 to 0000021d ++ DW_CFA_advance_loc: 1 to [a-f0-9]+ + DW_CFA_restore: r3 \(ebx\) + DW_CFA_def_cfa_offset: 4 + +-0+38 00000010 0000003c FDE cie=00000000 pc=0000021e..00000222 ++0+38 00000010 0000003c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +-0+4c 00000020 00000050 FDE cie=00000000 pc=000001b0..000001e0 ++0+4c 00000020 00000050 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_def_cfa_offset: 8 +- DW_CFA_advance_loc: 6 to 000001b6 ++ DW_CFA_advance_loc: 6 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 12 +- DW_CFA_advance_loc: 10 to 000001c0 ++ DW_CFA_advance_loc: 10 to [a-f0-9]+ + DW_CFA_def_cfa_expression \(DW_OP_breg4 \(esp\): 4; DW_OP_breg8 \(eip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit2; DW_OP_shl; DW_OP_plus\) + +-0+70 00000010 00000074 FDE cie=00000000 pc=000001e0..00000200 ++0+70 00000010 00000074 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +diff -rup binutils.orig/ld/testsuite/ld-i386/ibt-plt-3d.d binutils-2.30/ld/testsuite/ld-i386/ibt-plt-3d.d +--- binutils.orig/ld/testsuite/ld-i386/ibt-plt-3d.d 2020-04-07 11:32:17.364775766 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/ibt-plt-3d.d 2020-04-07 13:34:03.907784031 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-3.s + #as: --32 +-#ld: -shared -m elf_i386 -z ibt --hash-style=sysv ++#ld: -shared -m elf_i386 -z ibt --hash-style=sysv -z noseparate-code + #readelf: -wf -n + + Contents of the .eh_frame section: +@@ -18,31 +18,31 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 0000001c 0000001c FDE cie=00000000 pc=00000200..0000021e +- DW_CFA_advance_loc: 1 to 00000201 ++0+18 0000001c 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ ++ DW_CFA_advance_loc: 1 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 + DW_CFA_offset: r3 \(ebx\) at cfa-8 +- DW_CFA_advance_loc: 14 to 0000020f ++ DW_CFA_advance_loc: 14 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 13 to 0000021c ++ DW_CFA_advance_loc: 13 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 +- DW_CFA_advance_loc: 1 to 0000021d ++ DW_CFA_advance_loc: 1 to [a-f0-9]+ + DW_CFA_restore: r3 \(ebx\) + DW_CFA_def_cfa_offset: 4 + +-0+38 00000010 0000003c FDE cie=00000000 pc=0000021e..00000222 ++0+38 00000010 0000003c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +-0+4c 00000020 00000050 FDE cie=00000000 pc=000001b0..000001e0 ++0+4c 00000020 00000050 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_def_cfa_offset: 8 +- DW_CFA_advance_loc: 6 to 000001b6 ++ DW_CFA_advance_loc: 6 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 12 +- DW_CFA_advance_loc: 10 to 000001c0 ++ DW_CFA_advance_loc: 10 to [a-f0-9]+ + DW_CFA_def_cfa_expression \(DW_OP_breg4 \(esp\): 4; DW_OP_breg8 \(eip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit2; DW_OP_shl; DW_OP_plus\) + +-0+70 00000010 00000074 FDE cie=00000000 pc=000001e0..00000200 ++0+70 00000010 00000074 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +diff -rup binutils.orig/ld/testsuite/ld-i386/pr23372a.d binutils-2.30/ld/testsuite/ld-i386/pr23372a.d +--- binutils.orig/ld/testsuite/ld-i386/pr23372a.d 2020-04-07 11:32:17.357775817 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/pr23372a.d 2020-04-07 13:34:03.907784031 +0100 +@@ -3,3 +3,8 @@ + #as: --32 + #ld: -r -m elf_i386 + #readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA used: +diff -rup binutils.orig/ld/testsuite/ld-i386/property-x86-ibt3a.d binutils-2.30/ld/testsuite/ld-i386/property-x86-ibt3a.d +--- binutils.orig/ld/testsuite/ld-i386/property-x86-ibt3a.d 2020-04-07 11:32:17.358775810 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/property-x86-ibt3a.d 2020-04-07 13:34:03.907784031 +0100 +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff -rup binutils.orig/ld/testsuite/ld-i386/property-x86-ibt3b.d binutils-2.30/ld/testsuite/ld-i386/property-x86-ibt3b.d +--- binutils.orig/ld/testsuite/ld-i386/property-x86-ibt3b.d 2020-04-07 11:32:17.353775846 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/property-x86-ibt3b.d 2020-04-07 13:34:03.908784024 +0100 +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff -rup binutils.orig/ld/testsuite/ld-i386/property-x86-shstk3a.d binutils-2.30/ld/testsuite/ld-i386/property-x86-shstk3a.d +--- binutils.orig/ld/testsuite/ld-i386/property-x86-shstk3a.d 2020-04-07 11:32:17.355775832 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/property-x86-shstk3a.d 2020-04-07 13:34:03.908784024 +0100 +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff -rup binutils.orig/ld/testsuite/ld-i386/property-x86-shstk3b.d binutils-2.30/ld/testsuite/ld-i386/property-x86-shstk3b.d +--- binutils.orig/ld/testsuite/ld-i386/property-x86-shstk3b.d 2020-04-07 11:32:17.362775781 +0100 ++++ binutils-2.30/ld/testsuite/ld-i386/property-x86-shstk3b.d 2020-04-07 13:34:03.908784024 +0100 +@@ -6,6 +6,5 @@ + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: i486, 586, SSE2, SSE3 +- x86 ISA needed: 586, SSE, SSE3, SSE4_1 ++ GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: 586, SSE, SSE3, SSE4_1 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-1-x32.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-1-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-1-x32.d 2020-04-07 11:32:17.432775271 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-1-x32.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-1.s + #as: --x32 +-#ld: -shared -m elf32_x86_64 --hash-style=sysv ++#ld: -shared -m elf32_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+1c0 <.plt>: +- +[a-f0-9]+: ff 35 62 01 20 00 pushq 0x200162\(%rip\) # 200328 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: ff 25 64 01 20 00 jmpq \*0x200164\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x10> ++[a-f0-9]+ <.plt>: ++ +[a-f0-9]+: ff 35 ([0-9a-f]{2} ){4}[ ]+pushq 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 e2 ff ff ff jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 d2 ff ff ff jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + + Disassembly of section .plt.sec: + +-0+1f0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200338 ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + +-0+200 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 36 01 20 00 jmpq \*0x200136\(%rip\) # 200340 ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+210 : ++[a-f0-9]+ : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 200 ++ +[a-f0-9]+: e8 e7 ff ff ff callq [a-f0-9]+ + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq [a-f0-9]+ + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-1.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-1.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-1.d 2020-04-07 11:32:17.431775279 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-1.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-1.s + #as: --64 -defsym __64_bit__=1 +-#ld: -shared -m elf_x86_64 --hash-style=sysv ++#ld: -shared -m elf_x86_64 --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+290 <.plt>: +- +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10> ++[a-f0-9]+ <.plt>: ++ +[a-f0-9]+: ff 35 ([0-9a-f]{2} ){4}[ ]+pushq 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 00 nopl \(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 90 nop + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 90 nop + + Disassembly of section .plt.sec: + +-0+2c0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + +-0+2d0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+2e0 : ++[a-f0-9]+ : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 ++ +[a-f0-9]+: e8 e7 ff ff ff callq [a-f0-9]+ + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq [a-f0-9]+ + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d 2020-04-07 11:32:17.427775308 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2a-x32.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --x32 +-#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv ++#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+1c0 <.plt>: +- +[a-f0-9]+: ff 35 62 01 20 00 pushq 0x200162\(%rip\) # 200328 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: ff 25 64 01 20 00 jmpq \*0x200164\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x10> ++0+1.0 <.plt>: ++ +[a-f0-9]+: ff 35 4a 01 20 00 pushq 0x20014a\(%rip\) # 200... <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: ff 25 4c 01 20 00 jmpq \*0x20014c\(%rip\) # 200... <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 e2 ff ff ff jmpq 1.0 <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 d2 ff ff ff jmpq 1.0 <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + + Disassembly of section .plt.sec: + +-0+1f0 : ++0+1.0 : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200338 ++ +[a-f0-9]+: ff 25 26 01 20 00 jmpq \*0x200126\(%rip\) # 200... + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + +-0+200 : ++0+1.0 : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 36 01 20 00 jmpq \*0x200136\(%rip\) # 200340 ++ +[a-f0-9]+: ff 25 1e 01 20 00 jmpq \*0x20011e\(%rip\) # 200... + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+210 : ++0+1.0 : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 200 ++ +[a-f0-9]+: e8 e7 ff ff ff callq 1.0 + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq 1.0 + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2a.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2a.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2a.d 2020-04-07 11:32:17.434775257 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2a.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --64 -defsym __64_bit__=1 +-#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv ++#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+290 <.plt>: +- +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10> ++0+..0 <.plt>: ++ +[a-f0-9]+: ff 35 ca 01 20 00 pushq 0x2001ca\(%rip\) # 200... <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: f2 ff 25 cb 01 20 00 bnd jmpq \*0x2001cb\(%rip\) # 200... <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 00 nopl \(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq ..0 <.plt> + +[a-f0-9]+: 90 nop + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq ..0 <.plt> + +[a-f0-9]+: 90 nop + + Disassembly of section .plt.sec: + +-0+2c0 : ++0+..0 : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 ++ +[a-f0-9]+: f2 ff 25 a5 01 20 00 bnd jmpq \*0x2001a5\(%rip\) # 200... + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + +-0+2d0 : ++0+..0 : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 ++ +[a-f0-9]+: f2 ff 25 9d 01 20 00 bnd jmpq \*0x20019d\(%rip\) # 200... + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+2e0 : ++0+..0 : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 ++ +[a-f0-9]+: e8 e7 ff ff ff callq ..0 + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq ..0 + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d 2020-04-07 11:32:17.432775271 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2b-x32.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --x32 +-#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv ++#ld: -shared -m elf32_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #readelf: -n -wf + + Contents of the .eh_frame section: +@@ -18,27 +18,21 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 00000014 0000001c FDE cie=00000000 pc=00000210..00000222 +- DW_CFA_advance_loc: 4 to 00000214 ++0+18 00000014 0000001c FDE cie=00000000 pc=00000..0..00000..2 ++ DW_CFA_advance_loc: 4 to 00000..4 + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 9 to 0000021d ++ DW_CFA_advance_loc: 9 to 00000..d + DW_CFA_def_cfa_offset: 8 + DW_CFA_nop + +-0+30 00000020 00000034 FDE cie=00000000 pc=000001c0..000001f0 ++0+30 00000020 00000034 FDE cie=00000000 pc=00000..0..00000..0 + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 6 to 000001c6 ++ DW_CFA_advance_loc: 6 to 00000..6 + DW_CFA_def_cfa_offset: 24 +- DW_CFA_advance_loc: 10 to 000001d0 ++ DW_CFA_advance_loc: 10 to 00000..0 + DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\) + +-0+54 00000010 00000058 FDE cie=00000000 pc=000001f0..00000210 ++0+54 00000010 00000058 FDE cie=00000000 pc=00000..0..00000..0 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +- +- +-Displaying notes found in: .note.gnu.property +- Owner Data size Description +- GNU 0x0000000c NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 feature: +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2b.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2b.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2b.d 2020-04-07 11:32:17.427775308 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2b.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --64 -defsym __64_bit__=1 +-#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv ++#ld: -shared -m elf_x86_64 -z ibtplt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #readelf: -wf -n + + Contents of the .eh_frame section: +@@ -18,31 +18,25 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000002e0..00000000000002f2 +- DW_CFA_advance_loc: 4 to 00000000000002e4 ++0+18 0000000000000014 0000001c FDE cie=00000000 pc=0000000000000..0..0000000000000..2 ++ DW_CFA_advance_loc: 4 to 0000000000000..4 + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 9 to 00000000000002ed ++ DW_CFA_advance_loc: 9 to 0000000000000..d + DW_CFA_def_cfa_offset: 8 + DW_CFA_nop + +-0+30 0000000000000024 00000034 FDE cie=00000000 pc=0000000000000290..00000000000002c0 ++0+30 0000000000000024 00000034 FDE cie=00000000 pc=0000000000000..0..0000000000000..0 + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 6 to 0000000000000296 ++ DW_CFA_advance_loc: 6 to 0000000000000..6 + DW_CFA_def_cfa_offset: 24 +- DW_CFA_advance_loc: 10 to 00000000000002a0 ++ DW_CFA_advance_loc: 10 to 0000000000000..0 + DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit10; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\) + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +-0+58 0000000000000010 0000005c FDE cie=00000000 pc=00000000000002c0..00000000000002e0 ++0+58 0000000000000010 0000005c FDE cie=00000000 pc=0000000000000..0..0000000000000..0 + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +- +- +-Displaying notes found in: .note.gnu.property +- Owner Data size Description +- GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 feature: +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d 2020-04-07 11:32:17.429775293 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2c-x32.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --x32 +-#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+1c0 <.plt>: +- +[a-f0-9]+: ff 35 62 01 20 00 pushq 0x200162\(%rip\) # 200328 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: ff 25 64 01 20 00 jmpq \*0x200164\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x10> ++[a-f0-9]+ <.plt>: ++ +[a-f0-9]+: ff 35 ([0-9a-f]{2} ){4}[ ]+pushq 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 e2 ff ff ff jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 d2 ff ff ff jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + + Disassembly of section .plt.sec: + +-0+1f0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200338 ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + +-0+200 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 36 01 20 00 jmpq \*0x200136\(%rip\) # 200340 ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+210 : ++[a-f0-9]+ : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 200 ++ +[a-f0-9]+: e8 e7 ff ff ff callq [a-f0-9]+ + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq [a-f0-9]+ + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2c.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2c.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2c.d 2020-04-07 11:32:17.429775293 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2c.d 2020-04-07 13:34:03.908784024 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --64 -defsym __64_bit__=1 +-#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+290 <.plt>: +- +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10> ++[a-f0-9]+ <.plt>: ++ +[a-f0-9]+: ff 35 ([0-9a-f]{2} ){4}[ ]+pushq 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 00 nopl \(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 90 nop + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 90 nop + + Disassembly of section .plt.sec: + +-0+2c0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + +-0+2d0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+2e0 : ++[a-f0-9]+ : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 ++ +[a-f0-9]+: e8 e7 ff ff ff callq [a-f0-9]+ + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq [a-f0-9]+ + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d 2020-04-07 11:32:17.423775337 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2d-x32.d 2020-04-07 13:34:03.909784017 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --x32 +-#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #readelf: -n -wf + + Contents of the .eh_frame section: +@@ -18,21 +18,21 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 00000014 0000001c FDE cie=00000000 pc=00000210..00000222 +- DW_CFA_advance_loc: 4 to 00000214 ++0+18 00000014 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ ++ DW_CFA_advance_loc: 4 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 9 to 0000021d ++ DW_CFA_advance_loc: 9 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 + DW_CFA_nop + +-0+30 00000020 00000034 FDE cie=00000000 pc=000001c0..000001f0 ++0+30 00000020 00000034 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 6 to 000001c6 ++ DW_CFA_advance_loc: 6 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 24 +- DW_CFA_advance_loc: 10 to 000001d0 ++ DW_CFA_advance_loc: 10 to [a-f0-9]+ + DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\) + +-0+54 00000010 00000058 FDE cie=00000000 pc=000001f0..00000210 ++0+54 00000010 00000058 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2d.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2d.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-2d.d 2020-04-07 11:32:17.425775323 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-2d.d 2020-04-07 13:34:03.909784017 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-2.s + #as: --64 -defsym __64_bit__=1 +-#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #readelf: -wf -n + + Contents of the .eh_frame section: +@@ -18,25 +18,25 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000002e0..00000000000002f2 +- DW_CFA_advance_loc: 4 to 00000000000002e4 ++0+18 0000000000000014 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ ++ DW_CFA_advance_loc: 4 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 9 to 00000000000002ed ++ DW_CFA_advance_loc: 9 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 + DW_CFA_nop + +-0+30 0000000000000024 00000034 FDE cie=00000000 pc=0000000000000290..00000000000002c0 ++0+30 0000000000000024 00000034 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 6 to 0000000000000296 ++ DW_CFA_advance_loc: 6 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 24 +- DW_CFA_advance_loc: 10 to 00000000000002a0 ++ DW_CFA_advance_loc: 10 to [a-f0-9]+ + DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit10; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\) + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +-0+58 0000000000000010 0000005c FDE cie=00000000 pc=00000000000002c0..00000000000002e0 ++0+58 0000000000000010 0000005c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +@@ -46,3 +46,4 @@ Displaying notes found in: .note.gnu.pro + Owner Data size Description + GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 + Properties: x86 feature: IBT ++#pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d 2020-04-07 11:32:17.428775301 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3c-x32.d 2020-04-07 13:34:03.909784017 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-3.s + #as: --x32 +-#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+1c0 <.plt>: +- +[a-f0-9]+: ff 35 62 01 20 00 pushq 0x200162\(%rip\) # 200328 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: ff 25 64 01 20 00 jmpq \*0x200164\(%rip\) # 200330 <_GLOBAL_OFFSET_TABLE_\+0x10> ++[a-f0-9]+ <.plt>: ++ +[a-f0-9]+: ff 35 ([0-9a-f]{2} ){4}[ ]+pushq 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 40 00 nopl 0x0\(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: e9 e2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 e2 ff ff ff jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: e9 d2 ff ff ff jmpq 1c0 <.plt> ++ +[a-f0-9]+: e9 d2 ff ff ff jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 66 90 xchg %ax,%ax + + Disassembly of section .plt.sec: + +-0+1f0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 3e 01 20 00 jmpq \*0x20013e\(%rip\) # 200338 ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + +-0+200 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: ff 25 36 01 20 00 jmpq \*0x200136\(%rip\) # 200340 ++ +[a-f0-9]+: ff 25 ([0-9a-f]{2} ){4}[ ]+jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 66 0f 1f 44 00 00 nopw 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+210 : ++[a-f0-9]+ : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 200 ++ +[a-f0-9]+: e8 e7 ff ff ff callq [a-f0-9]+ + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 1f0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq [a-f0-9]+ + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3c.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3c.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3c.d 2020-04-07 11:32:17.435775250 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3c.d 2020-04-07 13:34:03.909784017 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-3.s + #as: --64 -defsym __64_bit__=1 +-#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #objdump: -dw + + .*: +file format .* +@@ -8,36 +8,36 @@ + + Disassembly of section .plt: + +-0+290 <.plt>: +- +[a-f0-9]+: ff 35 ea 01 20 00 pushq 0x2001ea\(%rip\) # 200480 <_GLOBAL_OFFSET_TABLE_\+0x8> +- +[a-f0-9]+: f2 ff 25 eb 01 20 00 bnd jmpq \*0x2001eb\(%rip\) # 200488 <_GLOBAL_OFFSET_TABLE_\+0x10> ++[a-f0-9]+ <.plt>: ++ +[a-f0-9]+: ff 35 ([0-9a-f]{2} ){4}[ ]+pushq 0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x8> ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ <_GLOBAL_OFFSET_TABLE_\+0x10> + +[a-f0-9]+: 0f 1f 00 nopl \(%rax\) + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 00 00 00 00 pushq \$0x0 +- +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 e1 ff ff ff bnd jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 90 nop + +[a-f0-9]+: f3 0f 1e fa endbr64 + +[a-f0-9]+: 68 01 00 00 00 pushq \$0x1 +- +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq 290 <.plt> ++ +[a-f0-9]+: f2 e9 d1 ff ff ff bnd jmpq [a-f0-9]+ <.plt> + +[a-f0-9]+: 90 nop + + Disassembly of section .plt.sec: + +-0+2c0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 c5 01 20 00 bnd jmpq \*0x2001c5\(%rip\) # 200490 ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + +-0+2d0 : ++[a-f0-9]+ : + +[a-f0-9]+: f3 0f 1e fa endbr64 +- +[a-f0-9]+: f2 ff 25 bd 01 20 00 bnd jmpq \*0x2001bd\(%rip\) # 200498 ++ +[a-f0-9]+: f2 ff 25 ([0-9a-f]{2} ){4}[ ]+bnd jmpq \*0x[a-f0-9]+\(%rip\) # [a-f0-9]+ + +[a-f0-9]+: 0f 1f 44 00 00 nopl 0x0\(%rax,%rax,1\) + + Disassembly of section .text: + +-0+2e0 : ++[a-f0-9]+ : + +[a-f0-9]+: 48 83 ec 08 sub \$0x8,%rsp +- +[a-f0-9]+: e8 e7 ff ff ff callq 2d0 ++ +[a-f0-9]+: e8 e7 ff ff ff callq [a-f0-9]+ + +[a-f0-9]+: 48 83 c4 08 add \$0x8,%rsp +- +[a-f0-9]+: e9 ce ff ff ff jmpq 2c0 ++ +[a-f0-9]+: e9 ce ff ff ff jmpq [a-f0-9]+ + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d 2020-04-07 11:32:17.433775264 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3d-x32.d 2020-04-07 13:34:03.909784017 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-3.s + #as: --x32 +-#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf32_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #readelf: -wf -n + + Contents of the .eh_frame section: +@@ -18,21 +18,21 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 00000014 0000001c FDE cie=00000000 pc=00000210..00000222 +- DW_CFA_advance_loc: 4 to 00000214 ++0+18 00000014 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ ++ DW_CFA_advance_loc: 4 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 9 to 0000021d ++ DW_CFA_advance_loc: 9 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 + DW_CFA_nop + +-0+30 00000020 00000034 FDE cie=00000000 pc=000001c0..000001f0 ++0+30 00000020 00000034 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 6 to 000001c6 ++ DW_CFA_advance_loc: 6 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 24 +- DW_CFA_advance_loc: 10 to 000001d0 ++ DW_CFA_advance_loc: 10 to [a-f0-9]+ + DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit9; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\) + +-0+54 00000010 00000058 FDE cie=00000000 pc=000001f0..00000210 ++0+54 00000010 00000058 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +diff -rup binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3d.d binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3d.d +--- binutils.orig/ld/testsuite/ld-x86-64/ibt-plt-3d.d 2020-04-07 11:32:17.438775228 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/ibt-plt-3d.d 2020-04-07 13:34:03.909784017 +0100 +@@ -1,6 +1,6 @@ + #source: ibt-plt-3.s + #as: --64 -defsym __64_bit__=1 +-#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv ++#ld: -shared -m elf_x86_64 -z ibt --hash-style=sysv -z max-page-size=0x200000 -z noseparate-code + #readelf: -wf -n + + Contents of the .eh_frame section: +@@ -18,25 +18,25 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+18 0000000000000014 0000001c FDE cie=00000000 pc=00000000000002e0..00000000000002f2 +- DW_CFA_advance_loc: 4 to 00000000000002e4 ++0+18 0000000000000014 0000001c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ ++ DW_CFA_advance_loc: 4 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 9 to 00000000000002ed ++ DW_CFA_advance_loc: 9 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 8 + DW_CFA_nop + +-0+30 0000000000000024 00000034 FDE cie=00000000 pc=0000000000000290..00000000000002c0 ++0+30 0000000000000024 00000034 FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_def_cfa_offset: 16 +- DW_CFA_advance_loc: 6 to 0000000000000296 ++ DW_CFA_advance_loc: 6 to [a-f0-9]+ + DW_CFA_def_cfa_offset: 24 +- DW_CFA_advance_loc: 10 to 00000000000002a0 ++ DW_CFA_advance_loc: 10 to [a-f0-9]+ + DW_CFA_def_cfa_expression \(DW_OP_breg7 \(rsp\): 8; DW_OP_breg16 \(rip\): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit10; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus\) + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop + +-0+58 0000000000000010 0000005c FDE cie=00000000 pc=00000000000002c0..00000000000002e0 ++0+58 0000000000000010 0000005c FDE cie=00000000 pc=[a-f0-9]+\.\.[a-f0-9]+ + DW_CFA_nop + DW_CFA_nop + DW_CFA_nop +diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr23372a-x32.d binutils-2.30/ld/testsuite/ld-x86-64/pr23372a-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/pr23372a-x32.d 2020-04-07 11:32:17.435775250 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/pr23372a-x32.d 2020-04-07 13:34:03.909784017 +0100 +@@ -3,3 +3,8 @@ + #as: --x32 + #ld: -r -m elf32_x86_64 + #readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA used: +diff -rup binutils.orig/ld/testsuite/ld-x86-64/pr23372a.d binutils-2.30/ld/testsuite/ld-x86-64/pr23372a.d +--- binutils.orig/ld/testsuite/ld-x86-64/pr23372a.d 2020-04-07 11:32:17.439775221 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/pr23372a.d 2020-04-07 13:34:03.909784017 +0100 +@@ -3,3 +3,8 @@ + #as: --64 -defsym __64_bit__=1 + #ld: -r -m elf_x86_64 + #readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++ Owner Data size Description ++ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA used: +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-3.r binutils-2.30/ld/testsuite/ld-x86-64/property-3.r +--- binutils.orig/ld/testsuite/ld-x86-64/property-3.r 2020-04-07 11:32:17.423775337 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-3.r 2020-04-07 13:34:03.909784017 +0100 +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.pro + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA used: 586, SSE + x86 ISA needed: i486, 586 + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-4.r binutils-2.30/ld/testsuite/ld-x86-64/property-4.r +--- binutils.orig/ld/testsuite/ld-x86-64/property-4.r 2020-04-07 11:32:17.427775308 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-4.r 2020-04-07 13:34:03.909784017 +0100 +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.pro + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-5.r binutils-2.30/ld/testsuite/ld-x86-64/property-5.r +--- binutils.orig/ld/testsuite/ld-x86-64/property-5.r 2020-04-07 11:32:17.437775235 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-5.r 2020-04-07 13:34:03.909784017 +0100 +@@ -3,6 +3,5 @@ Displaying notes found in: .note.gnu.pro + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x900000 +- x86 ISA used: i486, 586, SSE + x86 ISA needed: i486, 586, SSE + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d 2020-04-07 11:32:17.429775293 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3a-x32.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-3.s + #source: property-x86-ibt.s +-#as: --x32 ++#as: --x32 -mx86-used-note=yes + #ld: -r -m elf32_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3a.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3a.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3a.d 2020-04-07 11:32:17.431775279 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3a.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-3.s + #source: property-x86-ibt.s +-#as: --64 -defsym __64_bit__=1 ++#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes + #ld: -r -melf_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d 2020-04-07 11:32:17.427775308 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3b-x32.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-ibt.s + #source: property-x86-3.s +-#as: --x32 ++#as: --x32 -mx86-used-note=yes + #ld: -r -m elf32_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3b.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3b.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-ibt3b.d 2020-04-07 11:32:17.423775337 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-ibt3b.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-ibt.s + #source: property-x86-3.s +-#as: --64 -defsym __64_bit__=1 ++#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes + #ld: -r -melf_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d 2020-04-07 11:32:17.425775323 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3a-x32.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-3.s + #source: property-x86-shstk.s +-#as: --x32 ++#as: --x32 -mx86-used-note=yes + #ld: -r -m elf32_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3a.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3a.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3a.d 2020-04-07 11:32:17.427775308 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3a.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-3.s + #source: property-x86-shstk.s +-#as: --64 -defsym __64_bit__=1 ++#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes + #ld: -r -melf_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d 2020-04-07 11:32:17.423775337 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3b-x32.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-shstk.s + #source: property-x86-3.s +-#as: --x32 ++#as: --x32 -mx86-used-note=yes + #ld: -r -m elf32_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000018 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000024 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3b.d binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3b.d +--- binutils.orig/ld/testsuite/ld-x86-64/property-x86-shstk3b.d 2020-04-07 11:32:17.436775242 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-x86-shstk3b.d 2020-04-07 13:34:03.910784010 +0100 +@@ -1,11 +1,12 @@ + #source: property-x86-shstk.s + #source: property-x86-3.s +-#as: --64 -defsym __64_bit__=1 ++#as: --64 -defsym __64_bit__=1 -mx86-used-note=yes + #ld: -r -melf_x86_64 + #readelf: -n + + Displaying notes found in: .note.gnu.property + Owner Data size Description +- GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 +- Properties: x86 ISA used: 586, SSE, SSE3, SSE4_1 +- x86 ISA needed: i486, 586, SSE2, SSE3 ++ GNU 0x00000030 NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA needed: i486, 586, SSE2, SSE3 ++ x86 ISA used: ++ x86 feature used: x86 +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/gas/testsuite/gas/i386/property-1.s 2020-08-20 15:44:27.696983474 +0100 +@@ -0,0 +1,30 @@ ++ .section ".note.gnu.property", "a" ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ .long 1f - 0f /* name length. */ ++ .long 3f - 1f /* data length. */ ++ /* NT_GNU_PROPERTY_TYPE_0 */ ++ .long 5 /* note type. */ ++0: ++ .asciz "GNU" /* vendor name. */ ++1: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ /* GNU_PROPERTY_X86_ISA_1_USED */ ++ .long 0xc0010000 /* pr_type. */ ++ .long 5f - 4f /* pr_datasz. */ ++4: ++ .long 0 ++5: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++3: +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/gas/testsuite/gas/i386/property-1.d 2020-08-20 15:44:27.696983474 +0100 +@@ -0,0 +1,8 @@ ++#name: i386 property 1 ++#as: -mx86-used-note=no --generate-missing-build-notes=no ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++[ ]+Owner[ ]+Data size[ ]+Description ++ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA used: +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/gas/testsuite/gas/i386/property-2.d 2020-08-20 15:44:34.770964195 +0100 +@@ -0,0 +1,9 @@ ++#name: i386 property 2 ++#as: -mx86-used-note=yes --generate-missing-build-notes=no ++#readelf: -n ++ ++Displaying notes found in: .note.gnu.property ++[ ]+Owner[ ]+Data size[ ]+Description ++ GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 ++ Properties: x86 ISA used: CMOV, SSE, SSE2, SSE3, SSSE3, SSE4_1, SSE4_2, AVX, AVX2, FMA, AVX512F, AVX512CD, AVX512ER, AVX512PF, AVX512VL, AVX512DQ, AVX512BW, AVX512_4FMAPS, AVX512_4VNNIW, AVX512_BITALG, AVX512_IFMA, AVX512_VBMI, AVX512_VBMI2, AVX512_VNNI, AVX512_BF16 ++ x86 feature used: x86, x87, MMX, XMM, YMM, ZMM, FXSR, XSAVE, XSAVEOPT, XSAVEC +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/gas/testsuite/gas/i386/property-2.s 2020-08-20 15:44:34.770964195 +0100 +@@ -0,0 +1,32 @@ ++ .text ++ fsin ++ movq %mm0, %mm1 ++ fxsave (%eax) ++ xsave (%eax) ++ xsaveopt (%eax) ++ xsavec (%eax) ++ cmove %eax,%ebx ++ movaps %xmm0, %xmm1 ++ movapd %xmm0, %xmm1 ++ mwait ++ psignb %xmm0, %xmm1 ++ blendvpd %xmm0, %xmm1 ++ pcmpgtq %xmm0, %xmm1 ++ vmovaps %xmm0, %xmm1 ++ vpabsb %ymm0, %ymm1 ++ vfmadd231ps %ymm0, %ymm1, %ymm1 ++ vmovaps %zmm0, %zmm1 ++ vplzcntd %zmm0, %zmm1 ++ vrsqrt28pd %zmm0, %zmm1 ++ vscatterpf0dpd (%eax,%ymm1){%k1} ++ {evex} vpmovzxdq %xmm0, %xmm1 ++ vandnpd %zmm0, %zmm0, %zmm1 ++ vpmaxuw %zmm0, %zmm0, %zmm1 ++ v4fnmaddss (%ecx), %xmm4, %xmm1 ++ vpopcntb %zmm0, %zmm1 ++ vp4dpwssd (%ecx), %zmm0, %zmm1 ++ vpmadd52luq (%ecx), %zmm0, %zmm1 ++ vpermt2b (%ecx), %zmm0, %zmm1 ++ vpcompressb %zmm0, %zmm1 ++ vpdpwssds (%ecx), %zmm0, %zmm1 ++ vcvtne2ps2bf16 (%ecx), %zmm0, %zmm1 +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/pr23900-1-32.rd 2020-08-20 15:46:11.850699543 +0100 +@@ -0,0 +1,14 @@ ++#source: pr23900-1.s ++#ld: ++#readelf: -l --wide ++#target: *-*-linux* *-*-gnu* *-*-nacl* ++ ++#... ++ GNU_PROPERTY .* +0x4 ++#... ++ +[0-9]+ +.*\ \.note\.gnu\.property .* ++#... ++ +[0-9]+ +\.note\.gnu\.property ++#... ++ +[0-9]+ +\.note\.gnu\.property ++#... +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/pr23900-1-64.rd 2020-08-20 15:46:16.968685596 +0100 +@@ -0,0 +1,14 @@ ++#source: pr23900-1.s ++#ld: ++#readelf: -l --wide ++#target: *-*-linux* *-*-gnu* *-*-nacl* ++ ++#... ++ GNU_PROPERTY .* +0x8 ++#... ++ +[0-9]+ +.*\ \.note\.gnu\.property .* ++#... ++ +[0-9]+ +\.note\.gnu\.property ++#... ++ +[0-9]+ +\.note\.gnu\.property ++#... +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/pr23900-1.d 2020-08-20 15:46:26.546659490 +0100 +@@ -0,0 +1,16 @@ ++#ld: ++#readelf: --notes --wide -l ++#target: *-*-linux* *-*-gnu* *-*-nacl* ++ ++#... ++ GNU_PROPERTY .* ++#... ++ +[0-9]+ +.*\.note\.gnu\.property.* ++#... ++ +[0-9]+ +\.note\.gnu\.property ++#... ++ +[0-9]+ +\.note\.gnu\.property ++#... ++Displaying notes found in: \.note\.gnu\.property ++[ ]+Owner[ ]+Data size[ ]+Description ++[ ]+GNU[ ]+0x0+..[ ]+NT_GNU_PROPERTY_TYPE_0[ ]+Properties: no copy on protected +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/pr23900-1.s 2020-08-20 15:46:30.072649878 +0100 +@@ -0,0 +1,30 @@ ++ .text ++ .global start /* Used by SH targets. */ ++start: ++ .global _start ++_start: ++ .global __start ++__start: ++ .global main /* Used by HPPA targets. */ ++main: ++ .globl _main /* Used by LynxOS targets. */ ++_main: ++ .dc.a 0 ++ ++ .section .note.gnu.property, "a" ++ .p2align ALIGN ++ .dc.l .L1 - .L0 /* name length. */ ++ .dc.l .L3 - .L1 /* data length. */ ++ /* NT_GNU_PROPERTY_TYPE_0 */ ++ .dc.l 5 /* note type. */ ++.L0: ++ .asciz "GNU" /* vendor name. */ ++.L1: ++ .p2align ALIGN ++ /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ ++ .dc.l 2 /* pr_type. */ ++ .dc.l .L5 - .L4 /* pr_datasz. */ ++.L4: ++.L5: ++ .p2align ALIGN ++.L3: +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/pr23900-2.s 2020-08-20 15:46:36.328632828 +0100 +@@ -0,0 +1,32 @@ ++ .text ++ .global start /* Used by SH targets. */ ++start: ++ .global _start ++_start: ++ .global __start ++__start: ++ .global main /* Used by HPPA targets. */ ++main: ++ .globl _main /* Used by LynxOS targets. */ ++_main: ++ .dc.a 0 ++ ++ /* NB: Deliberately incorrect section name. Should be ++ .note.gnu.property. */ ++ .section .note, "a" ++ .p2align ALIGN ++ .dc.l .L1 - .L0 /* name length. */ ++ .dc.l .L3 - .L1 /* data length. */ ++ /* NT_GNU_PROPERTY_TYPE_0 */ ++ .dc.l 5 /* note type. */ ++.L0: ++ .asciz "GNU" /* vendor name. */ ++.L1: ++ .p2align ALIGN ++ /* GNU_PROPERTY_NO_COPY_ON_PROTECTED */ ++ .dc.l 2 /* pr_type. */ ++ .dc.l .L5 - .L4 /* pr_datasz. */ ++.L4: ++.L5: ++ .p2align ALIGN ++.L3: +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/pr23900-2a.d 2020-08-20 15:46:42.642615623 +0100 +@@ -0,0 +1,9 @@ ++#source: pr23900-2.s ++#ld: ++#readelf: --notes --wide ++#target: *-*-linux* *-*-gnu* *-*-nacl* ++ ++#... ++Displaying notes found in: \.note ++[ ]+Owner[ ]+Data size[ ]+Description ++[ ]+GNU[ ]+0x0+..[ ]+NT_GNU_PROPERTY_TYPE_0[ ]+Properties: no copy on protected +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/pr23900-2b.d 2020-08-20 15:46:48.738599006 +0100 +@@ -0,0 +1,9 @@ ++#source: pr23900-2.s ++#ld: ++#readelf: -l --wide ++#target: *-*-linux* *-*-gnu* *-*-nacl* ++ ++#failif ++#... ++ GNU_PROPERTY .* ++#... +--- /dev/null 2020-08-20 07:54:24.260993139 +0100 ++++ binutils-2.30/ld/testsuite/ld-elf/stack-noexec.rd 2020-08-20 15:46:59.907568567 +0100 +@@ -0,0 +1,3 @@ ++#... ++ GNU_STACK 0x0+00000 0x0+000000 0x0+000000 0x0+000 0x.+0000 RW 0x[0-9a-f]+ ++#pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-3.r binutils-2.30/ld/testsuite/ld-x86-64/property-3.r +--- binutils.orig/ld/testsuite/ld-x86-64/property-3.r 2020-08-21 10:21:01.138676431 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-3.r 2020-08-21 10:47:30.373599165 +0100 +@@ -3,5 +3,5 @@ Displaying notes found in: .note.gnu.pro + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA needed: i486, 586 ++ x86 ISA needed: i486, 58.* + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-4.r binutils-2.30/ld/testsuite/ld-x86-64/property-4.r +--- binutils.orig/ld/testsuite/ld-x86-64/property-4.r 2020-08-21 10:21:01.122676481 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-4.r 2020-08-21 10:49:39.940182100 +0100 +@@ -3,5 +3,5 @@ Displaying notes found in: .note.gnu.pro + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x800000 +- x86 ISA needed: i486, 586, SSE ++ x86 ISA needed: i486, 586, SS.* + #pass +diff -rup binutils.orig/ld/testsuite/ld-x86-64/property-5.r binutils-2.30/ld/testsuite/ld-x86-64/property-5.r +--- binutils.orig/ld/testsuite/ld-x86-64/property-5.r 2020-08-21 10:21:01.127676465 +0100 ++++ binutils-2.30/ld/testsuite/ld-x86-64/property-5.r 2020-08-21 10:50:06.198097582 +0100 +@@ -3,5 +3,5 @@ Displaying notes found in: .note.gnu.pro + Owner Data size Description + GNU 0x[0-9a-f]+ NT_GNU_PROPERTY_TYPE_0 + Properties: stack size: 0x900000 +- x86 ISA needed: i486, 586, SSE ++ x86 ISA needed: i486, 586, SS.* + #pass diff --git a/SOURCES/binutils-PowerPC-IEEE-long-double-warnings.patch b/SOURCES/binutils-PowerPC-IEEE-long-double-warnings.patch new file mode 100644 index 0000000..2c3d8d3 --- /dev/null +++ b/SOURCES/binutils-PowerPC-IEEE-long-double-warnings.patch @@ -0,0 +1,17 @@ +--- binutils.orig/bfd/elf32-ppc.c 2018-06-12 17:35:40.931551297 +0100 ++++ binutils-2.30/bfd/elf32-ppc.c 2018-06-12 17:37:22.252441292 +0100 +@@ -4677,12 +4677,12 @@ _bfd_elf_ppc_merge_fp_attributes (bfd *i + _bfd_error_handler + /* xgettext:c-format */ + (_("Warning: %B uses IBM long double, " +- "%B uses IEEE long double"), ibfd, obfd); ++ "%B uses IEEE long double"), obfd, ibfd); + else if (out_fp == 3 * 4 && in_fp == 1 * 4) + _bfd_error_handler + /* xgettext:c-format */ + (_("Warning: %B uses IBM long double, " +- "%B uses IEEE long double"), obfd, ibfd); ++ "%B uses IEEE long double"), ibfd, obfd); + } + } + diff --git a/SOURCES/binutils-aarch64-STO_AARCH64_VARIANT_PCS.patch b/SOURCES/binutils-aarch64-STO_AARCH64_VARIANT_PCS.patch new file mode 100644 index 0000000..89f4468 --- /dev/null +++ b/SOURCES/binutils-aarch64-STO_AARCH64_VARIANT_PCS.patch @@ -0,0 +1,855 @@ +diff -rup binutils.orig/bfd/elfnn-aarch64.c binutils-2.32/bfd/elfnn-aarch64.c +--- binutils.orig/bfd/elfnn-aarch64.c 2019-07-02 17:30:19.407892712 +0100 ++++ binutils-2.32/bfd/elfnn-aarch64.c 2019-07-02 17:35:21.874749884 +0100 +@@ -2579,6 +2579,9 @@ struct elf_aarch64_link_hash_table + unsigned int top_index; + asection **input_list; + ++ /* JUMP_SLOT relocs for variant PCS symbols may be present. */ ++ int variant_pcs; ++ + /* The offset into splt of the PLT entry for the TLS descriptor + resolver. Special values are 0, if not necessary (or not found + to be necessary yet), and -1 if needed but not determined +@@ -2790,6 +2793,31 @@ elfNN_aarch64_copy_indirect_symbol (stru + _bfd_elf_link_hash_copy_indirect (info, dir, ind); + } + ++/* Merge non-visibility st_other attributes. */ ++ ++static void ++elfNN_aarch64_merge_symbol_attribute (struct elf_link_hash_entry *h, ++ const Elf_Internal_Sym *isym, ++ bfd_boolean definition ATTRIBUTE_UNUSED, ++ bfd_boolean dynamic ATTRIBUTE_UNUSED) ++{ ++ unsigned int isym_sto = isym->st_other & ~ELF_ST_VISIBILITY (-1); ++ unsigned int h_sto = h->other & ~ELF_ST_VISIBILITY (-1); ++ ++ if (isym_sto == h_sto) ++ return; ++ ++ if (isym_sto & ~STO_AARCH64_VARIANT_PCS) ++ /* Not fatal, this callback cannot fail. */ ++ _bfd_error_handler (_("unknown attribute for symbol `%s': 0x%02x"), ++ h->root.root.string, isym_sto); ++ ++ /* Note: Ideally we would warn about any attribute mismatch, but ++ this api does not allow that without substantial changes. */ ++ if (isym_sto & STO_AARCH64_VARIANT_PCS) ++ h->other |= STO_AARCH64_VARIANT_PCS; ++} ++ + /* Destroy an AArch64 elf linker hash table. */ + + static void +@@ -8370,6 +8398,12 @@ elfNN_aarch64_allocate_dynrelocs (struct + updated. */ + + htab->root.srelplt->reloc_count++; ++ ++ /* Mark the DSO in case R__JUMP_SLOT relocs against ++ variant PCS symbols are present. */ ++ if (h->other & STO_AARCH64_VARIANT_PCS) ++ htab->variant_pcs = 1; ++ + } + else + { +@@ -8958,6 +8992,10 @@ elfNN_aarch64_size_dynamic_sections (bfd + || !add_dynamic_entry (DT_JMPREL, 0)) + return FALSE; + ++ if (htab->variant_pcs ++ && !add_dynamic_entry (DT_AARCH64_VARIANT_PCS, 0)) ++ return FALSE; ++ + if (htab->tlsdesc_plt + && (!add_dynamic_entry (DT_TLSDESC_PLT, 0) + || !add_dynamic_entry (DT_TLSDESC_GOT, 0))) +@@ -9708,6 +9746,9 @@ const struct elf_size_info elfNN_aarch64 + #define elf_backend_copy_indirect_symbol \ + elfNN_aarch64_copy_indirect_symbol + ++#define elf_backend_merge_symbol_attribute \ ++ elfNN_aarch64_merge_symbol_attribute ++ + /* Create .dynbss, and .rela.bss sections in DYNOBJ, and set up shortcuts + to them in our hash. */ + #define elf_backend_create_dynamic_sections \ +diff -rup binutils.orig/binutils/readelf.c binutils-2.32/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2019-07-02 17:30:18.890896375 +0100 ++++ binutils-2.32/binutils/readelf.c 2019-07-02 17:32:25.008002901 +0100 +@@ -1797,6 +1797,19 @@ dump_relocations (Filedata * fi + } + + static const char * ++get_aarch64_dynamic_type (unsigned long type) ++{ ++ switch (type) ++ { ++ case DT_AARCH64_BTI_PLT: return "AARCH64_BTI_PLT"; ++ case DT_AARCH64_PAC_PLT: return "AARCH64_PAC_PLT"; ++ case DT_AARCH64_VARIANT_PCS: return "AARCH64_VARIANT_PCS"; ++ default: ++ return NULL; ++ } ++} ++ ++static const char * + get_mips_dynamic_type (unsigned long type) + { + switch (type) +@@ -2169,6 +2182,9 @@ get_dynamic_type (Filedata * filedata, u + + switch (filedata->file_header.e_machine) + { ++ case EM_AARCH64: ++ result = get_aarch64_dynamic_type (type); ++ break; + case EM_MIPS: + case EM_MIPS_RS3_LE: + result = get_mips_dynamic_type (type); +@@ -11054,6 +11070,22 @@ get_solaris_symbol_visibility (unsigned + } + + static const char * ++get_aarch64_symbol_other (unsigned int other) ++{ ++ static char buf[32]; ++ ++ if (other & STO_AARCH64_VARIANT_PCS) ++ { ++ other &= ~STO_AARCH64_VARIANT_PCS; ++ if (other == 0) ++ return "VARIANT_PCS"; ++ snprintf (buf, sizeof buf, "VARIANT_PCS | %x", other); ++ return buf; ++ } ++ return NULL; ++} ++ ++static const char * + get_mips_symbol_other (unsigned int other) + { + switch (other) +@@ -11164,6 +11196,9 @@ get_symbol_other (Filedata * filedata, u + + switch (filedata->file_header.e_machine) + { ++ case EM_AARCH64: ++ result = get_aarch64_symbol_other (other); ++ break; + case EM_MIPS: + result = get_mips_symbol_other (other); + break; +diff -rup binutils.orig/gas/config/tc-aarch64.c binutils-2.32/gas/config/tc-aarch64.c +--- binutils.orig/gas/config/tc-aarch64.c 2019-07-02 17:30:19.131894667 +0100 ++++ binutils-2.32/gas/config/tc-aarch64.c 2019-07-02 17:35:45.202584620 +0100 +@@ -1938,6 +1938,28 @@ s_aarch64_elf_cons (int nbytes) + demand_empty_rest_of_line (); + } + ++/* Mark symbol that it follows a variant PCS convention. */ ++ ++static void ++s_variant_pcs (int ignored ATTRIBUTE_UNUSED) ++{ ++ char *name; ++ char c; ++ symbolS *sym; ++ asymbol *bfdsym; ++ elf_symbol_type *elfsym; ++ ++ c = get_symbol_name (&name); ++ if (!*name) ++ as_bad (_("Missing symbol name in directive")); ++ sym = symbol_find_or_make (name); ++ restore_line_pointer (c); ++ demand_empty_rest_of_line (); ++ bfdsym = symbol_get_bfdsym (sym); ++ elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym); ++ gas_assert (elfsym); ++ elfsym->internal_elf_sym.st_other |= STO_AARCH64_VARIANT_PCS; ++} + #endif /* OBJ_ELF */ + + /* Output a 32-bit word, but mark as an instruction. */ +@@ -2084,6 +2106,7 @@ const pseudo_typeS md_pseudo_table[] = { + {"long", s_aarch64_elf_cons, 4}, + {"xword", s_aarch64_elf_cons, 8}, + {"dword", s_aarch64_elf_cons, 8}, ++ {"variant_pcs", s_variant_pcs, 0}, + #endif + {0, 0, 0} + }; +@@ -9320,3 +9343,35 @@ aarch64_copy_symbol_attributes (symbolS + { + AARCH64_GET_FLAG (dest) = AARCH64_GET_FLAG (src); + } ++ ++#ifdef OBJ_ELF ++/* Same as elf_copy_symbol_attributes, but without copying st_other. ++ This is needed so AArch64 specific st_other values can be independently ++ specified for an IFUNC resolver (that is called by the dynamic linker) ++ and the symbol it resolves (aliased to the resolver). In particular, ++ if a function symbol has special st_other value set via directives, ++ then attaching an IFUNC resolver to that symbol should not override ++ the st_other setting. Requiring the directive on the IFUNC resolver ++ symbol would be unexpected and problematic in C code, where the two ++ symbols appear as two independent function declarations. */ ++ ++void ++aarch64_elf_copy_symbol_attributes (symbolS *dest, symbolS *src) ++{ ++ struct elf_obj_sy *srcelf = symbol_get_obj (src); ++ struct elf_obj_sy *destelf = symbol_get_obj (dest); ++ if (srcelf->size) ++ { ++ if (destelf->size == NULL) ++ destelf->size = XNEW (expressionS); ++ *destelf->size = *srcelf->size; ++ } ++ else ++ { ++ if (destelf->size != NULL) ++ free (destelf->size); ++ destelf->size = NULL; ++ } ++ S_SET_SIZE (dest, S_GET_SIZE (src)); ++} ++#endif +diff -rup binutils.orig/gas/config/tc-aarch64.h binutils-2.32/gas/config/tc-aarch64.h +--- binutils.orig/gas/config/tc-aarch64.h 2019-07-02 17:30:19.136894632 +0100 ++++ binutils-2.32/gas/config/tc-aarch64.h 2019-07-02 17:35:45.202584620 +0100 +@@ -130,6 +130,12 @@ void aarch64_copy_symbol_attributes (sym + (aarch64_copy_symbol_attributes (DEST, SRC)) + #endif + ++#ifdef OBJ_ELF ++void aarch64_elf_copy_symbol_attributes (symbolS *, symbolS *); ++#define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \ ++ aarch64_elf_copy_symbol_attributes (DEST, SRC) ++#endif ++ + #define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) \ + (NEXT_CHAR == ':' || (NEXT_CHAR == '/' && aarch64_data_in_code ())) + #define tc_canonicalize_symbol_name(str) aarch64_canonicalize_symbol_name (str); +diff -rup binutils.orig/gas/doc/c-aarch64.texi binutils-2.32/gas/doc/c-aarch64.texi +--- binutils.orig/gas/doc/c-aarch64.texi 2019-07-02 17:30:19.125894710 +0100 ++++ binutils-2.32/gas/doc/c-aarch64.texi 2019-07-02 17:35:11.362824354 +0100 +@@ -425,6 +425,12 @@ should only be done if it is really nece + + @c VVVVVVVVVVVVVVVVVVVVVVVVVV + ++@cindex @code{.variant_pcs} directive, AArch64 ++@item .variant_pcs @var{symbol} ++This directive marks @var{symbol} referencing a function that may ++follow a variant procedure call standard with different register ++usage convention from the base procedure call standard. ++ + @c WWWWWWWWWWWWWWWWWWWWWWWWWW + @c XXXXXXXXXXXXXXXXXXXXXXXXXX + +diff -rup binutils.orig/include/elf/aarch64.h binutils-2.32/include/elf/aarch64.h +--- binutils.orig/include/elf/aarch64.h 2019-07-02 17:30:18.850896658 +0100 ++++ binutils-2.32/include/elf/aarch64.h 2019-07-02 17:32:55.678785616 +0100 +@@ -36,6 +36,15 @@ + #define SHF_COMDEF 0x80000000 /* Section may be multiply defined + in the input to a link step. */ + ++/* Processor specific dynamic array tags. */ ++#define DT_AARCH64_BTI_PLT (DT_LOPROC + 1) ++#define DT_AARCH64_PAC_PLT (DT_LOPROC + 3) ++#define DT_AARCH64_VARIANT_PCS (DT_LOPROC + 5) ++ ++/* AArch64-specific values for st_other. */ ++#define STO_AARCH64_VARIANT_PCS 0x80 /* Symbol may follow different call ++ convention from the base PCS. */ ++ + /* Relocation types. */ + + START_RELOC_NUMBERS (elf_aarch64_reloc_type) +diff -rup binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp binutils-2.32/ld/testsuite/ld-aarch64/aarch64-elf.exp +--- binutils.orig/ld/testsuite/ld-aarch64/aarch64-elf.exp 2019-07-02 17:30:18.922896148 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/aarch64-elf.exp 2019-07-02 17:35:21.875749878 +0100 +@@ -371,6 +371,10 @@ run_dump_test_lp64 "rela-abs-relative-op + + run_dump_test_lp64 "pie-bind-locally" + ++run_dump_test_lp64 "variant_pcs-r" ++run_dump_test_lp64 "variant_pcs-shared" ++run_dump_test_lp64 "variant_pcs-now" ++ + set aarch64elflinktests { + {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s} + {} "copy-reloc-so.so"} +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.d 2019-07-02 17:35:11.362824354 +0100 +@@ -0,0 +1,10 @@ ++#objdump: -t ++ ++.*: file format .* ++ ++SYMBOL TABLE: ++0+ l d \.text 0+ \.text ++0+ l d \.data 0+ \.data ++0+ l d \.bss 0+ \.bss ++0+ l \.text 0+ func ++0+ \*UND\* 0+ 0x80 foobar +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.s 2019-07-02 17:35:11.362824354 +0100 +@@ -0,0 +1,8 @@ ++.text ++.variant_pcs foobar ++func: ++ bl foobar ++ b foobar ++ ++.data ++.xword foobar +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.d 2019-07-02 17:35:11.362824354 +0100 +@@ -0,0 +1,9 @@ ++#objdump: -t ++ ++.*: file format .* ++ ++SYMBOL TABLE: ++0+ l d \.text 0+ \.text ++0+ l d \.data 0+ \.data ++0+ l d \.bss 0+ \.bss ++0+ l \.text 0+ 0x80 foo +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.s 2019-07-02 17:35:11.362824354 +0100 +@@ -0,0 +1,4 @@ ++.text ++.variant_pcs foo ++foo: ++ ret +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.s 2019-07-02 17:35:45.202584620 +0100 +@@ -0,0 +1,20 @@ ++.text ++.global foo_vpcs ++.global foo_base ++.global alias_vpcs ++.global alias_base ++ ++.variant_pcs foo_vpcs ++.variant_pcs alias_vpcs ++ ++foo_vpcs: ++foo_base: ++ bl foo_vpcs ++ bl foo_base ++ bl alias_vpcs ++ bl alias_base ++ ++/* Check that the STO_AARCH64_VARIANT_PCS is not affected by .set. */ ++ ++.set alias_base, foo_vpcs ++.set alias_vpcs, foo_base +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.d 2019-07-02 17:35:45.202584620 +0100 +@@ -0,0 +1,12 @@ ++#objdump: -t ++ ++.*: file format .* ++ ++SYMBOL TABLE: ++0+ l d \.text 0+ \.text ++0+ l d \.data 0+ \.data ++0+ l d \.bss 0+ \.bss ++0+ g \.text 0+ 0x80 foo_vpcs ++0+ g \.text 0+ foo_base ++0+ g \.text 0+ 0x80 alias_vpcs ++0+ g \.text 0+ alias_base +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-1.s 2019-07-02 17:35:21.875749878 +0100 +@@ -0,0 +1,59 @@ ++.text ++ ++.variant_pcs f_spec_global_default_def ++.variant_pcs f_spec_global_default_undef ++.variant_pcs f_spec_global_hidden_def ++.variant_pcs f_spec_local ++.variant_pcs f_spec_global_default_ifunc ++.variant_pcs f_spec_global_hidden_ifunc ++.variant_pcs f_spec_local_ifunc ++ ++.global f_spec_global_default_def ++.global f_spec_global_default_undef ++.global f_spec_global_hidden_def ++.global f_spec_global_default_ifunc ++.global f_spec_global_hidden_ifunc ++.global f_base_global_default_def ++.global f_base_global_default_undef ++.global f_base_global_hidden_def ++.global f_base_global_default_ifunc ++.global f_base_global_hidden_ifunc ++ ++.hidden f_spec_global_hidden_def ++.hidden f_spec_global_hidden_ifunc ++.hidden f_base_global_hidden_def ++.hidden f_base_global_hidden_ifunc ++ ++.type f_spec_global_default_ifunc, %gnu_indirect_function ++.type f_spec_global_hidden_ifunc, %gnu_indirect_function ++.type f_spec_local_ifunc, %gnu_indirect_function ++.type f_base_global_default_ifunc, %gnu_indirect_function ++.type f_base_global_hidden_ifunc, %gnu_indirect_function ++.type f_base_local_ifunc, %gnu_indirect_function ++ ++f_spec_global_default_def: ++f_spec_global_hidden_def: ++f_spec_local: ++f_base_global_default_def: ++f_base_global_hidden_def: ++f_base_local: ++f_spec_global_default_ifunc: ++f_spec_global_hidden_ifunc: ++f_spec_local_ifunc: ++f_base_global_default_ifunc: ++f_base_global_hidden_ifunc: ++f_base_local_ifunc: ++ bl f_spec_global_default_def ++ bl f_spec_global_default_undef ++ bl f_spec_global_hidden_def ++ bl f_spec_local ++ bl f_base_global_default_def ++ bl f_base_global_default_undef ++ bl f_base_global_hidden_def ++ bl f_base_local ++ bl f_spec_global_default_ifunc ++ bl f_spec_global_hidden_ifunc ++ bl f_spec_local_ifunc ++ bl f_base_global_default_ifunc ++ bl f_base_global_hidden_ifunc ++ bl f_base_local_ifunc +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-2.s 2019-07-02 17:35:21.875749878 +0100 +@@ -0,0 +1,47 @@ ++.text ++ ++.variant_pcs f_spec_global_default_def ++.variant_pcs f_spec_global_default_undef ++.variant_pcs f_spec_global_hidden_def ++.variant_pcs f_spec_local2 ++.variant_pcs f_spec_global_default_ifunc ++.variant_pcs f_spec_global_hidden_ifunc ++.variant_pcs f_spec_local2_ifunc ++ ++.global f_spec_global_default_def ++.global f_spec_global_default_undef ++.global f_spec_global_hidden_def ++.global f_spec_global_default_ifunc ++.global f_spec_global_hidden_ifunc ++.global f_base_global_default_def ++.global f_base_global_default_undef ++.global f_base_global_hidden_def ++.global f_base_global_default_ifunc ++.global f_base_global_hidden_ifunc ++ ++.hidden f_spec_global_hidden_def ++.hidden f_spec_global_hidden_ifunc ++.hidden f_base_global_hidden_def ++.hidden f_base_global_hidden_ifunc ++ ++.type f_spec_local2_ifunc, %gnu_indirect_function ++.type f_base_local2_ifunc, %gnu_indirect_function ++ ++f_spec_local2: ++f_base_local2: ++f_spec_local2_ifunc: ++f_base_local2_ifunc: ++ bl f_spec_global_default_def ++ bl f_spec_global_default_undef ++ bl f_spec_global_hidden_def ++ bl f_spec_local2 ++ bl f_base_global_default_def ++ bl f_base_global_default_undef ++ bl f_base_global_hidden_def ++ bl f_base_local2 ++ bl f_spec_global_default_ifunc ++ bl f_spec_global_hidden_ifunc ++ bl f_spec_local2_ifunc ++ bl f_base_global_default_ifunc ++ bl f_base_global_hidden_ifunc ++ bl f_base_local2_ifunc +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs.ld 2019-07-02 17:35:37.100642017 +0100 +@@ -0,0 +1,23 @@ ++/* Script for .variant_pcs symbol tests. */ ++OUTPUT_ARCH(aarch64) ++ENTRY(_start) ++SECTIONS ++{ ++ /* Read-only sections, merged into text segment: */ ++ PROVIDE (__executable_start = 0x8000); . = 0x8000; ++ .text : ++ { ++ *(.before) ++ *(.text) ++ *(.after) ++ } =0 ++ . = 0x9000; ++ .got : { *(.got) *(.got.plt)} ++ . = 0x10000; ++ .rela.dyn : { *(.rela.ifunc) } ++ . = 0x11000; ++ .rela.plt : { *(.rela.plt) *(.rela.iplt) } ++ . = 0x12340000; ++ .far : { *(.far) } ++ .ARM.attributes 0 : { *(.ARM.atttributes) } ++} +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-now.d 2019-07-02 17:34:37.557063849 +0100 +@@ -0,0 +1,67 @@ ++#source: variant_pcs-1.s ++#source: variant_pcs-2.s ++#ld: -shared --hash-style=sysv -T variant_pcs.ld -z now ++#readelf: -rsW ++ ++Relocation section '\.rela\.plt' at offset 0x11000 contains 12 entries: ++ Offset Info Type Symbol's Value Symbol's Name \+ Addend ++0000000000009020 0000000100000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_base_global_default_undef \+ 0 ++0000000000009028 0000000200000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_spec_global_default_undef \+ 0 ++0000000000009030 0000000400000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_base_global_default_def \+ 0 ++0000000000009038 0000000500000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_spec_global_default_def \+ 0 ++0000000000009040 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009048 0000000300000402 R_AARCH64_JUMP_SLOT f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0 ++0000000000009050 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009058 0000000600000402 R_AARCH64_JUMP_SLOT f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0 ++0000000000009060 0000000000000408 R_AARCH64_IRELATIVE 8038 ++0000000000009068 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009070 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009078 0000000000000408 R_AARCH64_IRELATIVE 8038 ++ ++Symbol table '\.dynsym' contains 7 entries: ++ Num: Value Size Type Bind Vis Ndx Name ++ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND ++ 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef ++ 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef ++ 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 4: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def ++ 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 6: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc ++ ++Symbol table '\.symtab' contains 35 entries: ++ Num: Value Size Type Bind Vis Ndx Name ++ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND ++ 1: 0000000000008000 0 SECTION LOCAL DEFAULT 1 ++ 2: 0000000000008070 0 SECTION LOCAL DEFAULT 2 ++ 3: 0000000000009000 0 SECTION LOCAL DEFAULT 3 ++ 4: 0000000000009080 0 SECTION LOCAL DEFAULT 4 ++ 5: 0000000000011000 0 SECTION LOCAL DEFAULT 5 ++ 6: 0000000000011120 0 SECTION LOCAL DEFAULT 6 ++ 7: 00000000000111c8 0 SECTION LOCAL DEFAULT 7 ++ 8: 0000000000011270 0 SECTION LOCAL DEFAULT 8 ++ 9: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o ++ 10: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local ++ 11: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local_ifunc ++ 12: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_local_ifunc ++ 13: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_local ++ 14: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 \$x ++ 15: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-2\.o ++ 16: 0000000000008038 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2 ++ 17: 0000000000008038 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2_ifunc ++ 18: 0000000000008038 0 IFUNC LOCAL DEFAULT 1 f_base_local2_ifunc ++ 19: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 f_base_local2 ++ 20: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 \$x ++ 21: 0000000000000000 0 FILE LOCAL DEFAULT ABS ++ 22: 0000000000009080 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC ++ 23: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_def ++ 24: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_global_hidden_ifunc ++ 25: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_global_hidden_def ++ 26: 0000000000009000 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ ++ 27: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_ifunc ++ 28: 0000000000008070 0 NOTYPE LOCAL DEFAULT 2 \$x ++ 29: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef ++ 30: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef ++ 31: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 32: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def ++ 33: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 34: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-r.d 2019-07-02 17:35:35.244655166 +0100 +@@ -0,0 +1,60 @@ ++#source: variant_pcs-1.s ++#source: variant_pcs-2.s ++#ld: -r ++#readelf: -rsW ++ ++Relocation section '\.rela\.text' at offset .* contains 24 entries: ++ Offset Info Type Symbol's Value Symbol's Name \+ Addend ++0000000000000000 000000180000011b R_AARCH64_CALL26 0000000000000000 f_spec_global_default_def \+ 0 ++0000000000000004 000000110000011b R_AARCH64_CALL26 0000000000000000 f_spec_global_default_undef \+ 0 ++0000000000000008 000000120000011b R_AARCH64_CALL26 0000000000000000 f_spec_global_hidden_def \+ 0 ++0000000000000010 000000170000011b R_AARCH64_CALL26 0000000000000000 f_base_global_default_def \+ 0 ++0000000000000014 000000100000011b R_AARCH64_CALL26 0000000000000000 f_base_global_default_undef \+ 0 ++0000000000000018 000000150000011b R_AARCH64_CALL26 0000000000000000 f_base_global_hidden_def \+ 0 ++0000000000000020 000000140000011b R_AARCH64_CALL26 f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0 ++0000000000000024 000000160000011b R_AARCH64_CALL26 f_spec_global_hidden_ifunc\(\) f_spec_global_hidden_ifunc \+ 0 ++0000000000000028 000000060000011b R_AARCH64_CALL26 f_spec_local_ifunc\(\) f_spec_local_ifunc \+ 0 ++000000000000002c 000000190000011b R_AARCH64_CALL26 f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0 ++0000000000000030 000000130000011b R_AARCH64_CALL26 f_base_global_hidden_ifunc\(\) f_base_global_hidden_ifunc \+ 0 ++0000000000000034 000000070000011b R_AARCH64_CALL26 f_base_local_ifunc\(\) f_base_local_ifunc \+ 0 ++0000000000000038 000000180000011b R_AARCH64_CALL26 0000000000000000 f_spec_global_default_def \+ 0 ++000000000000003c 000000110000011b R_AARCH64_CALL26 0000000000000000 f_spec_global_default_undef \+ 0 ++0000000000000040 000000120000011b R_AARCH64_CALL26 0000000000000000 f_spec_global_hidden_def \+ 0 ++0000000000000048 000000170000011b R_AARCH64_CALL26 0000000000000000 f_base_global_default_def \+ 0 ++000000000000004c 000000100000011b R_AARCH64_CALL26 0000000000000000 f_base_global_default_undef \+ 0 ++0000000000000050 000000150000011b R_AARCH64_CALL26 0000000000000000 f_base_global_hidden_def \+ 0 ++0000000000000058 000000140000011b R_AARCH64_CALL26 f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0 ++000000000000005c 000000160000011b R_AARCH64_CALL26 f_spec_global_hidden_ifunc\(\) f_spec_global_hidden_ifunc \+ 0 ++0000000000000060 0000000c0000011b R_AARCH64_CALL26 f_spec_local2_ifunc\(\) f_spec_local2_ifunc \+ 0 ++0000000000000064 000000190000011b R_AARCH64_CALL26 f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0 ++0000000000000068 000000130000011b R_AARCH64_CALL26 f_base_global_hidden_ifunc\(\) f_base_global_hidden_ifunc \+ 0 ++000000000000006c 0000000d0000011b R_AARCH64_CALL26 f_base_local2_ifunc\(\) f_base_local2_ifunc \+ 0 ++ ++Symbol table '\.symtab' contains 26 entries: ++ Num: Value Size Type Bind Vis Ndx Name ++ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND ++ 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 ++ 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 ++ 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 ++ 4: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o ++ 5: 0000000000000000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local ++ 6: 0000000000000000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local_ifunc ++ 7: 0000000000000000 0 IFUNC LOCAL DEFAULT 1 f_base_local_ifunc ++ 8: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 f_base_local ++ 9: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 \$x ++ 10: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-2\.o ++ 11: 0000000000000038 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2 ++ 12: 0000000000000038 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2_ifunc ++ 13: 0000000000000038 0 IFUNC LOCAL DEFAULT 1 f_base_local2_ifunc ++ 14: 0000000000000038 0 NOTYPE LOCAL DEFAULT 1 f_base_local2 ++ 15: 0000000000000038 0 NOTYPE LOCAL DEFAULT 1 \$x ++ 16: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef ++ 17: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef ++ 18: 0000000000000000 0 NOTYPE GLOBAL HIDDEN \[VARIANT_PCS\] 1 f_spec_global_hidden_def ++ 19: 0000000000000000 0 IFUNC GLOBAL HIDDEN 1 f_base_global_hidden_ifunc ++ 20: 0000000000000000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 21: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 f_base_global_hidden_def ++ 22: 0000000000000000 0 IFUNC GLOBAL HIDDEN \[VARIANT_PCS\] 1 f_spec_global_hidden_ifunc ++ 23: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def ++ 24: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 25: 0000000000000000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc +--- /dev/null 2019-07-02 08:01:33.386842704 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-shared.d 2019-07-02 17:34:45.635006622 +0100 +@@ -0,0 +1,67 @@ ++#source: variant_pcs-1.s ++#source: variant_pcs-2.s ++#ld: -shared --hash-style=sysv -T variant_pcs.ld ++#readelf: -rsW ++ ++Relocation section '\.rela\.plt' at offset 0x11000 contains 12 entries: ++ Offset Info Type Symbol's Value Symbol's Name \+ Addend ++0000000000009020 0000000100000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_base_global_default_undef \+ 0 ++0000000000009028 0000000200000402 R_AARCH64_JUMP_SLOT 0000000000000000 f_spec_global_default_undef \+ 0 ++0000000000009030 0000000400000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_base_global_default_def \+ 0 ++0000000000009038 0000000500000402 R_AARCH64_JUMP_SLOT 0000000000008000 f_spec_global_default_def \+ 0 ++0000000000009040 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009048 0000000300000402 R_AARCH64_JUMP_SLOT f_spec_global_default_ifunc\(\) f_spec_global_default_ifunc \+ 0 ++0000000000009050 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009058 0000000600000402 R_AARCH64_JUMP_SLOT f_base_global_default_ifunc\(\) f_base_global_default_ifunc \+ 0 ++0000000000009060 0000000000000408 R_AARCH64_IRELATIVE 8038 ++0000000000009068 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009070 0000000000000408 R_AARCH64_IRELATIVE 8000 ++0000000000009078 0000000000000408 R_AARCH64_IRELATIVE 8038 ++ ++Symbol table '\.dynsym' contains 7 entries: ++ Num: Value Size Type Bind Vis Ndx Name ++ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND ++ 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef ++ 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef ++ 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 4: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def ++ 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 6: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc ++ ++Symbol table '\.symtab' contains 35 entries: ++ Num: Value Size Type Bind Vis Ndx Name ++ 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND ++ 1: 0000000000008000 0 SECTION LOCAL DEFAULT 1 ++ 2: 0000000000008070 0 SECTION LOCAL DEFAULT 2 ++ 3: 0000000000009000 0 SECTION LOCAL DEFAULT 3 ++ 4: 0000000000009080 0 SECTION LOCAL DEFAULT 4 ++ 5: 0000000000011000 0 SECTION LOCAL DEFAULT 5 ++ 6: 0000000000011120 0 SECTION LOCAL DEFAULT 6 ++ 7: 00000000000111c8 0 SECTION LOCAL DEFAULT 7 ++ 8: 0000000000011270 0 SECTION LOCAL DEFAULT 8 ++ 9: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o ++ 10: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local ++ 11: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local_ifunc ++ 12: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_local_ifunc ++ 13: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_local ++ 14: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 \$x ++ 15: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-2\.o ++ 16: 0000000000008038 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2 ++ 17: 0000000000008038 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2_ifunc ++ 18: 0000000000008038 0 IFUNC LOCAL DEFAULT 1 f_base_local2_ifunc ++ 19: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 f_base_local2 ++ 20: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 \$x ++ 21: 0000000000000000 0 FILE LOCAL DEFAULT ABS ++ 22: 0000000000009080 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC ++ 23: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_def ++ 24: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_global_hidden_ifunc ++ 25: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_global_hidden_def ++ 26: 0000000000009000 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ ++ 27: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_ifunc ++ 28: 0000000000008070 0 NOTYPE LOCAL DEFAULT 2 \$x ++ 29: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef ++ 30: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef ++ 31: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 32: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def ++ 33: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 34: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc +diff -rup binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-now.d binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-now.d +--- binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-now.d 2019-07-03 10:06:20.012412075 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-now.d 2019-07-03 10:20:51.959203582 +0100 +@@ -22,10 +22,10 @@ Symbol table '\.dynsym' contains 7 entri + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef +- 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef +- 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\] ++ 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\] + 4: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def +- 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\] + 6: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc + + Symbol table '\.symtab' contains 35 entries: +@@ -40,28 +40,28 @@ Symbol table '\.symtab' contains 35 entr + 7: 00000000000111c8 0 SECTION LOCAL DEFAULT 7 + 8: 0000000000011270 0 SECTION LOCAL DEFAULT 8 + 9: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o +- 10: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local +- 11: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local_ifunc ++ 10: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_spec_local \[VARIANT_PCS\] ++ 11: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_spec_local_ifunc \[VARIANT_PCS\] + 12: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_local_ifunc + 13: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_local + 14: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 \$x + 15: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-2\.o +- 16: 0000000000008038 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2 +- 17: 0000000000008038 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2_ifunc ++ 16: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 f_spec_local2 \[VARIANT_PCS\] ++ 17: 0000000000008038 0 IFUNC LOCAL DEFAULT 1 f_spec_local2_ifunc \[VARIANT_PCS\] + 18: 0000000000008038 0 IFUNC LOCAL DEFAULT 1 f_base_local2_ifunc + 19: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 f_base_local2 + 20: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 \$x + 21: 0000000000000000 0 FILE LOCAL DEFAULT ABS + 22: 0000000000009080 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC +- 23: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_def ++ 23: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_spec_global_hidden_def \[VARIANT_PCS\] + 24: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_global_hidden_ifunc + 25: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_global_hidden_def + 26: 0000000000009000 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ +- 27: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_ifunc ++ 27: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_spec_global_hidden_ifunc \[VARIANT_PCS\] + 28: 0000000000008070 0 NOTYPE LOCAL DEFAULT 2 \$x + 29: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef +- 30: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef +- 31: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 30: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\] ++ 31: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\] + 32: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def +- 33: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 33: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\] + 34: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc +diff -rup binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-r.d binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-r.d +--- binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-r.d 2019-07-03 10:06:20.012412075 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-r.d 2019-07-03 10:14:28.152933189 +0100 +@@ -37,24 +37,24 @@ Symbol table '\.symtab' contains 26 entr + 2: 0000000000000000 0 SECTION LOCAL DEFAULT 3 + 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 + 4: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o +- 5: 0000000000000000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local +- 6: 0000000000000000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local_ifunc ++ 5: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 f_spec_local \[VARIANT_PCS\] ++ 6: 0000000000000000 0 IFUNC LOCAL DEFAULT 1 f_spec_local_ifunc \[VARIANT_PCS\] + 7: 0000000000000000 0 IFUNC LOCAL DEFAULT 1 f_base_local_ifunc + 8: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 f_base_local + 9: 0000000000000000 0 NOTYPE LOCAL DEFAULT 1 \$x + 10: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-2\.o +- 11: 0000000000000038 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2 +- 12: 0000000000000038 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2_ifunc ++ 11: 0000000000000038 0 NOTYPE LOCAL DEFAULT 1 f_spec_local2 \[VARIANT_PCS\] ++ 12: 0000000000000038 0 IFUNC LOCAL DEFAULT 1 f_spec_local2_ifunc \[VARIANT_PCS\] + 13: 0000000000000038 0 IFUNC LOCAL DEFAULT 1 f_base_local2_ifunc + 14: 0000000000000038 0 NOTYPE LOCAL DEFAULT 1 f_base_local2 + 15: 0000000000000038 0 NOTYPE LOCAL DEFAULT 1 \$x + 16: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef +- 17: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef +- 18: 0000000000000000 0 NOTYPE GLOBAL HIDDEN \[VARIANT_PCS\] 1 f_spec_global_hidden_def ++ 17: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\] ++ 18: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 f_spec_global_hidden_def \[VARIANT_PCS\] + 19: 0000000000000000 0 IFUNC GLOBAL HIDDEN 1 f_base_global_hidden_ifunc +- 20: 0000000000000000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 20: 0000000000000000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\] + 21: 0000000000000000 0 NOTYPE GLOBAL HIDDEN 1 f_base_global_hidden_def +- 22: 0000000000000000 0 IFUNC GLOBAL HIDDEN \[VARIANT_PCS\] 1 f_spec_global_hidden_ifunc ++ 22: 0000000000000000 0 IFUNC GLOBAL HIDDEN 1 f_spec_global_hidden_ifunc \[VARIANT_PCS\] + 23: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def +- 24: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 24: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\] + 25: 0000000000000000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc +diff -rup binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-shared.d binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-shared.d +--- binutils.orig/ld/testsuite/ld-aarch64/variant_pcs-shared.d 2019-07-03 10:06:20.012412075 +0100 ++++ binutils-2.32/ld/testsuite/ld-aarch64/variant_pcs-shared.d 2019-07-03 10:19:00.760994532 +0100 +@@ -22,10 +22,10 @@ Symbol table '\.dynsym' contains 7 entri + Num: Value Size Type Bind Vis Ndx Name + 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND + 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef +- 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef +- 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\] ++ 3: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\] + 4: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def +- 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 5: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\] + 6: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc + + Symbol table '\.symtab' contains 35 entries: +@@ -40,28 +40,28 @@ Symbol table '\.symtab' contains 35 entr + 7: 00000000000111c8 0 SECTION LOCAL DEFAULT 7 + 8: 0000000000011270 0 SECTION LOCAL DEFAULT 8 + 9: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-1\.o +- 10: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local +- 11: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local_ifunc ++ 10: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_spec_local \[VARIANT_PCS\] ++ 11: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_spec_local_ifunc \[VARIANT_PCS\] + 12: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_local_ifunc + 13: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_local + 14: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 \$x + 15: 0000000000000000 0 FILE LOCAL DEFAULT ABS .*variant_pcs-2\.o +- 16: 0000000000008038 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2 +- 17: 0000000000008038 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_local2_ifunc ++ 16: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 f_spec_local2 \[VARIANT_PCS\] ++ 17: 0000000000008038 0 IFUNC LOCAL DEFAULT 1 f_spec_local2_ifunc \[VARIANT_PCS\] + 18: 0000000000008038 0 IFUNC LOCAL DEFAULT 1 f_base_local2_ifunc + 19: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 f_base_local2 + 20: 0000000000008038 0 NOTYPE LOCAL DEFAULT 1 \$x + 21: 0000000000000000 0 FILE LOCAL DEFAULT ABS + 22: 0000000000009080 0 OBJECT LOCAL DEFAULT ABS _DYNAMIC +- 23: 0000000000008000 0 NOTYPE LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_def ++ 23: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_spec_global_hidden_def \[VARIANT_PCS\] + 24: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_base_global_hidden_ifunc + 25: 0000000000008000 0 NOTYPE LOCAL DEFAULT 1 f_base_global_hidden_def + 26: 0000000000009000 0 OBJECT LOCAL DEFAULT ABS _GLOBAL_OFFSET_TABLE_ +- 27: 0000000000008000 0 IFUNC LOCAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_hidden_ifunc ++ 27: 0000000000008000 0 IFUNC LOCAL DEFAULT 1 f_spec_global_hidden_ifunc \[VARIANT_PCS\] + 28: 0000000000008070 0 NOTYPE LOCAL DEFAULT 2 \$x + 29: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_base_global_default_undef +- 30: 0000000000000000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] UND f_spec_global_default_undef +- 31: 0000000000008000 0 IFUNC GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_ifunc ++ 30: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND f_spec_global_default_undef \[VARIANT_PCS\] ++ 31: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_spec_global_default_ifunc \[VARIANT_PCS\] + 32: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_base_global_default_def +- 33: 0000000000008000 0 NOTYPE GLOBAL DEFAULT \[VARIANT_PCS\] 1 f_spec_global_default_def ++ 33: 0000000000008000 0 NOTYPE GLOBAL DEFAULT 1 f_spec_global_default_def \[VARIANT_PCS\] + 34: 0000000000008000 0 IFUNC GLOBAL DEFAULT 1 f_base_global_default_ifunc diff --git a/SOURCES/binutils-aarch64-armv8.6-support.patch b/SOURCES/binutils-aarch64-armv8.6-support.patch new file mode 100644 index 0000000..fd070a7 --- /dev/null +++ b/SOURCES/binutils-aarch64-armv8.6-support.patch @@ -0,0 +1,146139 @@ +diff -rup binutils-2.30/bfd/archures.c binutils-2.30.new/bfd/archures.c +--- binutils-2.30/bfd/archures.c 2021-03-23 16:21:44.001022834 +0000 ++++ binutils-2.30.new/bfd/archures.c 2021-03-23 16:20:02.829710624 +0000 +@@ -526,6 +526,7 @@ DESCRIPTION + .#define bfd_mach_tilegx32 2 + . bfd_arch_aarch64, {* AArch64. *} + .#define bfd_mach_aarch64 0 ++.#define bfd_mach_aarch64_8R 1 + .#define bfd_mach_aarch64_ilp32 32 + . bfd_arch_nios2, {* Nios II. *} + .#define bfd_mach_nios2 0 +diff -rup binutils-2.30/bfd/bfd-in2.h binutils-2.30.new/bfd/bfd-in2.h +--- binutils-2.30/bfd/bfd-in2.h 2021-03-23 16:21:44.002022828 +0000 ++++ binutils-2.30.new/bfd/bfd-in2.h 2021-03-23 16:20:02.815710719 +0000 +@@ -985,12 +985,6 @@ extern void bfd_elf64_aarch64_init_maps + extern void bfd_elf32_aarch64_init_maps + (bfd *); + +-extern void bfd_elf64_aarch64_set_options +- (bfd *, struct bfd_link_info *, int, int, int, int, int, int); +- +-extern void bfd_elf32_aarch64_set_options +- (bfd *, struct bfd_link_info *, int, int, int, int, int, int); +- + /* ELF AArch64 mapping symbol support. */ + #define BFD_AARCH64_SPECIAL_SYM_TYPE_MAP (1 << 0) + #define BFD_AARCH64_SPECIAL_SYM_TYPE_TAG (1 << 1) +@@ -2388,6 +2382,7 @@ enum bfd_architecture + #define bfd_mach_tilegx32 2 + bfd_arch_aarch64, /* AArch64. */ + #define bfd_mach_aarch64 0 ++#define bfd_mach_aarch64_8R 1 + #define bfd_mach_aarch64_ilp32 32 + bfd_arch_nios2, /* Nios II. */ + #define bfd_mach_nios2 0 +@@ -5961,6 +5956,36 @@ of a signed value. Changes instruction + value's sign. */ + BFD_RELOC_AARCH64_MOVW_G2_S, + ++/* AArch64 MOV[NZ] instruction with most significant bits 0 to 15 ++of a signed value. Changes instruction to MOVZ or MOVN depending on the ++value's sign. */ ++ BFD_RELOC_AARCH64_MOVW_PREL_G0, ++ ++/* AArch64 MOV[NZ] instruction with most significant bits 0 to 15 ++of a signed value. Changes instruction to MOVZ or MOVN depending on the ++value's sign. */ ++ BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, ++ ++/* AArch64 MOVK instruction with most significant bits 16 to 31 ++of a signed value. */ ++ BFD_RELOC_AARCH64_MOVW_PREL_G1, ++ ++/* AArch64 MOVK instruction with most significant bits 16 to 31 ++of a signed value. */ ++ BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, ++ ++/* AArch64 MOVK instruction with most significant bits 32 to 47 ++of a signed value. */ ++ BFD_RELOC_AARCH64_MOVW_PREL_G2, ++ ++/* AArch64 MOVK instruction with most significant bits 32 to 47 ++of a signed value. */ ++ BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, ++ ++/* AArch64 MOVK instruction with most significant bits 47 to 63 ++of a signed value. */ ++ BFD_RELOC_AARCH64_MOVW_PREL_G3, ++ + /* AArch64 Load Literal instruction, holding a 19 bit pc-relative word + offset. The lowest two bits must be zero and are not stored in the + instruction, giving a 21 bit signed byte offset. */ +@@ -6188,6 +6213,34 @@ instructions. */ + /* AArch64 TLS LOCAL EXEC relocation. */ + BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC, + ++/* bit[11:1] of byte offset to module TLS base address, encoded in ldst ++instructions. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, ++ ++/* Similar as BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, but no overflow check. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC, ++ ++/* bit[11:2] of byte offset to module TLS base address, encoded in ldst ++instructions. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, ++ ++/* Similar as BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, but no overflow check. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC, ++ ++/* bit[11:3] of byte offset to module TLS base address, encoded in ldst ++instructions. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, ++ ++/* Similar as BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, but no overflow check. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC, ++ ++/* bit[11:0] of byte offset to module TLS base address, encoded in ldst ++instructions. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, ++ ++/* Similar as BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, but no overflow check. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC, ++ + /* AArch64 TLS DESC relocation. */ + BFD_RELOC_AARCH64_TLSDESC_LD_PREL19, + +@@ -6271,6 +6324,14 @@ any object files. */ + /* Similar as BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, but no overflow check. */ + BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC, + ++/* AArch64 pseudo relocation code for TLS local exec mode. It's to be ++used internally by the AArch64 assembler and not (currently) written to ++any object files. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, ++ ++/* Similar as BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, but no overflow check. */ ++ BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC, ++ + /* AArch64 pseudo relocation code to be used internally by the AArch64 + assembler and not (currently) written to any object files. */ + BFD_RELOC_AARCH64_LD_GOT_LO12_NC, +diff -rup binutils-2.30/bfd/cpu-aarch64.c binutils-2.30.new/bfd/cpu-aarch64.c +--- binutils-2.30/bfd/cpu-aarch64.c 2018-01-13 13:31:15.000000000 +0000 ++++ binutils-2.30.new/bfd/cpu-aarch64.c 2021-03-23 16:20:02.830710617 +0000 +@@ -1,5 +1,5 @@ + /* BFD support for AArch64. +- Copyright (C) 2009-2018 Free Software Foundation, Inc. ++ Copyright (C) 2009-2021 Free Software Foundation, Inc. + Contributed by ARM Ltd. + + This file is part of BFD, the Binary File Descriptor library. +@@ -22,6 +22,7 @@ + #include "bfd.h" + #include "libbfd.h" + #include "libiberty.h" ++#include "cpu-aarch64.h" + + /* This routine is provided two arch_infos and works out which Aarch64 + machine which would be compatible with both and returns a pointer +@@ -68,10 +69,11 @@ static struct + } + processors[] = + { +- /* These two are example CPUs supported in GCC, once we have real +- CPUs they will be removed. */ +- { bfd_mach_aarch64, "example-1" }, +- { bfd_mach_aarch64, "example-2" } ++ { bfd_mach_aarch64, "cortex-a34" }, ++ { bfd_mach_aarch64, "cortex-a65" }, ++ { bfd_mach_aarch64, "cortex-a65ae" }, ++ { bfd_mach_aarch64, "cortex-a76ae" }, ++ { bfd_mach_aarch64, "cortex-a77" } + }; + + static bfd_boolean +@@ -103,10 +105,14 @@ scan (const struct bfd_arch_info *info, + #define N(NUMBER, PRINT, WORDSIZE, DEFAULT, NEXT) \ + { WORDSIZE, WORDSIZE, 8, bfd_arch_aarch64, NUMBER, \ + "aarch64", PRINT, 4, DEFAULT, compatible, scan, \ +- bfd_arch_default_fill, NEXT } ++ bfd_arch_default_fill, NEXT, 0 } ++ ++static const bfd_arch_info_type bfd_aarch64_arch_v8_r = ++ N (bfd_mach_aarch64_8R, "aarch64:armv8-r", 64, FALSE, NULL); + + static const bfd_arch_info_type bfd_aarch64_arch_ilp32 = +- N (bfd_mach_aarch64_ilp32, "aarch64:ilp32", 32, FALSE, NULL); ++ N (bfd_mach_aarch64_ilp32, "aarch64:ilp32", 32, FALSE, ++ &bfd_aarch64_arch_v8_r); + + const bfd_arch_info_type bfd_aarch64_arch = + N (0, "aarch64", 64, TRUE, &bfd_aarch64_arch_ilp32); +diff -rup binutils-2.30/bfd/reloc.c binutils-2.30.new/bfd/reloc.c +--- binutils-2.30/bfd/reloc.c 2018-01-13 13:31:15.000000000 +0000 ++++ binutils-2.30.new/bfd/reloc.c 2021-03-23 16:20:02.829710624 +0000 +@@ -7071,6 +7071,43 @@ ENUMDOC + of a signed value. Changes instruction to MOVZ or MOVN depending on the + value's sign. + ENUM ++ BFD_RELOC_AARCH64_MOVW_PREL_G0 ++ENUMDOC ++ AArch64 MOV[NZ] instruction with most significant bits 0 to 15 ++ of a signed value. Changes instruction to MOVZ or MOVN depending on the ++ value's sign. ++ENUM ++ BFD_RELOC_AARCH64_MOVW_PREL_G0_NC ++ENUMDOC ++ AArch64 MOV[NZ] instruction with most significant bits 0 to 15 ++ of a signed value. Changes instruction to MOVZ or MOVN depending on the ++ value's sign. ++ENUM ++ BFD_RELOC_AARCH64_MOVW_PREL_G1 ++ENUMDOC ++ AArch64 MOVK instruction with most significant bits 16 to 31 ++ of a signed value. ++ENUM ++ BFD_RELOC_AARCH64_MOVW_PREL_G1_NC ++ENUMDOC ++ AArch64 MOVK instruction with most significant bits 16 to 31 ++ of a signed value. ++ENUM ++ BFD_RELOC_AARCH64_MOVW_PREL_G2 ++ENUMDOC ++ AArch64 MOVK instruction with most significant bits 32 to 47 ++ of a signed value. ++ENUM ++ BFD_RELOC_AARCH64_MOVW_PREL_G2_NC ++ENUMDOC ++ AArch64 MOVK instruction with most significant bits 32 to 47 ++ of a signed value. ++ENUM ++ BFD_RELOC_AARCH64_MOVW_PREL_G3 ++ENUMDOC ++ AArch64 MOVK instruction with most significant bits 47 to 63 ++ of a signed value. ++ENUM + BFD_RELOC_AARCH64_LD_LO19_PCREL + ENUMDOC + AArch64 Load Literal instruction, holding a 19 bit pc-relative word +@@ -7359,6 +7396,42 @@ ENUM + ENUMDOC + AArch64 TLS LOCAL EXEC relocation. + ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12 ++ENUMDOC ++ bit[11:1] of byte offset to module TLS base address, encoded in ldst ++ instructions. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC ++ENUMDOC ++ Similar as BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, but no overflow check. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12 ++ENUMDOC ++ bit[11:2] of byte offset to module TLS base address, encoded in ldst ++ instructions. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC ++ENUMDOC ++ Similar as BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, but no overflow check. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12 ++ENUMDOC ++ bit[11:3] of byte offset to module TLS base address, encoded in ldst ++ instructions. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC ++ENUMDOC ++ Similar as BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, but no overflow check. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12 ++ENUMDOC ++ bit[11:0] of byte offset to module TLS base address, encoded in ldst ++ instructions. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC ++ENUMDOC ++ Similar as BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, but no overflow check. ++ENUM + BFD_RELOC_AARCH64_TLSDESC_LD_PREL19 + ENUMDOC + AArch64 TLS DESC relocation. +@@ -7467,6 +7540,16 @@ ENUM + ENUMDOC + Similar as BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12, but no overflow check. + ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12 ++ENUMDOC ++ AArch64 pseudo relocation code for TLS local exec mode. It's to be ++ used internally by the AArch64 assembler and not (currently) written to ++ any object files. ++ENUM ++ BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC ++ENUMDOC ++ Similar as BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, but no overflow check. ++ENUM + BFD_RELOC_AARCH64_LD_GOT_LO12_NC + ENUMDOC + AArch64 pseudo relocation code to be used internally by the AArch64 +diff -rup binutils-2.30/gas/config/tc-aarch64.c binutils-2.30.new/gas/config/tc-aarch64.c +--- binutils-2.30/gas/config/tc-aarch64.c 2021-03-23 16:21:44.128021971 +0000 ++++ binutils-2.30.new/gas/config/tc-aarch64.c 2021-03-23 16:19:55.031763633 +0000 +@@ -1,6 +1,6 @@ + /* tc-aarch64.c -- Assemble for the AArch64 ISA + +- Copyright (C) 2009-2018 Free Software Foundation, Inc. ++ Copyright (C) 2009-2021 Free Software Foundation, Inc. + Contributed by ARM Ltd. + + This file is part of GAS. +@@ -35,6 +35,9 @@ + + #include "dwarf2dbg.h" + ++/* Number of littlenums required to hold an extended precision number. */ ++#define MAX_LITTLENUMS 6 ++ + /* Types of processor to assemble for. */ + #ifndef CPU_DEFAULT + #define CPU_DEFAULT AARCH64_ARCH_V8 +@@ -55,6 +58,9 @@ static const aarch64_feature_set *march_ + /* Constants for known architecture features. */ + static const aarch64_feature_set cpu_default = CPU_DEFAULT; + ++/* Currently active instruction sequence. */ ++static aarch64_instr_sequence *insn_sequence = NULL; ++ + #ifdef OBJ_ELF + /* Pre-defined "_GLOBAL_OFFSET_TABLE_" */ + static symbolS *GOT_symbol; +@@ -146,6 +152,13 @@ static aarch64_instruction inst; + static bfd_boolean parse_operands (char *, const aarch64_opcode *); + static bfd_boolean programmer_friendly_fixup (aarch64_instruction *); + ++#ifdef OBJ_ELF ++# define now_instr_sequence seg_info \ ++ (now_seg)->tc_segment_info_data.insn_sequence ++#else ++static struct aarch64_instr_sequence now_instr_sequence; ++#endif ++ + /* Diagnostics inline function utilities. + + These are lightweight utilities which should only be called by parse_operands +@@ -228,9 +241,6 @@ set_fatal_syntax_error (const char *erro + set_error (AARCH64_OPDE_FATAL_SYNTAX_ERROR, error); + } + +-/* Number of littlenums required to hold an extended precision number. */ +-#define MAX_LITTLENUMS 6 +- + /* Return value for certain parsers when the parsing fails; those parsers + return the information of the parsed result, e.g. register number, on + success. */ +@@ -243,12 +253,6 @@ set_fatal_syntax_error (const char *erro + typedef struct + { + const char *template; +- unsigned long value; +-} asm_barrier_opt; +- +-typedef struct +-{ +- const char *template; + uint32_t value; + } asm_nzcv; + +@@ -439,24 +443,28 @@ get_reg_expected_msg (aarch64_reg_type r + + /* Some well known registers that we refer to directly elsewhere. */ + #define REG_SP 31 ++#define REG_ZR 31 + + /* Instructions take 4 bytes in the object file. */ + #define INSN_SIZE 4 + +-static struct hash_control *aarch64_ops_hsh; +-static struct hash_control *aarch64_cond_hsh; +-static struct hash_control *aarch64_shift_hsh; +-static struct hash_control *aarch64_sys_regs_hsh; +-static struct hash_control *aarch64_pstatefield_hsh; +-static struct hash_control *aarch64_sys_regs_ic_hsh; +-static struct hash_control *aarch64_sys_regs_dc_hsh; +-static struct hash_control *aarch64_sys_regs_at_hsh; +-static struct hash_control *aarch64_sys_regs_tlbi_hsh; +-static struct hash_control *aarch64_reg_hsh; +-static struct hash_control *aarch64_barrier_opt_hsh; +-static struct hash_control *aarch64_nzcv_hsh; +-static struct hash_control *aarch64_pldop_hsh; +-static struct hash_control *aarch64_hint_opt_hsh; ++#define htab_t struct hash_control * ++ ++static htab_t aarch64_ops_hsh; ++static htab_t aarch64_cond_hsh; ++static htab_t aarch64_shift_hsh; ++static htab_t aarch64_sys_regs_hsh; ++static htab_t aarch64_pstatefield_hsh; ++static htab_t aarch64_sys_regs_ic_hsh; ++static htab_t aarch64_sys_regs_dc_hsh; ++static htab_t aarch64_sys_regs_at_hsh; ++static htab_t aarch64_sys_regs_tlbi_hsh; ++static htab_t aarch64_sys_regs_sr_hsh; ++static htab_t aarch64_reg_hsh; ++static htab_t aarch64_barrier_opt_hsh; ++static htab_t aarch64_nzcv_hsh; ++static htab_t aarch64_pldop_hsh; ++static htab_t aarch64_hint_opt_hsh; + + /* Stuff needed to resolve the label ambiguity + As: +@@ -520,7 +528,7 @@ const char EXP_CHARS[] = "eE"; + /* As in 0f12.456 */ + /* or 0d1.2345e12 */ + +-const char FLT_CHARS[] = "rRsSfFdDxXeEpP"; ++const char FLT_CHARS[] = "rRsSfFdDxXeEpPhH"; + + /* Prefix character that indicates the start of an immediate value. */ + #define is_immediate_prefix(C) ((C) == '#') +@@ -618,6 +626,96 @@ my_get_expression (expressionS * ep, cha + return TRUE; + } + ++#define MAX_PRECISION 5 ++#define H_PRECISION 1 ++#define F_PRECISION 2 ++#define D_PRECISION 4 ++#define X_PRECISION 5 ++#define P_PRECISION 5 ++/* Length in LittleNums of guard bits. */ ++#define GUARD 2 ++ ++static void ++make_invalid_floating_point_number (LITTLENUM_TYPE *words) ++{ ++ as_bad (_("cannot create floating-point number")); ++ /* Zero the leftmost bit. */ ++ words[0] = (LITTLENUM_TYPE) ((unsigned) -1) >> 1; ++ words[1] = (LITTLENUM_TYPE) -1; ++ words[2] = (LITTLENUM_TYPE) -1; ++ words[3] = (LITTLENUM_TYPE) -1; ++ words[4] = (LITTLENUM_TYPE) -1; ++ words[5] = (LITTLENUM_TYPE) -1; ++} ++ ++char * atof_ieee_detail (char *, int, int, LITTLENUM_TYPE *, FLONUM_TYPE *); ++ ++/* Build a floating point constant at str into a IEEE floating ++ point number. This function does the same thing as atof_ieee ++ however it allows more control over the exact format, i.e. ++ explicitly specifying the precision and number of exponent bits ++ instead of relying on this infomation being deduced from a given type. ++ ++ If generic_float_info is not NULL then it will be set to contain generic ++ infomation about the parsed floating point number. ++ ++ Returns pointer past text consumed. */ ++char * ++atof_ieee_detail (char * str, ++ int precision, ++ int exponent_bits, ++ LITTLENUM_TYPE * words, ++ FLONUM_TYPE * generic_float_info) ++{ ++ /* Extra bits for zeroed low-order bits. ++ The 1st MAX_PRECISION are zeroed, the last contain flonum bits. */ ++ static LITTLENUM_TYPE bits[MAX_PRECISION + MAX_PRECISION + GUARD]; ++ char *return_value; ++ ++ /* Number of 16-bit words in the format. */ ++ FLONUM_TYPE save_gen_flonum; ++ ++ /* We have to save the generic_floating_point_number because it ++ contains storage allocation about the array of LITTLENUMs where ++ the value is actually stored. We will allocate our own array of ++ littlenums below, but have to restore the global one on exit. */ ++ save_gen_flonum = generic_floating_point_number; ++ ++ return_value = str; ++ generic_floating_point_number.low = bits + MAX_PRECISION; ++ generic_floating_point_number.high = NULL; ++ generic_floating_point_number.leader = NULL; ++ generic_floating_point_number.exponent = 0; ++ generic_floating_point_number.sign = '\0'; ++ ++ /* Use more LittleNums than seems necessary: the highest flonum may ++ have 15 leading 0 bits, so could be useless. */ ++ ++ memset (bits, '\0', sizeof (LITTLENUM_TYPE) * MAX_PRECISION); ++ ++ generic_floating_point_number.high ++ = generic_floating_point_number.low + precision - 1 + GUARD; ++ ++ if (atof_generic (&return_value, ".", EXP_CHARS, ++ &generic_floating_point_number)) ++ { ++ make_invalid_floating_point_number (words); ++ return NULL; ++ } ++ ++ if (generic_float_info) ++ *generic_float_info = generic_floating_point_number; ++ ++ gen_to_words (words, precision, exponent_bits); ++ ++ /* Restore the generic_floating_point_number's storage alloc (and ++ everything else). */ ++ generic_floating_point_number = save_gen_flonum; ++ ++ return return_value; ++} ++ ++ + /* Turn a string in input_line_pointer into a floating point constant + of type TYPE, and store the appropriate bytes in *LITP. The number + of LITTLENUMS emitted is stored in *SIZEP. An error message is +@@ -626,6 +724,54 @@ my_get_expression (expressionS * ep, cha + const char * + md_atof (int type, char *litP, int *sizeP) + { ++ /* If this is a bfloat16 type, then parse it slightly differently - ++ as it does not follow the IEEE standard exactly. */ ++ if (type == 'b') ++ { ++ char * t; ++ LITTLENUM_TYPE words[MAX_LITTLENUMS]; ++ FLONUM_TYPE generic_float; ++ ++ t = atof_ieee_detail (input_line_pointer, 1, 8, words, &generic_float); ++ ++ if (t) ++ input_line_pointer = t; ++ else ++ return _("invalid floating point number"); ++ ++ switch (generic_float.sign) ++ { ++ /* Is +Inf. */ ++ case 'P': ++ words[0] = 0x7f80; ++ break; ++ ++ /* Is -Inf. */ ++ case 'N': ++ words[0] = 0xff80; ++ break; ++ ++ /* Is NaN. */ ++ /* bfloat16 has two types of NaN - quiet and signalling. ++ Quiet NaN has bit[6] == 1 && faction != 0, whereas ++ signalling Nan's have bit[0] == 0 && fraction != 0. ++ Chose this specific encoding as it is the same form ++ as used by other IEEE 754 encodings in GAS. */ ++ case 0: ++ words[0] = 0x7fff; ++ break; ++ ++ default: ++ break; ++ } ++ ++ *sizeP = 2; ++ ++ md_number_to_chars (litP, (valueT) words[0], sizeof (LITTLENUM_TYPE)); ++ ++ return NULL; ++ } ++ + return ieee_md_atof (type, litP, sizeP, target_big_endian); + } + +@@ -826,7 +972,7 @@ parse_vector_type_for_operand (aarch64_r + return FALSE; + } + +-elt_size: ++ elt_size: + switch (TOLOWER (*ptr)) + { + case 'b': +@@ -1945,7 +2091,7 @@ s_variant_pcs (int ignored ATTRIBUTE_UNU + restore_line_pointer (c); + demand_empty_rest_of_line (); + bfdsym = symbol_get_bfdsym (sym); +- elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym); ++ elfsym = elf_symbol_from (NULL, bfdsym); + gas_assert (elfsym); + elfsym->internal_elf_sym.st_other |= STO_AARCH64_VARIANT_PCS; + } +@@ -2088,6 +2234,8 @@ const pseudo_typeS md_pseudo_table[] = { + {"dword", s_aarch64_elf_cons, 8}, + {"variant_pcs", s_variant_pcs, 0}, + #endif ++ {"float16", float_cons, 'h'}, ++ {"bfloat16", float_cons, 'b'}, + {0, 0, 0} + }; + +@@ -2122,7 +2270,7 @@ reg_name_p (char *str, aarch64_reg_type + return FALSE; + + skip_whitespace (str); +- if (*str == ',' || is_end_of_line[(unsigned int) *str]) ++ if (*str == ',' || is_end_of_line[(unsigned char) *str]) + return TRUE; + + return FALSE; +@@ -2302,7 +2450,6 @@ parse_aarch64_imm_float (char **ccp, int + char *str = *ccp; + char *fpnum; + LITTLENUM_TYPE words[MAX_LITTLENUMS]; +- int found_fpchar = 0; + int64_t val = 0; + unsigned fpword = 0; + bfd_boolean hex_p = FALSE; +@@ -2332,26 +2479,10 @@ parse_aarch64_imm_float (char **ccp, int + + hex_p = TRUE; + } +- else +- { +- if (reg_name_p (str, reg_type)) +- { +- set_recoverable_error (_("immediate operand required")); +- return FALSE; +- } +- +- /* We must not accidentally parse an integer as a floating-point number. +- Make sure that the value we parse is not an integer by checking for +- special characters '.' or 'e'. */ +- for (; *fpnum != '\0' && *fpnum != ' ' && *fpnum != '\n'; fpnum++) +- if (*fpnum == '.' || *fpnum == 'e' || *fpnum == 'E') +- { +- found_fpchar = 1; +- break; +- } +- +- if (!found_fpchar) +- return FALSE; ++ else if (reg_name_p (str, reg_type)) ++ { ++ set_recoverable_error (_("immediate operand required")); ++ return FALSE; + } + + if (! hex_p) +@@ -2373,7 +2504,7 @@ parse_aarch64_imm_float (char **ccp, int + *ccp = str; + return TRUE; + +-invalid_fp: ++ invalid_fp: + set_fatal_syntax_error (_("invalid floating-point constant")); + return FALSE; + } +@@ -2600,6 +2731,69 @@ static struct reloc_table_entry reloc_ta + 0, + 0}, + ++ /* Most significant bits 0-15 of signed/unsigned address/value: MOVZ */ ++ {"prel_g0", 1, ++ 0, /* adr_type */ ++ 0, ++ BFD_RELOC_AARCH64_MOVW_PREL_G0, ++ 0, ++ 0, ++ 0}, ++ ++ /* Most significant bits 0-15 of signed/unsigned address/value: MOVK */ ++ {"prel_g0_nc", 1, ++ 0, /* adr_type */ ++ 0, ++ BFD_RELOC_AARCH64_MOVW_PREL_G0_NC, ++ 0, ++ 0, ++ 0}, ++ ++ /* Most significant bits 16-31 of signed/unsigned address/value: MOVZ */ ++ {"prel_g1", 1, ++ 0, /* adr_type */ ++ 0, ++ BFD_RELOC_AARCH64_MOVW_PREL_G1, ++ 0, ++ 0, ++ 0}, ++ ++ /* Most significant bits 16-31 of signed/unsigned address/value: MOVK */ ++ {"prel_g1_nc", 1, ++ 0, /* adr_type */ ++ 0, ++ BFD_RELOC_AARCH64_MOVW_PREL_G1_NC, ++ 0, ++ 0, ++ 0}, ++ ++ /* Most significant bits 32-47 of signed/unsigned address/value: MOVZ */ ++ {"prel_g2", 1, ++ 0, /* adr_type */ ++ 0, ++ BFD_RELOC_AARCH64_MOVW_PREL_G2, ++ 0, ++ 0, ++ 0}, ++ ++ /* Most significant bits 32-47 of signed/unsigned address/value: MOVK */ ++ {"prel_g2_nc", 1, ++ 0, /* adr_type */ ++ 0, ++ BFD_RELOC_AARCH64_MOVW_PREL_G2_NC, ++ 0, ++ 0, ++ 0}, ++ ++ /* Most significant bits 48-63 of signed/unsigned address/value: MOVZ */ ++ {"prel_g3", 1, ++ 0, /* adr_type */ ++ 0, ++ BFD_RELOC_AARCH64_MOVW_PREL_G3, ++ 0, ++ 0, ++ 0}, ++ + /* Get to the page containing GOT entry for a symbol. */ + {"got", 1, + 0, /* adr_type */ +@@ -2862,7 +3056,7 @@ static struct reloc_table_entry reloc_ta + 0, + 0, + BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12, +- 0, ++ BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12, + 0}, + + /* Get tp offset for a symbol. */ +@@ -2880,7 +3074,7 @@ static struct reloc_table_entry reloc_ta + 0, + 0, + BFD_RELOC_AARCH64_TLSLE_ADD_TPREL_LO12_NC, +- 0, ++ BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC, + 0}, + + /* Most significant bits 32-47 of address/value: MOVZ. */ +@@ -3337,6 +3531,7 @@ parse_shifter_operand_reloc (char **str, + [base,Xm,SXTX {#imm}] + [base,Wm,(S|U)XTW {#imm}] + Pre-indexed ++ [base]! // in ldraa/ldrab exclusive + [base,#imm]! + Post-indexed + [base],#imm +@@ -3350,6 +3545,7 @@ parse_shifter_operand_reloc (char **str, + [base,Zm.D,(S|U)XTW {#imm}] // ignores top 32 bits of Zm.D elements + [Zn.S,#imm] + [Zn.D,#imm] ++ [Zn.S{, Xm}] + [Zn.S,Zm.S{,LSL #imm}] // in ADR + [Zn.D,Zm.D{,LSL #imm}] // in ADR + [Zn.D,Zm.D,(S|U)XTW {#imm}] // in ADR +@@ -3515,6 +3711,7 @@ parse_address_main (char **str, aarch64_ + return FALSE; + } + /* We only accept: ++ [base,Xm] # For vector plus scalar SVE2 indexing. + [base,Xm{,LSL #imm}] + [base,Xm,SXTX {#imm}] + [base,Wm,(S|U)XTW {#imm}] */ +@@ -3528,7 +3725,10 @@ parse_address_main (char **str, aarch64_ + return FALSE; + } + if (aarch64_get_qualifier_esize (*base_qualifier) +- != aarch64_get_qualifier_esize (*offset_qualifier)) ++ != aarch64_get_qualifier_esize (*offset_qualifier) ++ && (operand->type != AARCH64_OPND_SVE_ADDR_ZX ++ || *base_qualifier != AARCH64_OPND_QLF_S_S ++ || *offset_qualifier != AARCH64_OPND_QLF_X)) + { + set_syntax_error (_("offset has different size from base")); + return FALSE; +@@ -3646,18 +3846,43 @@ parse_address_main (char **str, aarch64_ + } + + /* If at this point neither .preind nor .postind is set, we have a +- bare [Rn]{!}; reject [Rn]! but accept [Rn] as a shorthand for [Rn,#0]. */ ++ bare [Rn]{!}; only accept [Rn]! as a shorthand for [Rn,#0]! for ldraa and ++ ldrab, accept [Rn] as a shorthand for [Rn,#0]. ++ For SVE2 vector plus scalar offsets, allow [Zn.] as shorthand for ++ [Zn., xzr]. */ + if (operand->addr.preind == 0 && operand->addr.postind == 0) + { + if (operand->addr.writeback) + { +- /* Reject [Rn]! */ +- set_syntax_error (_("missing offset in the pre-indexed address")); +- return FALSE; ++ if (operand->type == AARCH64_OPND_ADDR_SIMM10) ++ { ++ /* Accept [Rn]! as a shorthand for [Rn,#0]! */ ++ operand->addr.offset.is_reg = 0; ++ operand->addr.offset.imm = 0; ++ operand->addr.preind = 1; ++ } ++ else ++ { ++ /* Reject [Rn]! */ ++ set_syntax_error (_("missing offset in the pre-indexed address")); ++ return FALSE; ++ } ++ } ++ else ++ { ++ operand->addr.preind = 1; ++ if (operand->type == AARCH64_OPND_SVE_ADDR_ZX) ++ { ++ operand->addr.offset.is_reg = 1; ++ operand->addr.offset.regno = REG_ZR; ++ *offset_qualifier = AARCH64_OPND_QLF_X; ++ } ++ else ++ { ++ inst.reloc.exp.X_op = O_constant; ++ inst.reloc.exp.X_add_number = 0; ++ } + } +- operand->addr.preind = 1; +- inst.reloc.exp.X_op = O_constant; +- inst.reloc.exp.X_add_number = 0; + } + + *str = p; +@@ -3849,7 +4074,7 @@ static int + parse_barrier (char **str) + { + char *p, *q; +- const asm_barrier_opt *o; ++ const struct aarch64_name_value_pair *o; + + p = q = *str; + while (ISALPHA (*q)) +@@ -3881,7 +4106,7 @@ parse_barrier_psb (char **str, + if (!o) + { + set_fatal_syntax_error +- ( _("unknown or missing option to PSB")); ++ ( _("unknown or missing option to PSB/TSB")); + return PARSE_FAIL; + } + +@@ -3889,7 +4114,48 @@ parse_barrier_psb (char **str, + { + /* PSB only accepts option name 'CSYNC'. */ + set_syntax_error +- (_("the specified option is not accepted for PSB")); ++ (_("the specified option is not accepted for PSB/TSB")); ++ return PARSE_FAIL; ++ } ++ ++ *str = q; ++ *hint_opt = o; ++ return 0; ++} ++ ++/* Parse an operand for BTI. Set *HINT_OPT to the hint-option record ++ return 0 if successful. Otherwise return PARSE_FAIL. */ ++ ++static int ++parse_bti_operand (char **str, ++ const struct aarch64_name_value_pair ** hint_opt) ++{ ++ char *p, *q; ++ const struct aarch64_name_value_pair *o; ++ ++ p = q = *str; ++ while (ISALPHA (*q)) ++ q++; ++ ++ o = hash_find_n (aarch64_hint_opt_hsh, p, q - p); ++ if (!o) ++ { ++ set_fatal_syntax_error ++ ( _("unknown option to BTI")); ++ return PARSE_FAIL; ++ } ++ ++ switch (o->value) ++ { ++ /* Valid BTI operands. */ ++ case HINT_OPD_C: ++ case HINT_OPD_J: ++ case HINT_OPD_JC: ++ break; ++ ++ default: ++ set_syntax_error ++ (_("unknown option to BTI")); + return PARSE_FAIL; + } + +@@ -3909,21 +4175,26 @@ parse_barrier_psb (char **str, + */ + + static int +-parse_sys_reg (char **str, struct hash_control *sys_regs, +- int imple_defined_p, int pstatefield_p) ++parse_sys_reg (char **str, htab_t sys_regs, ++ int imple_defined_p, int pstatefield_p, ++ uint32_t* flags) + { + char *p, *q; +- char buf[32]; ++ char buf[AARCH64_MAX_SYSREG_NAME_LEN]; + const aarch64_sys_reg *o; + int value; + + p = buf; + for (q = *str; ISALNUM (*q) || *q == '_'; q++) +- if (p < buf + 31) ++ if (p < buf + (sizeof (buf) - 1)) + *p++ = TOLOWER (*q); + *p = '\0'; +- /* Assert that BUF be large enough. */ +- gas_assert (p - buf == q - *str); ++ ++ /* If the name is longer than AARCH64_MAX_SYSREG_NAME_LEN then it cannot be a ++ valid system register. This is enforced by construction of the hash ++ table. */ ++ if (p - buf != q - *str) ++ return PARSE_FAIL; + + o = hash_find (sys_regs, buf); + if (!o) +@@ -3941,6 +4212,8 @@ parse_sys_reg (char **str, struct hash_c + if (op0 > 3 || op1 > 7 || cn > 15 || cm > 15 || op2 > 7) + return PARSE_FAIL; + value = (op0 << 14) | (op1 << 11) | (cn << 7) | (cm << 3) | op2; ++ if (flags) ++ *flags = 0; + } + } + else +@@ -3948,13 +4221,17 @@ parse_sys_reg (char **str, struct hash_c + if (pstatefield_p && !aarch64_pstatefield_supported_p (cpu_variant, o)) + as_bad (_("selected processor does not support PSTATE field " + "name '%s'"), buf); +- if (!pstatefield_p && !aarch64_sys_reg_supported_p (cpu_variant, o)) ++ if (!pstatefield_p ++ && !aarch64_sys_ins_reg_supported_p (cpu_variant, o->name, ++ o->value, o->flags, o->features)) + as_bad (_("selected processor does not support system register " + "name '%s'"), buf); +- if (aarch64_sys_reg_deprecated_p (o)) ++ if (aarch64_sys_reg_deprecated_p (o->flags)) + as_warn (_("system register name '%s' is deprecated and may be " + "removed in a future release"), buf); + value = o->value; ++ if (flags) ++ *flags = o->flags; + } + + *str = q; +@@ -3965,25 +4242,35 @@ parse_sys_reg (char **str, struct hash_c + for the option, or NULL. */ + + static const aarch64_sys_ins_reg * +-parse_sys_ins_reg (char **str, struct hash_control *sys_ins_regs) ++parse_sys_ins_reg (char **str, htab_t sys_ins_regs) + { + char *p, *q; +- char buf[32]; ++ char buf[AARCH64_MAX_SYSREG_NAME_LEN]; + const aarch64_sys_ins_reg *o; + + p = buf; + for (q = *str; ISALNUM (*q) || *q == '_'; q++) +- if (p < buf + 31) ++ if (p < buf + (sizeof (buf) - 1)) + *p++ = TOLOWER (*q); + *p = '\0'; + ++ /* If the name is longer than AARCH64_MAX_SYSREG_NAME_LEN then it cannot be a ++ valid system register. This is enforced by construction of the hash ++ table. */ ++ if (p - buf != q - *str) ++ return NULL; ++ + o = hash_find (sys_ins_regs, buf); + if (!o) + return NULL; + +- if (!aarch64_sys_ins_reg_supported_p (cpu_variant, o)) ++ if (!aarch64_sys_ins_reg_supported_p (cpu_variant, ++ o->name, o->value, o->flags, 0)) + as_bad (_("selected processor does not support system register " + "name '%s'"), buf); ++ if (aarch64_sys_reg_deprecated_p (o->flags)) ++ as_warn (_("system register name '%s' is deprecated and may be " ++ "removed in a future release"), buf); + + *str = q; + return o; +@@ -4137,7 +4424,10 @@ reencode_movzn_to_movn (uint32_t opcode) + static fixS * + fix_new_aarch64 (fragS * frag, + int where, +- short int size, expressionS * exp, int pc_rel, int reloc) ++ short int size, ++ expressionS * exp, ++ int pc_rel, ++ int reloc) + { + fixS *new_fix; + +@@ -4371,6 +4661,7 @@ record_operand_error (const aarch64_opco + info.index = idx; + info.kind = kind; + info.error = error; ++ info.non_fatal = FALSE; + record_operand_error_info (opcode, &info); + } + +@@ -4386,6 +4677,7 @@ record_operand_error_with_data (const aa + info.data[0] = extra_data[0]; + info.data[1] = extra_data[1]; + info.data[2] = extra_data[2]; ++ info.non_fatal = FALSE; + record_operand_error_info (opcode, &info); + } + +@@ -4504,7 +4796,8 @@ print_operands (char *buf, const aarch64 + break; + + /* Generate the operand string in STR. */ +- aarch64_print_operand (str, sizeof (str), 0, opcode, opnds, i, NULL, NULL); ++ aarch64_print_operand (str, sizeof (str), 0, opcode, opnds, i, NULL, NULL, ++ NULL, cpu_variant); + + /* Delimiter. */ + if (str[0] != '\0') +@@ -4550,12 +4843,14 @@ output_operand_error_record (const opera + enum aarch64_opnd opd_code = (idx >= 0 ? opcode->operands[idx] + : AARCH64_OPND_NIL); + ++ typedef void (*handler_t)(const char *format, ...); ++ handler_t handler = detail->non_fatal ? as_warn : as_bad; ++ + switch (detail->kind) + { + case AARCH64_OPDE_NIL: + gas_assert (0); + break; +- + case AARCH64_OPDE_SYNTAX_ERROR: + case AARCH64_OPDE_RECOVERABLE: + case AARCH64_OPDE_FATAL_SYNTAX_ERROR: +@@ -4565,21 +4860,21 @@ output_operand_error_record (const opera + if (detail->error != NULL) + { + if (idx < 0) +- as_bad (_("%s -- `%s'"), detail->error, str); ++ handler (_("%s -- `%s'"), detail->error, str); + else +- as_bad (_("%s at operand %d -- `%s'"), +- detail->error, idx + 1, str); ++ handler (_("%s at operand %d -- `%s'"), ++ detail->error, idx + 1, str); + } + else + { + gas_assert (idx >= 0); +- as_bad (_("operand %d must be %s -- `%s'"), idx + 1, +- aarch64_get_operand_desc (opd_code), str); ++ handler (_("operand %d must be %s -- `%s'"), idx + 1, ++ aarch64_get_operand_desc (opd_code), str); + } + break; + + case AARCH64_OPDE_INVALID_VARIANT: +- as_bad (_("operand mismatch -- `%s'"), str); ++ handler (_("operand mismatch -- `%s'"), str); + if (verbose_error_p) + { + /* We will try to correct the erroneous instruction and also provide +@@ -4627,7 +4922,7 @@ output_operand_error_record (const opera + && programmer_friendly_fixup (&inst); + gas_assert (result); + result = aarch64_opcode_encode (opcode, inst_base, &inst_base->value, +- NULL, NULL); ++ NULL, NULL, insn_sequence); + gas_assert (!result); + + /* Find the most matched qualifier sequence. */ +@@ -4676,36 +4971,36 @@ output_operand_error_record (const opera + break; + + case AARCH64_OPDE_UNTIED_OPERAND: +- as_bad (_("operand %d must be the same register as operand 1 -- `%s'"), +- detail->index + 1, str); ++ handler (_("operand %d must be the same register as operand 1 -- `%s'"), ++ detail->index + 1, str); + break; + + case AARCH64_OPDE_OUT_OF_RANGE: + if (detail->data[0] != detail->data[1]) +- as_bad (_("%s out of range %d to %d at operand %d -- `%s'"), +- detail->error ? detail->error : _("immediate value"), +- detail->data[0], detail->data[1], idx + 1, str); ++ handler (_("%s out of range %d to %d at operand %d -- `%s'"), ++ detail->error ? detail->error : _("immediate value"), ++ detail->data[0], detail->data[1], idx + 1, str); + else +- as_bad (_("%s must be %d at operand %d -- `%s'"), +- detail->error ? detail->error : _("immediate value"), +- detail->data[0], idx + 1, str); ++ handler (_("%s must be %d at operand %d -- `%s'"), ++ detail->error ? detail->error : _("immediate value"), ++ detail->data[0], idx + 1, str); + break; + + case AARCH64_OPDE_REG_LIST: + if (detail->data[0] == 1) +- as_bad (_("invalid number of registers in the list; " +- "only 1 register is expected at operand %d -- `%s'"), +- idx + 1, str); ++ handler (_("invalid number of registers in the list; " ++ "only 1 register is expected at operand %d -- `%s'"), ++ idx + 1, str); + else +- as_bad (_("invalid number of registers in the list; " +- "%d registers are expected at operand %d -- `%s'"), +- detail->data[0], idx + 1, str); ++ handler (_("invalid number of registers in the list; " ++ "%d registers are expected at operand %d -- `%s'"), ++ detail->data[0], idx + 1, str); + break; + + case AARCH64_OPDE_UNALIGNED: +- as_bad (_("immediate value must be a multiple of " +- "%d at operand %d -- `%s'"), +- detail->data[0], idx + 1, str); ++ handler (_("immediate value must be a multiple of " ++ "%d at operand %d -- `%s'"), ++ detail->data[0], idx + 1, str); + break; + + default: +@@ -4719,10 +5014,15 @@ output_operand_error_record (const opera + When this function is called, the operand error information had + been collected for an assembly line and there will be multiple + errors in the case of multiple instruction templates; output the +- error message that most closely describes the problem. */ ++ error message that most closely describes the problem. ++ ++ The errors to be printed can be filtered on printing all errors ++ or only non-fatal errors. This distinction has to be made because ++ the error buffer may already be filled with fatal errors we don't want to ++ print due to the different instruction templates. */ + + static void +-output_operand_error_report (char *str) ++output_operand_error_report (char *str, bfd_boolean non_fatal_only) + { + int largest_error_pos; + const char *msg = NULL; +@@ -4740,9 +5040,14 @@ output_operand_error_report (char *str) + /* Only one error. */ + if (head == operand_error_report.tail) + { +- DEBUG_TRACE ("single opcode entry with error kind: %s", +- operand_mismatch_kind_names[head->detail.kind]); +- output_operand_error_record (head, str); ++ /* If the only error is a non-fatal one and we don't want to print it, ++ just exit. */ ++ if (!non_fatal_only || head->detail.non_fatal) ++ { ++ DEBUG_TRACE ("single opcode entry with error kind: %s", ++ operand_mismatch_kind_names[head->detail.kind]); ++ output_operand_error_record (head, str); ++ } + return; + } + +@@ -4753,16 +5058,21 @@ output_operand_error_report (char *str) + { + gas_assert (curr->detail.kind != AARCH64_OPDE_NIL); + DEBUG_TRACE ("\t%s", operand_mismatch_kind_names[curr->detail.kind]); +- if (operand_error_higher_severity_p (curr->detail.kind, kind)) ++ if (operand_error_higher_severity_p (curr->detail.kind, kind) ++ && (!non_fatal_only || (non_fatal_only && curr->detail.non_fatal))) + kind = curr->detail.kind; + } +- gas_assert (kind != AARCH64_OPDE_NIL); ++ ++ gas_assert (kind != AARCH64_OPDE_NIL || non_fatal_only); + + /* Pick up one of errors of KIND to report. */ + largest_error_pos = -2; /* Index can be -1 which means unknown index. */ + for (curr = head; curr != NULL; curr = curr->next) + { +- if (curr->detail.kind != kind) ++ /* If we don't want to print non-fatal errors then don't consider them ++ at all. */ ++ if (curr->detail.kind != kind ++ || (non_fatal_only && !curr->detail.non_fatal)) + continue; + /* If there are multiple errors, pick up the one with the highest + mismatching operand index. In the case of multiple errors with +@@ -4778,6 +5088,17 @@ output_operand_error_report (char *str) + } + } + ++ /* The way errors are collected in the back-end is a bit non-intuitive. But ++ essentially, because each operand template is tried recursively you may ++ always have errors collected from the previous tried OPND. These are ++ usually skipped if there is one successful match. However now with the ++ non-fatal errors we have to ignore those previously collected hard errors ++ when we're only interested in printing the non-fatal ones. This condition ++ prevents us from printing errors that are not appropriate, since we did ++ match a condition, but it also has warnings that it wants to print. */ ++ if (non_fatal_only && !record) ++ return; ++ + gas_assert (largest_error_pos != -2 && record != NULL); + DEBUG_TRACE ("Pick up error kind %s to report", + operand_mismatch_kind_names[record->detail.kind]); +@@ -4802,7 +5123,8 @@ get_aarch64_insn (char *buf) + { + unsigned char *where = (unsigned char *) buf; + uint32_t result; +- result = (where[0] | (where[1] << 8) | (where[2] << 16) | (where[3] << 24)); ++ result = ((where[0] | (where[1] << 8) | (where[2] << 16) ++ | ((uint32_t) where[3] << 24))); + return result; + } + +@@ -4957,6 +5279,10 @@ vectype_to_qualifier (const struct vecto + if (vectype->type == NT_b && vectype->width == 4) + return AARCH64_OPND_QLF_S_4B; + ++ /* Special case S_2H. */ ++ if (vectype->type == NT_h && vectype->width == 2) ++ return AARCH64_OPND_QLF_S_2H; ++ + /* Vector element register. */ + return AARCH64_OPND_QLF_S_B + vectype->type; + } +@@ -4989,7 +5315,7 @@ vectype_to_qualifier (const struct vecto + return offset; + } + +-vectype_conversion_fail: ++ vectype_conversion_fail: + first_error (_("bad vector arrangement type")); + return AARCH64_OPND_QLF_NIL; + } +@@ -5014,6 +5340,8 @@ process_omitted_operand (enum aarch64_op + case AARCH64_OPND_Rm: + case AARCH64_OPND_Rt: + case AARCH64_OPND_Rt2: ++ case AARCH64_OPND_Rt_LS64: ++ case AARCH64_OPND_Rt_SP: + case AARCH64_OPND_Rs: + case AARCH64_OPND_Ra: + case AARCH64_OPND_Rt_SYS: +@@ -5041,6 +5369,7 @@ process_omitted_operand (enum aarch64_op + case AARCH64_OPND_Ed: + case AARCH64_OPND_En: + case AARCH64_OPND_Em: ++ case AARCH64_OPND_Em16: + case AARCH64_OPND_SM3_IMM2: + operand->reglane.regno = default_value; + break; +@@ -5079,6 +5408,11 @@ process_omitted_operand (enum aarch64_op + + case AARCH64_OPND_BARRIER_ISB: + operand->barrier = aarch64_barrier_options + default_value; ++ break; ++ ++ case AARCH64_OPND_BTI_TARGET: ++ operand->hint_option = aarch64_hint_options + default_value; ++ break; + + default: + break; +@@ -5102,6 +5436,10 @@ process_movw_reloc_info (void) + case BFD_RELOC_AARCH64_MOVW_G0_S: + case BFD_RELOC_AARCH64_MOVW_G1_S: + case BFD_RELOC_AARCH64_MOVW_G2_S: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G0: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G1: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G2: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G3: + case BFD_RELOC_AARCH64_TLSGD_MOVW_G1: + case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G0: + case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G1: +@@ -5119,6 +5457,8 @@ process_movw_reloc_info (void) + case BFD_RELOC_AARCH64_MOVW_G0_NC: + case BFD_RELOC_AARCH64_MOVW_G0_S: + case BFD_RELOC_AARCH64_MOVW_GOTOFF_G0_NC: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G0: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G0_NC: + case BFD_RELOC_AARCH64_TLSDESC_OFF_G0_NC: + case BFD_RELOC_AARCH64_TLSGD_MOVW_G0_NC: + case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC: +@@ -5132,6 +5472,8 @@ process_movw_reloc_info (void) + case BFD_RELOC_AARCH64_MOVW_G1_NC: + case BFD_RELOC_AARCH64_MOVW_G1_S: + case BFD_RELOC_AARCH64_MOVW_GOTOFF_G1: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G1: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G1_NC: + case BFD_RELOC_AARCH64_TLSDESC_OFF_G1: + case BFD_RELOC_AARCH64_TLSGD_MOVW_G1: + case BFD_RELOC_AARCH64_TLSIE_MOVW_GOTTPREL_G1: +@@ -5144,6 +5486,8 @@ process_movw_reloc_info (void) + case BFD_RELOC_AARCH64_MOVW_G2: + case BFD_RELOC_AARCH64_MOVW_G2_NC: + case BFD_RELOC_AARCH64_MOVW_G2_S: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G2: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G2_NC: + case BFD_RELOC_AARCH64_TLSLD_MOVW_DTPREL_G2: + case BFD_RELOC_AARCH64_TLSLE_MOVW_TPREL_G2: + if (is32) +@@ -5156,6 +5500,7 @@ process_movw_reloc_info (void) + shift = 32; + break; + case BFD_RELOC_AARCH64_MOVW_G3: ++ case BFD_RELOC_AARCH64_MOVW_PREL_G3: + if (is32) + { + set_fatal_syntax_error +@@ -5202,7 +5547,7 @@ ldst_lo12_determine_real_reloc_type (voi + enum aarch64_opnd_qualifier opd0_qlf = inst.base.operands[0].qualifier; + enum aarch64_opnd_qualifier opd1_qlf = inst.base.operands[1].qualifier; + +- const bfd_reloc_code_real_type reloc_ldst_lo12[3][5] = { ++ const bfd_reloc_code_real_type reloc_ldst_lo12[5][5] = { + { + BFD_RELOC_AARCH64_LDST8_LO12, + BFD_RELOC_AARCH64_LDST16_LO12, +@@ -5223,13 +5568,31 @@ ldst_lo12_determine_real_reloc_type (voi + BFD_RELOC_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC, + BFD_RELOC_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC, + BFD_RELOC_AARCH64_NONE ++ }, ++ { ++ BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12, ++ BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12, ++ BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12, ++ BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12, ++ BFD_RELOC_AARCH64_NONE ++ }, ++ { ++ BFD_RELOC_AARCH64_TLSLE_LDST8_TPREL_LO12_NC, ++ BFD_RELOC_AARCH64_TLSLE_LDST16_TPREL_LO12_NC, ++ BFD_RELOC_AARCH64_TLSLE_LDST32_TPREL_LO12_NC, ++ BFD_RELOC_AARCH64_TLSLE_LDST64_TPREL_LO12_NC, ++ BFD_RELOC_AARCH64_NONE + } + }; + + gas_assert (inst.reloc.type == BFD_RELOC_AARCH64_LDST_LO12 + || inst.reloc.type == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12 + || (inst.reloc.type +- == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC)); ++ == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC) ++ || (inst.reloc.type ++ == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12) ++ || (inst.reloc.type ++ == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC)); + gas_assert (inst.base.opcode->operands[1] == AARCH64_OPND_ADDR_UIMM12); + + if (opd1_qlf == AARCH64_OPND_QLF_NIL) +@@ -5240,7 +5603,9 @@ ldst_lo12_determine_real_reloc_type (voi + + logsz = get_logsz (aarch64_get_qualifier_esize (opd1_qlf)); + if (inst.reloc.type == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12 +- || inst.reloc.type == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC) ++ || inst.reloc.type == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC ++ || inst.reloc.type == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12 ++ || inst.reloc.type == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC) + gas_assert (logsz <= 3); + else + gas_assert (logsz <= 4); +@@ -5345,14 +5710,31 @@ parse_operands (char *str, const aarch64 + case AARCH64_OPND_Rt2: + case AARCH64_OPND_Rs: + case AARCH64_OPND_Ra: ++ case AARCH64_OPND_Rt_LS64: + case AARCH64_OPND_Rt_SYS: + case AARCH64_OPND_PAIRREG: + case AARCH64_OPND_SVE_Rm: + po_int_reg_or_fail (REG_TYPE_R_Z); ++ ++ /* In LS64 load/store instructions Rt register number must be even ++ and <=22. */ ++ if (operands[i] == AARCH64_OPND_Rt_LS64) ++ { ++ /* We've already checked if this is valid register. ++ This will check if register number (Rt) is not undefined for LS64 ++ instructions: ++ if Rt<4:3> == '11' || Rt<0> == '1' then UNDEFINED. */ ++ if ((info->reg.regno & 0x18) == 0x18 || (info->reg.regno & 0x01) == 0x01) ++ { ++ set_syntax_error (_("invalid Rt register number in 64-byte load/store")); ++ goto failure; ++ } ++ } + break; + + case AARCH64_OPND_Rd_SP: + case AARCH64_OPND_Rn_SP: ++ case AARCH64_OPND_Rt_SP: + case AARCH64_OPND_SVE_Rn_SP: + case AARCH64_OPND_Rm_SP: + po_int_reg_or_fail (REG_TYPE_R_SP); +@@ -5477,6 +5859,8 @@ parse_operands (char *str, const aarch64 + + case AARCH64_OPND_SVE_Zm3_INDEX: + case AARCH64_OPND_SVE_Zm3_22_INDEX: ++ case AARCH64_OPND_SVE_Zm3_11_INDEX: ++ case AARCH64_OPND_SVE_Zm4_11_INDEX: + case AARCH64_OPND_SVE_Zm4_INDEX: + case AARCH64_OPND_SVE_Zn_INDEX: + reg_type = REG_TYPE_ZN; +@@ -5485,6 +5869,7 @@ parse_operands (char *str, const aarch64 + case AARCH64_OPND_Ed: + case AARCH64_OPND_En: + case AARCH64_OPND_Em: ++ case AARCH64_OPND_Em16: + case AARCH64_OPND_SM3_IMM2: + reg_type = REG_TYPE_VN; + vector_reg_index: +@@ -5533,11 +5918,20 @@ parse_operands (char *str, const aarch64 + val = parse_vector_reg_list (&str, reg_type, &vectype); + if (val == PARSE_FAIL) + goto failure; ++ + if (! reg_list_valid_p (val, /* accept_alternate */ 0)) + { + set_fatal_syntax_error (_("invalid register list")); + goto failure; + } ++ ++ if (vectype.width != 0 && *str != ',') ++ { ++ set_fatal_syntax_error ++ (_("expected element type rather than vector type")); ++ goto failure; ++ } ++ + info->reglist.first_regno = (val >> 2) & 0x1f; + info->reglist.num_regs = (val & 0x3) + 1; + } +@@ -5591,7 +5985,10 @@ parse_operands (char *str, const aarch64 + case AARCH64_OPND_CCMP_IMM: + case AARCH64_OPND_SIMM5: + case AARCH64_OPND_FBITS: ++ case AARCH64_OPND_TME_UIMM16: + case AARCH64_OPND_UIMM4: ++ case AARCH64_OPND_UIMM4_ADDG: ++ case AARCH64_OPND_UIMM10: + case AARCH64_OPND_UIMM3_OP1: + case AARCH64_OPND_UIMM3_OP2: + case AARCH64_OPND_IMM_VLSL: +@@ -5603,8 +6000,10 @@ parse_operands (char *str, const aarch64 + case AARCH64_OPND_SVE_LIMM_MOV: + case AARCH64_OPND_SVE_SHLIMM_PRED: + case AARCH64_OPND_SVE_SHLIMM_UNPRED: ++ case AARCH64_OPND_SVE_SHLIMM_UNPRED_22: + case AARCH64_OPND_SVE_SHRIMM_PRED: + case AARCH64_OPND_SVE_SHRIMM_UNPRED: ++ case AARCH64_OPND_SVE_SHRIMM_UNPRED_22: + case AARCH64_OPND_SVE_SIMM5: + case AARCH64_OPND_SVE_SIMM5B: + case AARCH64_OPND_SVE_SIMM6: +@@ -5618,6 +6017,7 @@ parse_operands (char *str, const aarch64 + case AARCH64_OPND_IMM_ROT3: + case AARCH64_OPND_SVE_IMM_ROT1: + case AARCH64_OPND_SVE_IMM_ROT2: ++ case AARCH64_OPND_SVE_IMM_ROT3: + po_imm_nc_or_fail (); + info->imm.value = val; + break; +@@ -5865,6 +6265,7 @@ parse_operands (char *str, const aarch64 + break; + + case AARCH64_OPND_EXCEPTION: ++ case AARCH64_OPND_UNDEFINED: + po_misc_or_fail (parse_immediate_expression (&str, &inst.reloc.exp, + imm_reg_type)); + assign_imm_if_const_or_fixup_later (&inst.reloc, info, +@@ -6062,6 +6463,8 @@ parse_operands (char *str, const aarch64 + + case AARCH64_OPND_ADDR_SIMM9: + case AARCH64_OPND_ADDR_SIMM9_2: ++ case AARCH64_OPND_ADDR_SIMM11: ++ case AARCH64_OPND_ADDR_SIMM13: + po_misc_or_fail (parse_address (&str, info)); + if (info->addr.pcrel || info->addr.offset.is_reg + || (!info->addr.preind && !info->addr.postind) +@@ -6116,7 +6519,11 @@ parse_operands (char *str, const aarch64 + || (inst.reloc.type + == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12) + || (inst.reloc.type +- == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC)) ++ == BFD_RELOC_AARCH64_TLSLD_LDST_DTPREL_LO12_NC) ++ || (inst.reloc.type ++ == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12) ++ || (inst.reloc.type ++ == BFD_RELOC_AARCH64_TLSLE_LDST_TPREL_LO12_NC)) + inst.reloc.type = ldst_lo12_determine_real_reloc_type (); + /* Leave qualifier to be determined by libopcodes. */ + break; +@@ -6144,6 +6551,7 @@ parse_operands (char *str, const aarch64 + break; + + case AARCH64_OPND_SVE_ADDR_RI_S4x16: ++ case AARCH64_OPND_SVE_ADDR_RI_S4x32: + case AARCH64_OPND_SVE_ADDR_RI_S4xVL: + case AARCH64_OPND_SVE_ADDR_RI_S4x2xVL: + case AARCH64_OPND_SVE_ADDR_RI_S4x3xVL: +@@ -6182,6 +6590,25 @@ parse_operands (char *str, const aarch64 + info->addr.offset.imm = inst.reloc.exp.X_add_number; + break; + ++ case AARCH64_OPND_SVE_ADDR_R: ++ /* [{, }] ++ but recognizing SVE registers. */ ++ po_misc_or_fail (parse_sve_address (&str, info, &base_qualifier, ++ &offset_qualifier)); ++ if (offset_qualifier == AARCH64_OPND_QLF_NIL) ++ { ++ offset_qualifier = AARCH64_OPND_QLF_X; ++ info->addr.offset.is_reg = 1; ++ info->addr.offset.regno = 31; ++ } ++ else if (base_qualifier != AARCH64_OPND_QLF_X ++ || offset_qualifier != AARCH64_OPND_QLF_X) ++ { ++ set_syntax_error (_("invalid addressing mode")); ++ goto failure; ++ } ++ goto regoff_addr; ++ + case AARCH64_OPND_SVE_ADDR_RR: + case AARCH64_OPND_SVE_ADDR_RR_LSL1: + case AARCH64_OPND_SVE_ADDR_RR_LSL2: +@@ -6228,6 +6655,33 @@ parse_operands (char *str, const aarch64 + info->qualifier = offset_qualifier; + goto regoff_addr; + ++ case AARCH64_OPND_SVE_ADDR_ZX: ++ /* [Zn.{, }]. */ ++ po_misc_or_fail (parse_sve_address (&str, info, &base_qualifier, ++ &offset_qualifier)); ++ /* Things to check: ++ base_qualifier either S_S or S_D ++ offset_qualifier must be X ++ */ ++ if ((base_qualifier != AARCH64_OPND_QLF_S_S ++ && base_qualifier != AARCH64_OPND_QLF_S_D) ++ || offset_qualifier != AARCH64_OPND_QLF_X) ++ { ++ set_syntax_error (_("invalid addressing mode")); ++ goto failure; ++ } ++ info->qualifier = base_qualifier; ++ if (!info->addr.offset.is_reg || info->addr.pcrel ++ || !info->addr.preind || info->addr.writeback ++ || info->shifter.operator_present != 0) ++ { ++ set_syntax_error (_("invalid addressing mode")); ++ goto failure; ++ } ++ info->shifter.kind = AARCH64_MOD_LSL; ++ break; ++ ++ + case AARCH64_OPND_SVE_ADDR_ZI_U5: + case AARCH64_OPND_SVE_ADDR_ZI_U5x2: + case AARCH64_OPND_SVE_ADDR_ZI_U5x4: +@@ -6269,17 +6723,21 @@ parse_operands (char *str, const aarch64 + goto regoff_addr; + + case AARCH64_OPND_SYSREG: +- if ((val = parse_sys_reg (&str, aarch64_sys_regs_hsh, 1, 0)) +- == PARSE_FAIL) +- { +- set_syntax_error (_("unknown or missing system register name")); +- goto failure; +- } +- inst.base.operands[i].sysreg = val; +- break; ++ { ++ uint32_t sysreg_flags; ++ if ((val = parse_sys_reg (&str, aarch64_sys_regs_hsh, 1, 0, ++ &sysreg_flags)) == PARSE_FAIL) ++ { ++ set_syntax_error (_("unknown or missing system register name")); ++ goto failure; ++ } ++ inst.base.operands[i].sysreg.value = val; ++ inst.base.operands[i].sysreg.flags = sysreg_flags; ++ break; ++ } + + case AARCH64_OPND_PSTATEFIELD: +- if ((val = parse_sys_reg (&str, aarch64_pstatefield_hsh, 0, 1)) ++ if ((val = parse_sys_reg (&str, aarch64_pstatefield_hsh, 0, 1, NULL)) + == PARSE_FAIL) + { + set_syntax_error (_("unknown or missing PSTATE field name")); +@@ -6292,18 +6750,26 @@ parse_operands (char *str, const aarch64 + inst.base.operands[i].sysins_op = + parse_sys_ins_reg (&str, aarch64_sys_regs_ic_hsh); + goto sys_reg_ins; ++ + case AARCH64_OPND_SYSREG_DC: + inst.base.operands[i].sysins_op = + parse_sys_ins_reg (&str, aarch64_sys_regs_dc_hsh); + goto sys_reg_ins; ++ + case AARCH64_OPND_SYSREG_AT: + inst.base.operands[i].sysins_op = + parse_sys_ins_reg (&str, aarch64_sys_regs_at_hsh); + goto sys_reg_ins; ++ ++ case AARCH64_OPND_SYSREG_SR: ++ inst.base.operands[i].sysins_op = ++ parse_sys_ins_reg (&str, aarch64_sys_regs_sr_hsh); ++ goto sys_reg_ins; ++ + case AARCH64_OPND_SYSREG_TLBI: + inst.base.operands[i].sysins_op = + parse_sys_ins_reg (&str, aarch64_sys_regs_tlbi_hsh); +-sys_reg_ins: ++ sys_reg_ins: + if (inst.base.operands[i].sysins_op == NULL) + { + set_fatal_syntax_error ( _("unknown or missing operation name")); +@@ -6324,12 +6790,53 @@ sys_reg_ins: + backtrack_pos = 0; + goto failure; + } ++ if (val != PARSE_FAIL ++ && operands[i] == AARCH64_OPND_BARRIER) ++ { ++ /* Regular barriers accept options CRm (C0-C15). ++ DSB nXS barrier variant accepts values > 15. */ ++ if (val < 0 || val > 15) ++ { ++ set_syntax_error (_("the specified option is not accepted in DSB")); ++ goto failure; ++ } ++ } + /* This is an extension to accept a 0..15 immediate. */ + if (val == PARSE_FAIL) + po_imm_or_fail (0, 15); + info->barrier = aarch64_barrier_options + val; + break; + ++ case AARCH64_OPND_BARRIER_DSB_NXS: ++ val = parse_barrier (&str); ++ if (val != PARSE_FAIL) ++ { ++ /* DSB nXS barrier variant accept only