diff --git a/0001-Plugin-target-handling.patch b/0001-Plugin-target-handling.patch new file mode 100644 index 0000000000000000000000000000000000000000..e80818440b79c2224131cefa81ff61eeae43df1b --- /dev/null +++ b/0001-Plugin-target-handling.patch @@ -0,0 +1,158 @@ +diff -rupN --no-dereference binutils-2.32/bfd/config.bfd binutils-2.32-new/bfd/config.bfd +--- binutils-2.32/bfd/config.bfd 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/config.bfd 2019-11-19 20:47:16.708676031 +0100 +@@ -217,11 +217,6 @@ esac + # convention, else the table becomes a real mess to understand and maintain. + + case "${targ}" in +- plugin) +- targ_defvec=plugin_vec +- targ_selvecs="plugin_vec" +- ;; +- + # START OF targmatch.h + #ifdef BFD64 + aarch64-*-darwin*) +diff -rupN --no-dereference binutils-2.32/bfd/configure binutils-2.32-new/bfd/configure +--- binutils-2.32/bfd/configure 2019-02-02 16:47:56.000000000 +0100 ++++ binutils-2.32-new/bfd/configure 2019-11-19 20:47:16.710676043 +0100 +@@ -12409,10 +12409,6 @@ else + fi + + +-if test "$plugins" = "yes"; then +- enable_targets="$enable_targets plugin" +-fi +- + # Check whether --enable-64-bit-bfd was given. + if test "${enable_64_bit_bfd+set}" = set; then : + enableval=$enable_64_bit_bfd; case "${enableval}" in +@@ -14580,12 +14576,12 @@ selarchs= + TDEFINES= + for targ in $target $canon_targets + do +- if test "x$targ" = "xall"; then ++ if test $targ = all; then + all_targets=true + assocvecs="$assocvecs $targ_defvec $targ_selvecs" +- else ++ elif test $targ != plugin; then + . $srcdir/config.bfd +- if test "x$targ" = "x$target"; then ++ if test $targ = $target; then + defvec=$targ_defvec + fi + selvecs="$selvecs $targ_defvec $targ_selvecs" +@@ -14820,7 +14816,6 @@ do + pef_xlib_vec) tb="$tb pef.lo" ;; + pj_elf32_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;; + pj_elf32_le_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;; +- plugin_vec) tb="$tb plugin.lo" ;; + powerpc_boot_vec) tb="$tb ppcboot.lo" ;; + powerpc_elf32_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; + powerpc_elf32_le_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; +@@ -14947,6 +14942,10 @@ do + fi + done + ++if test "$plugins" = "yes"; then ++ tb="$tb plugin.lo" ++fi ++ + # Target architecture .o files. + # A couple of CPUs use shorter file names to avoid problems on DOS + # filesystems. +diff -rupN --no-dereference binutils-2.32/bfd/configure.ac binutils-2.32-new/bfd/configure.ac +--- binutils-2.32/bfd/configure.ac 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/configure.ac 2019-11-19 20:47:16.710676043 +0100 +@@ -46,10 +46,6 @@ ACX_LARGEFILE + + AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes") + +-if test "$plugins" = "yes"; then +- enable_targets="$enable_targets plugin" +-fi +- + AC_ARG_ENABLE(64-bit-bfd, + [ --enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)], + [case "${enableval}" in +@@ -348,12 +344,12 @@ selarchs= + TDEFINES= + for targ in $target $canon_targets + do +- if test "x$targ" = "xall"; then ++ if test $targ = all; then + all_targets=true + assocvecs="$assocvecs $targ_defvec $targ_selvecs" +- else ++ elif test $targ != plugin; then + . $srcdir/config.bfd +- if test "x$targ" = "x$target"; then ++ if test $targ = $target; then + defvec=$targ_defvec + fi + selvecs="$selvecs $targ_defvec $targ_selvecs" +@@ -588,7 +584,6 @@ do + pef_xlib_vec) tb="$tb pef.lo" ;; + pj_elf32_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;; + pj_elf32_le_vec) tb="$tb elf32-pj.lo elf32.lo $elf" ;; +- plugin_vec) tb="$tb plugin.lo" ;; + powerpc_boot_vec) tb="$tb ppcboot.lo" ;; + powerpc_elf32_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; + powerpc_elf32_le_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; +@@ -715,6 +710,10 @@ do + fi + done + ++if test "$plugins" = "yes"; then ++ tb="$tb plugin.lo" ++fi ++ + # Target architecture .o files. + # A couple of CPUs use shorter file names to avoid problems on DOS + # filesystems. +diff -rupN --no-dereference binutils-2.32/bfd/format.c binutils-2.32-new/bfd/format.c +--- binutils-2.32/bfd/format.c 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/bfd/format.c 2019-11-19 20:47:16.710676043 +0100 +@@ -290,8 +290,15 @@ bfd_check_format_matches (bfd *abfd, bfd + { + const bfd_target *temp; + +- /* Don't check the default target twice. */ ++ /* The binary target matches anything, so don't return it when ++ searching. Don't match the plugin target if we have another ++ alternative since we want to properly set the input format ++ before allowing a plugin to claim the file. Also, don't ++ check the default target twice. */ + if (*target == &binary_vec ++#if BFD_SUPPORTS_PLUGINS ++ || (match_count != 0 && *target == &plugin_vec) ++#endif + || (!abfd->target_defaulted && *target == save_targ)) + continue; + +diff -rupN --no-dereference binutils-2.32/bfd/targets.c binutils-2.32-new/bfd/targets.c +--- binutils-2.32/bfd/targets.c 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/bfd/targets.c 2019-11-19 20:47:16.711676049 +0100 +@@ -1142,10 +1142,6 @@ static const bfd_target * const _bfd_tar + &pj_elf32_vec, + &pj_elf32_le_vec, + +-#if BFD_SUPPORTS_PLUGINS +- &plugin_vec, +-#endif +- + &powerpc_boot_vec, + &powerpc_elf32_vec, + &powerpc_elf32_le_vec, +@@ -1298,6 +1294,10 @@ static const bfd_target * const _bfd_tar + /* Likewise for ihex. */ + &ihex_vec, + ++#if BFD_SUPPORTS_PLUGINS ++ &plugin_vec, ++#endif ++ + /* Add any required traditional-core-file-handler. */ + + #ifdef AIX386_CORE diff --git a/binutils-2.22.52.0.4-no-config-h-check.patch b/binutils-2.22.52.0.4-no-config-h-check.patch new file mode 100644 index 0000000000000000000000000000000000000000..caf99ddf923e5851ddf9c4382ab51e7edd56722f --- /dev/null +++ b/binutils-2.22.52.0.4-no-config-h-check.patch @@ -0,0 +1,30 @@ +diff -rupN --no-dereference binutils-2.32/bfd/bfd-in2.h binutils-2.32-new/bfd/bfd-in2.h +--- binutils-2.32/bfd/bfd-in2.h 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/bfd-in2.h 2019-11-19 20:46:59.623577944 +0100 +@@ -30,11 +30,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 -rupN --no-dereference binutils-2.32/bfd/bfd-in.h binutils-2.32-new/bfd/bfd-in.h +--- binutils-2.32/bfd/bfd-in.h 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/bfd-in.h 2019-11-19 20:46:59.622577938 +0100 +@@ -23,11 +23,6 @@ + #ifndef __BFD_H_SEEN__ + #define __BFD_H_SEEN__ + +-/* PR 14072: Ensure that config.h is included first. */ +-#if !defined PACKAGE && !defined PACKAGE_VERSION +-#error config.h must be included before this header +-#endif +- + #ifdef __cplusplus + extern "C" { + #endif diff --git a/binutils-2.25-version.patch b/binutils-2.25-version.patch new file mode 100644 index 0000000000000000000000000000000000000000..fb1f2210612a6d5219aedec5fbd68bc891df0f4c --- /dev/null +++ b/binutils-2.25-version.patch @@ -0,0 +1,46 @@ +diff -rupN --no-dereference binutils-2.32/bfd/Makefile.am binutils-2.32-new/bfd/Makefile.am +--- binutils-2.32/bfd/Makefile.am 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/Makefile.am 2019-11-19 20:46:58.072569411 +0100 +@@ -953,8 +953,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 ;\ +@@ -965,7 +965,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 -rupN --no-dereference binutils-2.32/bfd/Makefile.in binutils-2.32-new/bfd/Makefile.in +--- binutils-2.32/bfd/Makefile.in 2019-02-02 16:47:56.000000000 +0100 ++++ binutils-2.32-new/bfd/Makefile.in 2019-11-19 20:46:58.072569411 +0100 +@@ -2068,8 +2068,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 ;\ +@@ -2080,7 +2080,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/binutils-2.29-filename-in-error-messages.patch b/binutils-2.29-filename-in-error-messages.patch new file mode 100644 index 0000000000000000000000000000000000000000..be81ecaa505d38c06f7aa8827575cdf9e39764f1 --- /dev/null +++ b/binutils-2.29-filename-in-error-messages.patch @@ -0,0 +1,125 @@ +diff -rupN --no-dereference binutils-2.32/binutils/readelf.c binutils-2.32-new/binutils/readelf.c +--- binutils-2.32/binutils/readelf.c 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/binutils/readelf.c 2019-11-19 20:47:00.396582218 +0100 +@@ -19642,75 +19642,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/binutils-2.32.tar.bz2 b/binutils-2.32.tar.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..69a3d774ddcec7de7a5f8c4d886c07a744666608 Binary files /dev/null and b/binutils-2.32.tar.bz2 differ diff --git a/binutils-CVE-2019-1010204.patch b/binutils-CVE-2019-1010204.patch new file mode 100644 index 0000000000000000000000000000000000000000..fa3a2502ffd1ef63428dd429af93e8f25d4eb9e1 --- /dev/null +++ b/binutils-CVE-2019-1010204.patch @@ -0,0 +1,16 @@ +diff -rupN --no-dereference binutils-2.32/gold/fileread.cc binutils-2.32-new/gold/fileread.cc +--- binutils-2.32/gold/fileread.cc 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/gold/fileread.cc 2019-11-19 20:47:14.475662786 +0100 +@@ -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/binutils-CVE-2019-14250.patch b/binutils-CVE-2019-14250.patch new file mode 100644 index 0000000000000000000000000000000000000000..aa4c8fc3057a5709b877c188084c369d0528e179 --- /dev/null +++ b/binutils-CVE-2019-14250.patch @@ -0,0 +1,18 @@ +diff -rupN --no-dereference binutils-2.32/libiberty/simple-object-elf.c binutils-2.32-new/libiberty/simple-object-elf.c +--- binutils-2.32/libiberty/simple-object-elf.c 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/libiberty/simple-object-elf.c 2019-11-19 20:47:15.208667119 +0100 +@@ -549,6 +549,14 @@ simple_object_elf_match (unsigned char h + return NULL; + } + ++ if (eor->shstrndx == 0) ++ { ++ *errmsg = "invalid ELF shstrndx == 0"; ++ *err = 0; ++ XDELETE (eor); ++ return NULL; ++ } ++ + return (void *) eor; + } + diff --git a/binutils-CVE-2019-14444.patch b/binutils-CVE-2019-14444.patch new file mode 100644 index 0000000000000000000000000000000000000000..1a869acc5924e70ccdfab88f8731691dd577f75d --- /dev/null +++ b/binutils-CVE-2019-14444.patch @@ -0,0 +1,12 @@ +diff -rupN --no-dereference binutils-2.32/binutils/readelf.c binutils-2.32-new/binutils/readelf.c +--- binutils-2.32/binutils/readelf.c 2019-11-19 20:47:07.833624139 +0100 ++++ binutils-2.32-new/binutils/readelf.c 2019-11-19 20:47:15.941671465 +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/binutils-CVE-2019-9071.patch b/binutils-CVE-2019-9071.patch new file mode 100644 index 0000000000000000000000000000000000000000..e50676bfb7bf154e427ed9d03738a4e984cf0533 --- /dev/null +++ b/binutils-CVE-2019-9071.patch @@ -0,0 +1,111 @@ +diff -rupN --no-dereference binutils-2.32/libiberty/cp-demangle.c binutils-2.32-new/libiberty/cp-demangle.c +--- binutils-2.32/libiberty/cp-demangle.c 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/libiberty/cp-demangle.c 2019-11-19 20:47:08.574628396 +0100 +@@ -861,7 +861,7 @@ CP_STATIC_IF_GLIBCPP_V3 + int + cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len) + { +- if (p == NULL || s == NULL || len == 0) ++ if (p == NULL || s == NULL || len <= 0) + return 0; + p->d_printing = 0; + p->type = DEMANGLE_COMPONENT_NAME; +@@ -4055,7 +4055,7 @@ d_growable_string_callback_adapter (cons + are larger than the actual numbers encountered. */ + + static void +-d_count_templates_scopes (int *num_templates, int *num_scopes, ++d_count_templates_scopes (struct d_print_info *dpi, + const struct demangle_component *dc) + { + if (dc == NULL) +@@ -4075,13 +4075,13 @@ d_count_templates_scopes (int *num_templ + break; + + case DEMANGLE_COMPONENT_TEMPLATE: +- (*num_templates)++; ++ dpi->num_copy_templates++; + goto recurse_left_right; + + case DEMANGLE_COMPONENT_REFERENCE: + case DEMANGLE_COMPONENT_RVALUE_REFERENCE: + if (d_left (dc)->type == DEMANGLE_COMPONENT_TEMPLATE_PARAM) +- (*num_scopes)++; ++ dpi->num_saved_scopes++; + goto recurse_left_right; + + case DEMANGLE_COMPONENT_QUAL_NAME: +@@ -4146,42 +4146,42 @@ d_count_templates_scopes (int *num_templ + case DEMANGLE_COMPONENT_TAGGED_NAME: + case DEMANGLE_COMPONENT_CLONE: + recurse_left_right: +- d_count_templates_scopes (num_templates, num_scopes, +- d_left (dc)); +- d_count_templates_scopes (num_templates, num_scopes, +- d_right (dc)); ++ /* PR 89394 - Check for too much recursion. */ ++ if (dpi->recursion > DEMANGLE_RECURSION_LIMIT) ++ /* FIXME: There ought to be a way to report to the ++ user that the recursion limit has been reached. */ ++ return; ++ ++ ++ dpi->recursion; ++ d_count_templates_scopes (dpi, d_left (dc)); ++ d_count_templates_scopes (dpi, d_right (dc)); ++ -- dpi->recursion; + break; + + case DEMANGLE_COMPONENT_CTOR: +- d_count_templates_scopes (num_templates, num_scopes, +- dc->u.s_ctor.name); ++ d_count_templates_scopes (dpi, dc->u.s_ctor.name); + break; + + case DEMANGLE_COMPONENT_DTOR: +- d_count_templates_scopes (num_templates, num_scopes, +- dc->u.s_dtor.name); ++ d_count_templates_scopes (dpi, dc->u.s_dtor.name); + break; + + case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: +- d_count_templates_scopes (num_templates, num_scopes, +- dc->u.s_extended_operator.name); ++ d_count_templates_scopes (dpi, dc->u.s_extended_operator.name); + break; + + case DEMANGLE_COMPONENT_FIXED_TYPE: +- d_count_templates_scopes (num_templates, num_scopes, +- dc->u.s_fixed.length); ++ d_count_templates_scopes (dpi, dc->u.s_fixed.length); + break; + + case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: + case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: +- d_count_templates_scopes (num_templates, num_scopes, +- d_left (dc)); ++ d_count_templates_scopes (dpi, d_left (dc)); + break; + + case DEMANGLE_COMPONENT_LAMBDA: + case DEMANGLE_COMPONENT_DEFAULT_ARG: +- d_count_templates_scopes (num_templates, num_scopes, +- dc->u.s_unary_num.sub); ++ d_count_templates_scopes (dpi, dc->u.s_unary_num.sub); + break; + } + } +@@ -4216,8 +4216,12 @@ d_print_init (struct d_print_info *dpi, + dpi->next_copy_template = 0; + dpi->num_copy_templates = 0; + +- d_count_templates_scopes (&dpi->num_copy_templates, +- &dpi->num_saved_scopes, dc); ++ d_count_templates_scopes (dpi, dc); ++ /* If we did not reach the recursion limit, then reset the ++ current recursion value back to 0, so that we can print ++ the templates. */ ++ if (dpi->recursion < DEMANGLE_RECURSION_LIMIT) ++ dpi->recursion = 0; + dpi->num_copy_templates *= dpi->num_saved_scopes; + + dpi->current_template = NULL; diff --git a/binutils-CVE-2019-9073.patch b/binutils-CVE-2019-9073.patch new file mode 100644 index 0000000000000000000000000000000000000000..b4608283ed6194f29d3a9f0a2e8da23d84cbd35e --- /dev/null +++ b/binutils-CVE-2019-9073.patch @@ -0,0 +1,14 @@ +diff -rupN --no-dereference binutils-2.32/binutils/objdump.c binutils-2.32-new/binutils/objdump.c +--- binutils-2.32/binutils/objdump.c 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/binutils/objdump.c 2019-11-19 20:47:04.839607089 +0100 +@@ -3178,7 +3178,9 @@ dump_bfd_header (bfd *abfd) + static void + dump_bfd_private_header (bfd *abfd) + { +- bfd_print_private_bfd_data (abfd, stdout); ++ if (!bfd_print_private_bfd_data (abfd, stdout)) ++ non_fatal (_("warning: private headers incomplete: %s"), ++ bfd_errmsg (bfd_get_error ())); + } + + static void diff --git a/binutils-CVE-2019-9074.patch b/binutils-CVE-2019-9074.patch new file mode 100644 index 0000000000000000000000000000000000000000..ef46e3c5508aa6a455bd10a83d85f6ce783caf39 --- /dev/null +++ b/binutils-CVE-2019-9074.patch @@ -0,0 +1,33 @@ +diff -rupN --no-dereference binutils-2.32/bfd/pei-x86_64.c binutils-2.32-new/bfd/pei-x86_64.c +--- binutils-2.32/bfd/pei-x86_64.c 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/bfd/pei-x86_64.c 2019-11-19 20:47:05.573611249 +0100 +@@ -541,7 +541,7 @@ pex64_bfd_print_pdata_section (bfd *abfd + /* virt_size might be zero for objects. */ + if (stop == 0 && strcmp (abfd->xvec->name, "pe-x86-64") == 0) + { +- stop = (datasize / onaline) * onaline; ++ stop = datasize; + virt_size_is_zero = TRUE; + } + else if (datasize < stop) +@@ -551,8 +551,8 @@ pex64_bfd_print_pdata_section (bfd *abfd + _("Warning: %s section size (%ld) is smaller than virtual size (%ld)\n"), + pdata_section->name, (unsigned long) datasize, + (unsigned long) stop); +- /* Be sure not to read passed datasize. */ +- stop = datasize / onaline; ++ /* Be sure not to read past datasize. */ ++ stop = datasize; + } + + /* Display functions table. */ +@@ -724,8 +724,7 @@ pex64_bfd_print_pdata_section (bfd *abfd + altent += imagebase; + + if (altent >= pdata_vma +- && (altent + PDATA_ROW_SIZE <= pdata_vma +- + pei_section_data (abfd, pdata_section)->virt_size)) ++ && altent - pdata_vma + PDATA_ROW_SIZE <= stop) + { + pex64_get_runtime_function + (abfd, &arf, &pdata[altent - pdata_vma]); diff --git a/binutils-CVE-2019-9075.patch b/binutils-CVE-2019-9075.patch new file mode 100644 index 0000000000000000000000000000000000000000..5f116210011895ce1a1b369df3509088c09ed64a --- /dev/null +++ b/binutils-CVE-2019-9075.patch @@ -0,0 +1,73 @@ +diff -rupN --no-dereference binutils-2.32/bfd/archive64.c binutils-2.32-new/bfd/archive64.c +--- binutils-2.32/bfd/archive64.c 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/archive64.c 2019-11-19 20:47:06.349615660 +0100 +@@ -100,8 +100,6 @@ _bfd_archive_64_bit_slurp_armap (bfd *ab + return FALSE; + carsyms = ardata->symdefs; + stringbase = ((char *) ardata->symdefs) + carsym_size; +- stringbase[stringsize] = 0; +- stringend = stringbase + stringsize; + + raw_armap = (bfd_byte *) bfd_alloc (abfd, ptrsize); + if (raw_armap == NULL) +@@ -115,15 +113,17 @@ _bfd_archive_64_bit_slurp_armap (bfd *ab + goto release_raw_armap; + } + ++ stringend = stringbase + stringsize; ++ *stringend = 0; + for (i = 0; i < nsymz; i++) + { + carsyms->file_offset = bfd_getb64 (raw_armap + i * 8); + carsyms->name = stringbase; +- if (stringbase < stringend) +- stringbase += strlen (stringbase) + 1; ++ stringbase += strlen (stringbase); ++ if (stringbase != stringend) ++ ++stringbase; + ++carsyms; + } +- *stringbase = '\0'; + + ardata->symdef_count = nsymz; + ardata->first_file_filepos = bfd_tell (abfd); +diff -rupN --no-dereference binutils-2.32/bfd/archive.c binutils-2.32-new/bfd/archive.c +--- binutils-2.32/bfd/archive.c 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/archive.c 2019-11-19 20:47:06.350615666 +0100 +@@ -1012,6 +1012,7 @@ do_slurp_coff_armap (bfd *abfd) + int *raw_armap, *rawptr; + struct artdata *ardata = bfd_ardata (abfd); + char *stringbase; ++ char *stringend; + bfd_size_type stringsize; + bfd_size_type parsed_size; + carsym *carsyms; +@@ -1071,22 +1072,20 @@ do_slurp_coff_armap (bfd *abfd) + } + + /* OK, build the carsyms. */ +- for (i = 0; i < nsymz && stringsize > 0; i++) ++ stringend = stringbase + stringsize; ++ *stringend = 0; ++ for (i = 0; i < nsymz; i++) + { + bfd_size_type len; + + rawptr = raw_armap + i; + carsyms->file_offset = swap ((bfd_byte *) rawptr); + carsyms->name = stringbase; +- /* PR 17512: file: 4a1d50c1. */ +- len = strnlen (stringbase, stringsize); +- if (len < stringsize) +- len ++; +- stringbase += len; +- stringsize -= len; ++ stringbase += strlen (stringbase); ++ if (stringbase != stringend) ++ ++stringbase; + carsyms++; + } +- *stringbase = 0; + + ardata->symdef_count = nsymz; + ardata->first_file_filepos = bfd_tell (abfd); diff --git a/binutils-CVE-2019-9077.patch b/binutils-CVE-2019-9077.patch new file mode 100644 index 0000000000000000000000000000000000000000..19e57bfbf9677d40cc20ef39efb1a5aa453c0de5 --- /dev/null +++ b/binutils-CVE-2019-9077.patch @@ -0,0 +1,17 @@ +diff -rupN --no-dereference binutils-2.32/binutils/readelf.c binutils-2.32-new/binutils/readelf.c +--- binutils-2.32/binutils/readelf.c 2019-11-19 20:47:01.883590484 +0100 ++++ binutils-2.32-new/binutils/readelf.c 2019-11-19 20:47:07.105619971 +0100 +@@ -16200,6 +16200,13 @@ process_mips_specific (Filedata * fileda + return FALSE; + } + ++ /* PR 24243 */ ++ if (sect->sh_size < sizeof (* eopt)) ++ { ++ error (_("The MIPS options section is too small.\n")); ++ return FALSE; ++ } ++ + eopt = (Elf_External_Options *) get_data (NULL, filedata, options_offset, 1, + sect->sh_size, _("options")); + if (eopt) diff --git a/binutils-aarch64-gold-PLT-for-MOVW_ABS.patch b/binutils-aarch64-gold-PLT-for-MOVW_ABS.patch new file mode 100644 index 0000000000000000000000000000000000000000..81413074c0ef9fb03e7ca98650eff1781f83056f --- /dev/null +++ b/binutils-aarch64-gold-PLT-for-MOVW_ABS.patch @@ -0,0 +1,21 @@ +diff -rupN --no-dereference binutils-2.32/gold/aarch64.cc binutils-2.32-new/gold/aarch64.cc +--- binutils-2.32/gold/aarch64.cc 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/gold/aarch64.cc 2019-11-19 20:47:09.316632670 +0100 +@@ -6496,6 +6496,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 --git a/binutils-disassembling-efi-files.patch b/binutils-disassembling-efi-files.patch new file mode 100644 index 0000000000000000000000000000000000000000..cfa3664546622e33caf56b39e01e0ea7dec4f425 --- /dev/null +++ b/binutils-disassembling-efi-files.patch @@ -0,0 +1,37 @@ +diff -rupN --no-dereference binutils-2.32/bfd/coffgen.c binutils-2.32-new/bfd/coffgen.c +--- binutils-2.32/bfd/coffgen.c 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/coffgen.c 2019-11-19 20:47:07.835624150 +0100 +@@ -2294,7 +2294,7 @@ coff_find_nearest_line_with_names (bfd * + information. So try again, using a bias against the address sought. */ + if (coff_data (abfd)->dwarf2_find_line_info != NULL) + { +- bfd_signed_vma bias; ++ bfd_signed_vma bias = 0; + + /* Create a cache of the result for the next call. */ + if (sec_data == NULL && section->owner == abfd) +@@ -2306,10 +2306,11 @@ coff_find_nearest_line_with_names (bfd * + + if (sec_data != NULL && sec_data->saved_bias) + bias = sec_data->saved_bias; +- else ++ else if (symbols) + { + bias = _bfd_dwarf2_find_symbol_bias (symbols, + & coff_data (abfd)->dwarf2_find_line_info); ++ + if (sec_data) + { + sec_data->saved_bias = TRUE; +diff -rupN --no-dereference binutils-2.32/bfd/dwarf2.c binutils-2.32-new/bfd/dwarf2.c +--- binutils-2.32/bfd/dwarf2.c 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/dwarf2.c 2019-11-19 20:47:07.836624156 +0100 +@@ -4472,7 +4472,7 @@ _bfd_dwarf2_find_symbol_bias (asymbol ** + + stash = (struct dwarf2_debug *) *pinfo; + +- if (stash == NULL) ++ if (stash == NULL || symbols == NULL) + return 0; + + for (unit = stash->all_comp_units; unit; unit = unit->next_unit) diff --git a/binutils-do-not-link-with-static-libstdc++.patch b/binutils-do-not-link-with-static-libstdc++.patch new file mode 100644 index 0000000000000000000000000000000000000000..c04b22847220d2391f9dcc7142b429572b2ff0cc --- /dev/null +++ b/binutils-do-not-link-with-static-libstdc++.patch @@ -0,0 +1,83 @@ +diff -rupN --no-dereference binutils-2.32/configure binutils-2.32-new/configure +--- binutils-2.32/configure 2019-01-19 17:10:54.000000000 +0100 ++++ binutils-2.32-new/configure 2019-11-19 20:47:01.887590506 +0100 +@@ -5049,49 +5049,6 @@ if test -z "$LD"; then + fi + fi + +-# Check whether -static-libstdc++ -static-libgcc is supported. +-have_static_libs=no +-if test "$GCC" = yes; then +- saved_LDFLAGS="$LDFLAGS" +- +- LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc" +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether g++ accepts -static-libstdc++ -static-libgcc" >&5 +-$as_echo_n "checking whether g++ accepts -static-libstdc++ -static-libgcc... " >&6; } +- ac_ext=cpp +-ac_cpp='$CXXCPP $CPPFLAGS' +-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +- +- +-cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +- +-#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) +-#error -static-libstdc++ not implemented +-#endif +-int main() {} +-_ACEOF +-if ac_fn_cxx_try_link "$LINENO"; then : +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +-$as_echo "yes" >&6; }; have_static_libs=yes +-else +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +-$as_echo "no" >&6; } +-fi +-rm -f core conftest.err conftest.$ac_objext \ +- conftest$ac_exeext conftest.$ac_ext +- ac_ext=c +-ac_cpp='$CPP $CPPFLAGS' +-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +-ac_compiler_gnu=$ac_cv_c_compiler_gnu +- +- +- LDFLAGS="$saved_LDFLAGS" +-fi +- +- + + + if test -n "$ac_tool_prefix"; then +diff -rupN --no-dereference binutils-2.32/configure.ac binutils-2.32-new/configure.ac +--- binutils-2.32/configure.ac 2019-02-02 17:15:43.000000000 +0100 ++++ binutils-2.32-new/configure.ac 2019-11-19 20:47:01.887590506 +0100 +@@ -1283,26 +1283,6 @@ if test -z "$LD"; then + fi + fi + +-# Check whether -static-libstdc++ -static-libgcc is supported. +-have_static_libs=no +-if test "$GCC" = yes; then +- saved_LDFLAGS="$LDFLAGS" +- +- LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc" +- AC_MSG_CHECKING([whether g++ accepts -static-libstdc++ -static-libgcc]) +- AC_LANG_PUSH(C++) +- AC_LINK_IFELSE([AC_LANG_SOURCE([ +-#if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) +-#error -static-libstdc++ not implemented +-#endif +-int main() {}])], +- [AC_MSG_RESULT([yes]); have_static_libs=yes], +- [AC_MSG_RESULT([no])]) +- AC_LANG_POP(C++) +- +- LDFLAGS="$saved_LDFLAGS" +-fi +- + ACX_PROG_GNAT + ACX_PROG_CMP_IGNORE_INITIAL + diff --git a/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch b/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch new file mode 100644 index 0000000000000000000000000000000000000000..d8c78a7ec48161b86d032dc56ec3b8d4681aa11b --- /dev/null +++ b/binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch @@ -0,0 +1,19 @@ +diff -rupN --no-dereference binutils-2.32/ld/emultempl/elf32.em binutils-2.32-new/ld/emultempl/elf32.em +--- binutils-2.32/ld/emultempl/elf32.em 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/ld/emultempl/elf32.em 2019-11-19 20:47:12.267649813 +0100 +@@ -2029,10 +2029,12 @@ elf_orphan_compatible (asection *in, ase + if (elf_section_data (out)->this_hdr.sh_info + != elf_section_data (in)->this_hdr.sh_info) + return FALSE; +- /* We can't merge two sections with differing SHF_EXCLUDE when doing +- a relocatable link. */ ++ /* We can't merge with member of output section group nor merge two ++ sections with differing SHF_EXCLUDE when doing a relocatable link. */ + if (bfd_link_relocatable (&link_info) +- && ((elf_section_flags (out) ^ elf_section_flags (in)) & SHF_EXCLUDE) != 0) ++ && (elf_next_in_group (out) != NULL ++ || ((elf_section_flags (out) ^ elf_section_flags (in)) ++ & SHF_EXCLUDE) != 0)) + return FALSE; + return _bfd_elf_match_sections_by_type (link_info.output_bfd, out, + in->owner, in); diff --git a/binutils-do-not-warn-about-debuginfo-files.patch b/binutils-do-not-warn-about-debuginfo-files.patch new file mode 100644 index 0000000000000000000000000000000000000000..367430ead0bdfe9fe47256eee2a85d55847542a1 --- /dev/null +++ b/binutils-do-not-warn-about-debuginfo-files.patch @@ -0,0 +1,66 @@ +diff -rupN --no-dereference binutils-2.32/bfd/elf-bfd.h binutils-2.32-new/bfd/elf-bfd.h +--- binutils-2.32/bfd/elf-bfd.h 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/elf-bfd.h 2019-11-19 20:47:11.528645500 +0100 +@@ -2749,6 +2749,8 @@ extern bfd_vma elf64_r_sym (bfd_vma); + extern bfd_vma elf32_r_info (bfd_vma, bfd_vma); + extern bfd_vma elf32_r_sym (bfd_vma); + ++extern bfd_boolean is_debuginfo_file (bfd *); ++ + /* Large common section. */ + extern asection _bfd_elf_large_com_section; + +diff -rupN --no-dereference binutils-2.32/bfd/elf.c binutils-2.32-new/bfd/elf.c +--- binutils-2.32/bfd/elf.c 2019-11-19 20:47:04.094602882 +0100 ++++ binutils-2.32-new/bfd/elf.c 2019-11-19 20:47:11.530645511 +0100 +@@ -5807,6 +5807,35 @@ assign_file_positions_for_load_sections + return TRUE; + } + ++/* Determine if a bfd is a debuginfo file. Unfortunately there ++ is no defined method for detecting such files, so we have to ++ use heuristics instead. */ ++ ++bfd_boolean ++is_debuginfo_file (bfd *abfd) ++{ ++ if (abfd == NULL || bfd_get_flavour (abfd) != bfd_target_elf_flavour) ++ return FALSE; ++ ++ Elf_Internal_Shdr **start_headers = elf_elfsections (abfd); ++ Elf_Internal_Shdr **end_headers = start_headers + elf_numsections (abfd); ++ Elf_Internal_Shdr **headerp; ++ ++ for (headerp = start_headers; headerp < end_headers; headerp ++) ++ { ++ Elf_Internal_Shdr *header = * headerp; ++ ++ /* Debuginfo files do not have any allocated SHT_PROGBITS sections. ++ The only allocated sections are SHT_NOBITS or SHT_NOTES. */ ++ if ((header->sh_flags & SHF_ALLOC) == SHF_ALLOC ++ && header->sh_type != SHT_NOBITS ++ && header->sh_type != SHT_NOTE) ++ return FALSE; ++ } ++ ++ return TRUE; ++} ++ + /* Assign file positions for the other sections. */ + + static bfd_boolean +@@ -5840,7 +5869,13 @@ assign_file_positions_for_non_load_secti + BFD_ASSERT (hdr->sh_offset == hdr->bfd_section->filepos); + else if ((hdr->sh_flags & SHF_ALLOC) != 0) + { +- if (hdr->sh_size != 0) ++ if (hdr->sh_size != 0 ++ /* PR 24717 - debuginfo files are known to be not strictly ++ compliant with the ELF standard. In particular they often ++ have .note.gnu.property sections that are outside of any ++ loadable segment. This is not a problem for such files, ++ so do not warn about them. */ ++ && ! is_debuginfo_file (abfd)) + _bfd_error_handler + /* xgettext:c-format */ + (_("%pB: warning: allocated section `%s' not in segment"), diff --git a/binutils-export-demangle.h.patch b/binutils-export-demangle.h.patch new file mode 100644 index 0000000000000000000000000000000000000000..1b8b2822c2443a523eeae2e3c892cbfa708845c5 --- /dev/null +++ b/binutils-export-demangle.h.patch @@ -0,0 +1,33 @@ +diff -rupN --no-dereference binutils-2.32/bfd/Makefile.am binutils-2.32-new/bfd/Makefile.am +--- binutils-2.32/bfd/Makefile.am 2019-11-19 20:46:58.862573749 +0100 ++++ binutils-2.32-new/bfd/Makefile.am 2019-11-19 20:46:58.865573765 +0100 +@@ -33,7 +33,7 @@ bfdlibdir = @bfdlibdir@ + bfdincludedir = @bfdincludedir@ + bfdlib_LTLIBRARIES = libbfd.la + bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \ +- bfd_stdint.h $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h ++ bfd_stdint.h $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h + else !INSTALL_LIBBFD + # Empty these so that the respective installation directories will not be created. + bfdlibdir = +diff -rupN --no-dereference binutils-2.32/bfd/Makefile.in binutils-2.32-new/bfd/Makefile.in +--- binutils-2.32/bfd/Makefile.in 2019-11-19 20:46:58.863573754 +0100 ++++ binutils-2.32-new/bfd/Makefile.in 2019-11-19 20:46:58.866573771 +0100 +@@ -249,7 +249,7 @@ am__can_run_installinfo = \ + esac + am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \ + $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h bfd_stdint.h \ +- $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h ++ $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h $(INCDIR)/demangle.h + HEADERS = $(bfdinclude_HEADERS) + RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +@@ -468,7 +468,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@ bfd_stdint.h $(INCDIR)/diagnostics.h \ ++@INSTALL_LIBBFD_TRUE@ bfd_stdint.h $(INCDIR)/diagnostics.h $(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/binutils-fix-testsuite-failures.patch b/binutils-fix-testsuite-failures.patch new file mode 100644 index 0000000000000000000000000000000000000000..e9124367c10a6980e65daed3b2ea7508bf6dba67 --- /dev/null +++ b/binutils-fix-testsuite-failures.patch @@ -0,0 +1,316 @@ +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-10.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-10.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-10.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-10.d 2019-11-19 20:47:04.100602916 +0100 +@@ -32,7 +32,8 @@ hook called: claim_file tmpdir/func.o \[ + hook called: claim_file tmpdir/libtext.a \[@.* not claimed + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-11.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-11.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-11.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-11.d 2019-11-19 20:47:04.100602916 +0100 +@@ -35,8 +35,9 @@ hook called: claim_file tmpdir/func.o \[ + hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY +-Sym: '_?text' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?text' Resolution: LDPR_PREVAILING_DEF_IRONLY ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-12.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-12.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-12.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-12.d 2019-11-19 20:47:04.100602916 +0100 +@@ -1,6 +1,6 @@ + #... +-.*: symbol `func' definition: 0, visibility: 0, resolution: 2 +-.*: symbol `func1' definition: 0, visibility: 1, resolution: 3 +-.*: symbol `func2' definition: 0, visibility: 2, resolution: 3 +-.*: symbol `func3' definition: 0, visibility: 3, resolution: 3 ++.*: symbol `_?func' definition: 0, visibility: 0, resolution: . ++.*: symbol `_?func1' definition: 0, visibility: 1, resolution: 3 ++.*: symbol `_?func2' definition: 0, visibility: 2, resolution: 3 ++.*: symbol `_?func3' definition: 0, visibility: 3, resolution: 3 + #pass +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-13.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-13.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-13.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-13.d 2019-11-19 20:47:04.097602899 +0100 +@@ -23,5 +23,3 @@ hook called: claim_file tmpdir/main.o \[ + hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... +-.*main.c.*: undefined reference to `\.?func' +-#... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-14.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-14.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-14.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-14.d 2019-11-19 20:47:04.097602899 +0100 +@@ -27,7 +27,6 @@ hook called: claim_file .*/ld/testsuite/ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-15.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-15.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-15.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-15.d 2019-11-19 20:47:04.097602899 +0100 +@@ -28,7 +28,6 @@ hook called: claim_file .*/ld/testsuite/ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-16.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-16.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-16.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-16.d 2019-11-19 20:47:04.097602899 +0100 +@@ -30,9 +30,8 @@ hook called: claim_file .*/ld/testsuite/ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-17.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-17.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-17.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-17.d 2019-11-19 20:47:04.098602905 +0100 +@@ -31,7 +31,8 @@ hook called: claim_file .*/ld/testsuite/ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-18.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-18.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-18.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-18.d 2019-11-19 20:47:04.100602916 +0100 +@@ -32,7 +32,8 @@ hook called: claim_file .*/ld/testsuite/ + hook called: claim_file tmpdir/libtext.a \[@.* not claimed + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-19.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-19.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-19.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-19.d 2019-11-19 20:47:04.100602916 +0100 +@@ -35,8 +35,9 @@ hook called: claim_file .*/ld/testsuite/ + hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY +-Sym: '_?text' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?text' Resolution: LDPR_PREVAILING_DEF_IRONLY ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-20.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-20.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-20.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-20.d 2019-11-19 20:47:04.098602905 +0100 +@@ -2,6 +2,5 @@ hook called: all symbols read. + Input: func.c \(tmpdir/libfunc.a\) + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-21.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-21.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-21.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-21.d 2019-11-19 20:47:04.098602905 +0100 +@@ -2,6 +2,5 @@ hook called: all symbols read. + Input: .*/ld/testsuite/ld-plugin/func.c \(.*/ld/testsuite/ld-plugin/func.c\) + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-22.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-22.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-22.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-22.d 2019-11-19 20:47:04.098602905 +0100 +@@ -2,6 +2,5 @@ Claimed: tmpdir/libfunc.a \[@.* + hook called: all symbols read. + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-23.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-23.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-23.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-23.d 2019-11-19 20:47:04.098602905 +0100 +@@ -2,6 +2,5 @@ Claimed: .*/ld/testsuite/ld-plugin/func. + hook called: all symbols read. + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-24.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-24.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-24.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-24.d 2019-11-19 20:47:04.098602905 +0100 +@@ -2,4 +2,5 @@ hook called: all symbols read. + Input: .*/ld/testsuite/ld-plugin/func.c \(.*/ld/testsuite/ld-plugin/func.c\) + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* ++#... + hook called: cleanup. +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-25.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-25.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-25.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-25.d 2019-11-19 20:47:04.098602905 +0100 +@@ -2,4 +2,5 @@ Claimed: .*/ld/testsuite/ld-plugin/func. + hook called: all symbols read. + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* + Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.* ++#... + hook called: cleanup. +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-28.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-28.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-28.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-28.d 2019-11-19 20:47:04.101602922 +0100 +@@ -1 +1,2 @@ + .*: error: Error ++#... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-29.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-29.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-29.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-29.d 2019-11-19 20:47:04.099602910 +0100 +@@ -1 +1,2 @@ + .*: warning: Warning ++#... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-30.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-30.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-30.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-30.d 2019-11-19 20:47:04.099602910 +0100 +@@ -24,3 +24,4 @@ hook called: claim_file tmpdir/main.o \[ + hook called: claim_file tmpdir/func.o \[@0/.* not claimed + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + hook called: claim_file tmpdir/libempty.a \[@.* not claimed ++#pass +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-6.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-6.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-6.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-6.d 2019-11-19 20:47:04.099602910 +0100 +@@ -27,7 +27,6 @@ hook called: claim_file tmpdir/func.o \[ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-7.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-7.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-7.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-7.d 2019-11-19 20:47:04.099602910 +0100 +@@ -28,7 +28,6 @@ hook called: claim_file tmpdir/func.o \[ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-8.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-8.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-8.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-8.d 2019-11-19 20:47:04.101602922 +0100 +@@ -30,9 +30,8 @@ hook called: claim_file tmpdir/func.o \[ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY +-.*: tmpdir/main.o: in function `main': +-.*main.c.*: undefined reference to `\.?func' ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/plugin-9.d binutils-2.32-new/ld/testsuite/ld-plugin/plugin-9.d +--- binutils-2.32/ld/testsuite/ld-plugin/plugin-9.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/plugin-9.d 2019-11-19 20:47:04.099602910 +0100 +@@ -31,7 +31,8 @@ hook called: claim_file tmpdir/func.o \[ + hook called: claim_file tmpdir/text.o \[@0/.* not claimed + #... + hook called: all symbols read. +-Sym: '_?func' Resolution: LDPR_PREVAILING_DEF ++Sym: '_?func' Resolution: LDPR_PREVAILING_DEF_IRONLY + Sym: '_?func2' Resolution: LDPR_PREVAILING_DEF_IRONLY ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-plugin/pr20070.d binutils-2.32-new/ld/testsuite/ld-plugin/pr20070.d +--- binutils-2.32/ld/testsuite/ld-plugin/pr20070.d 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-plugin/pr20070.d 2019-11-19 20:47:04.099602910 +0100 +@@ -5,5 +5,6 @@ Sym: 'weakdef' Resolution: LDPR_PREVAILI + Sym: 'undef' Resolution: LDPR_UNDEF + Sym: 'weakundef' Resolution: LDPR_UNDEF + Sym: 'common' Resolution: LDPR_PREVAILING_DEF_IRONLY ++#... + hook called: cleanup. + #... +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-srec/srec.exp binutils-2.32-new/ld/testsuite/ld-srec/srec.exp +--- binutils-2.32/ld/testsuite/ld-srec/srec.exp 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-srec/srec.exp 2019-11-19 20:47:04.099602910 +0100 +@@ -21,6 +21,8 @@ + + # Get the offset from an S-record line to the start of the data. + ++return ++ + proc srec_off { l } { + if [string match "S1*" $l] { + return 8 +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-x86-64/x86-64.exp binutils-2.32-new/ld/testsuite/ld-x86-64/x86-64.exp +--- binutils-2.32/ld/testsuite/ld-x86-64/x86-64.exp 2019-01-19 17:01:34.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-x86-64/x86-64.exp 2019-11-19 20:47:04.100602916 +0100 +@@ -1275,25 +1275,6 @@ if { [isnative] && [which $CC] != 0 } { + "$NOPIE_CFLAGS" \ + ] \ + ] +- } else { +- run_cc_link_tests [list \ +- [list \ +- "Build pr22001-1b" \ +- "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \ +- "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \ +- { pr22001-1c.c } \ +- {{error_output "pr22001-1b.err"}} \ +- "pr22001-1b" \ +- ] \ +- [list \ +- "Build pr21997-1b" \ +- "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \ +- "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \ +- { pr21997-1c.c } \ +- {{error_output "pr21997-1b.err"}} \ +- "pr21997-1b" \ +- ] \ +- ] + } + + run_ld_link_exec_tests [list \ diff --git a/binutils-gas-build-note-relocs.patch b/binutils-gas-build-note-relocs.patch new file mode 100644 index 0000000000000000000000000000000000000000..1fa71d47c60330a857d4f628c6795750b60d3f9d --- /dev/null +++ b/binutils-gas-build-note-relocs.patch @@ -0,0 +1,56 @@ +diff -rupN --no-dereference binutils-2.32/gas/write.c binutils-2.32-new/gas/write.c +--- binutils-2.32/gas/write.c 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/gas/write.c 2019-11-19 20:47:10.792641216 +0100 +@@ -1891,7 +1891,8 @@ create_obj_attrs_section (void) + static void + create_note_reloc (segT sec, + symbolS * sym, +- bfd_size_type offset, ++ bfd_size_type note_offset, ++ bfd_size_type desc2_offset, + int reloc_type, + bfd_vma addend, + char * note) +@@ -1901,10 +1902,10 @@ create_note_reloc (segT sec, + reloc = XNEW (struct reloc_list); + + /* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */ +- reloc->u.b.sec = sec; +- reloc->u.b.s = symbol_get_bfdsym (sym); ++ reloc->u.b.sec = sec; ++ reloc->u.b.s = symbol_get_bfdsym (sym); + reloc->u.b.r.sym_ptr_ptr = & reloc->u.b.s; +- reloc->u.b.r.address = offset; ++ reloc->u.b.r.address = note_offset + desc2_offset; + reloc->u.b.r.addend = addend; + reloc->u.b.r.howto = bfd_reloc_type_lookup (stdoutput, reloc_type); + +@@ -1929,12 +1930,12 @@ create_note_reloc (segT sec, + if (target_big_endian) + { + if (bfd_arch_bits_per_address (stdoutput) <= 32) +- note[offset + 3] = addend; ++ note[desc2_offset + 3] = addend; + else +- note[offset + 7] = addend; ++ note[desc2_offset + 7] = addend; + } + else +- note[offset] = addend; ++ note[desc2_offset] = addend; + } + } + +@@ -2037,10 +2038,10 @@ maybe_generate_build_notes (void) + memcpy (note + 12, "GA$3a1", 8); + + /* Create a relocation to install the start address of the note... */ +- create_note_reloc (sec, sym, total_size + 20, desc_reloc, 0, note); ++ create_note_reloc (sec, sym, total_size, 20, desc_reloc, 0, note); + + /* ...and another one to install the end address. */ +- create_note_reloc (sec, sym, total_size + desc2_offset, desc_reloc, ++ create_note_reloc (sec, sym, total_size, desc2_offset, desc_reloc, + bfd_get_section_size (bsym->section), + note); + diff --git a/binutils-gold-ignore-discarded-note-relocs.patch b/binutils-gold-ignore-discarded-note-relocs.patch new file mode 100644 index 0000000000000000000000000000000000000000..a8adff1f068bf9ce41a34a650838a8480075e593 --- /dev/null +++ b/binutils-gold-ignore-discarded-note-relocs.patch @@ -0,0 +1,11 @@ +diff -rupN --no-dereference binutils-2.32/gold/target-reloc.h binutils-2.32-new/gold/target-reloc.h +--- binutils-2.32/gold/target-reloc.h 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/gold/target-reloc.h 2019-11-19 20:47:02.632594671 +0100 +@@ -136,6 +136,7 @@ class Default_comdat_behavior + if (Layout::is_debug_info_section(name)) + return CB_PRETEND; + if (strcmp(name, ".eh_frame") == 0 ++ || strncmp(name, ".gnu.build.attributes", 21) == 0 // FIXME: We should really be checking the section type for ST_NOTE... + || strcmp(name, ".gcc_except_table") == 0) + return CB_IGNORE; + return CB_ERROR; diff --git a/binutils-gold-mismatched-section-flags.patch b/binutils-gold-mismatched-section-flags.patch new file mode 100644 index 0000000000000000000000000000000000000000..13659f0e20d4c563e4ba97f19c80b791dd1ae50f --- /dev/null +++ b/binutils-gold-mismatched-section-flags.patch @@ -0,0 +1,36 @@ +diff -rupN --no-dereference binutils-2.32/gold/layout.cc binutils-2.32-new/gold/layout.cc +--- binutils-2.32/gold/layout.cc 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/gold/layout.cc 2019-11-19 20:47:10.054636935 +0100 +@@ -868,6 +868,7 @@ Layout::get_output_section(const char* n + && (same_name->flags() & elfcpp::SHF_TLS) == 0) + os = same_name; + } ++#if 0 /* BZ 1722715, PR 17556. */ + else if ((flags & elfcpp::SHF_TLS) == 0) + { + elfcpp::Elf_Xword zero_flags = 0; +@@ -878,6 +879,7 @@ Layout::get_output_section(const char* n + if (p != this->section_name_map_.end()) + os = p->second; + } ++#endif + } + + if (os == NULL) +diff -rupN --no-dereference binutils-2.32/gold/object.cc binutils-2.32-new/gold/object.cc +--- binutils-2.32/gold/object.cc 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/gold/object.cc 2019-11-19 20:47:10.054636935 +0100 +@@ -1644,6 +1644,13 @@ Sized_relobj_file::do_ + omit[i] = true; + } + ++ // Skip empty sections without flags. ++ if (!(shdr.get_sh_flags() & ~elfcpp::SHF_GROUP) ++ && !shdr.get_sh_size()) ++ { ++ omit[i] = true; ++ } ++ + bool discard = omit[i]; + if (!discard) + { diff --git a/binutils-objcopy-gnu-build-version-notes.patch b/binutils-objcopy-gnu-build-version-notes.patch new file mode 100644 index 0000000000000000000000000000000000000000..d1f1492f54e1c654e72b31826591afa8ca5a3cc3 --- /dev/null +++ b/binutils-objcopy-gnu-build-version-notes.patch @@ -0,0 +1,58 @@ +diff -rupN --no-dereference binutils-2.32/binutils/objcopy.c binutils-2.32-new/binutils/objcopy.c +--- binutils-2.32/binutils/objcopy.c 2019-01-19 17:01:33.000000000 +0100 ++++ binutils-2.32-new/binutils/objcopy.c 2019-11-19 20:47:13.738658442 +0100 +@@ -1988,7 +1988,6 @@ merge_gnu_build_notes (bfd * abfd, asect + unsigned long previous_open_end = 0; + long relsize; + +- + relsize = bfd_get_reloc_upper_bound (abfd, sec); + if (relsize > 0) + { +@@ -2005,7 +2004,8 @@ merge_gnu_build_notes (bfd * abfd, asect + } + + /* Make a copy of the notes and convert to our internal format. +- Minimum size of a note is 12 bytes. */ ++ Minimum size of a note is 12 bytes. Also locate the version ++ notes and check them. */ + pnote = pnotes = (objcopy_internal_note *) xcalloc ((size / 12), sizeof (* pnote)); + while (remain >= 12) + { +@@ -2174,12 +2174,10 @@ merge_gnu_build_notes (bfd * abfd, asect + attribute_type_byte = version_1_seen ? 1 : 3; + val_start = attribute_type_byte + 1; + +- /* The first note should be the first version note. */ +- if (pnotes[0].note.namedata[attribute_type_byte] != GNU_BUILD_ATTRIBUTE_VERSION) +- { +- err = _("bad GNU build attribute notes: first note not version note"); +- goto done; +- } ++ /* We used to require that the first note be a version note, ++ but this is no longer enforced. Due to the problems with ++ linking sections with the same name (eg .gnu.build.note.hot) ++ we cannot guarantee that the first note will be a version note. */ + + /* Now merge the notes. The rules are: + 1. Preserve the ordering of the notes. +@@ -2196,8 +2194,9 @@ merge_gnu_build_notes (bfd * abfd, asect + with a non-empty description field must also be preserved *OR* the + description field of the note must be changed to contain the starting + address to which it refers. +- 6. Notes with the same start and end address can be deleted. */ +- for (pnote = pnotes + 1; pnote < pnotes_end; pnote ++) ++ 6. Notes with the same start and end address can be deleted. ++ 7. FIXME: Elminate duplicate version notes - even function specific ones ? */ ++ for (pnote = pnotes; pnote < pnotes_end; pnote ++) + { + int note_type; + objcopy_internal_note * back; +@@ -2225,7 +2224,6 @@ merge_gnu_build_notes (bfd * abfd, asect + && back->note.namesz == pnote->note.namesz + && memcmp (back->note.namedata, pnote->note.namedata, pnote->note.namesz) == 0) + { +- fprintf (stderr, "DUP FUNXC\n"); + duplicate_found = TRUE; + pnote->note.type = 0; + break; diff --git a/binutils-readelf-other-sym-info.patch b/binutils-readelf-other-sym-info.patch new file mode 100644 index 0000000000000000000000000000000000000000..ddec626aad888882d9f65f1894fba87aed7f97d7 --- /dev/null +++ b/binutils-readelf-other-sym-info.patch @@ -0,0 +1,64 @@ +diff -rupN --no-dereference binutils-2.32/binutils/readelf.c binutils-2.32-new/binutils/readelf.c +--- binutils-2.32/binutils/readelf.c 2019-11-19 20:47:01.146586379 +0100 ++++ binutils-2.32-new/binutils/readelf.c 2019-11-19 20:47:01.152586412 +0100 +@@ -11321,12 +11321,14 @@ print_dynamic_symbol (Filedata * filedat + unsigned int vis = ELF_ST_VISIBILITY (psym->st_other); + + printf (" %-7s", get_symbol_visibility (vis)); ++#if 0 + /* Check to see if any other bits in the st_other field are set. + Note - displaying this information disrupts the layout of the + table being generated, but for the moment this case is very + rare. */ + if (psym->st_other ^ vis) + printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis)); ++#endif + } + + printf (" %3.3s ", get_symbol_index_type (filedata, psym->st_shndx)); +@@ -11334,6 +11336,15 @@ print_dynamic_symbol (Filedata * filedat + print_symbol (25, GET_DYNAMIC_NAME (psym->st_name)); + else + printf (_(" "), psym->st_name); ++#if 1 ++ { ++ unsigned int vis = ELF_ST_VISIBILITY (psym->st_other); ++ ++ /* Check to see if any other bits in the st_other field are set. */ ++ if (psym->st_other ^ vis) ++ printf (" \t[%s]", get_symbol_other (filedata, psym->st_other ^ vis)); ++ } ++#endif + putchar ('\n'); + } + +@@ -11842,11 +11853,13 @@ process_symbol_table (Filedata * filedat + unsigned int vis = ELF_ST_VISIBILITY (psym->st_other); + + printf (" %-7s", get_symbol_visibility (vis)); ++#if 0 + /* Check to see if any other bits in the st_other field are set. + Note - displaying this information disrupts the layout of the + table being generated, but for the moment this case is very rare. */ + if (psym->st_other ^ vis) + printf (" [%s] ", get_symbol_other (filedata, psym->st_other ^ vis)); ++#endif + } + printf (" %4s ", get_symbol_index_type (filedata, psym->st_shndx)); + print_symbol (25, psym->st_name < strtab_size +@@ -11865,7 +11878,15 @@ process_symbol_table (Filedata * filedat + printf (sym_info == symbol_hidden ? "@%s" : "@@%s", + version_string); + } ++#if 1 ++ { ++ unsigned int vis = ELF_ST_VISIBILITY (psym->st_other); + ++ /* Check to see if any other bits in the st_other field are set. */ ++ if (psym->st_other ^ vis) ++ printf (" \t[%s] ", get_symbol_other (filedata, psym->st_other ^ vis)); ++ } ++#endif + putchar ('\n'); + + if (ELF_ST_BIND (psym->st_info) == STB_LOCAL diff --git a/binutils-rh1736114.patch b/binutils-rh1736114.patch new file mode 100644 index 0000000000000000000000000000000000000000..f229ef7a4f069af56252e32b81f579518bb9c20f --- /dev/null +++ b/binutils-rh1736114.patch @@ -0,0 +1,107 @@ +diff -rupN --no-dereference binutils-2.32/bfd/elf-properties.c binutils-2.32-new/bfd/elf-properties.c +--- binutils-2.32/bfd/elf-properties.c 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/elf-properties.c 2019-11-19 20:47:13.003654121 +0100 +@@ -322,12 +322,10 @@ elf_merge_gnu_property_list (struct bfd_ + (bfd_vma) p->property.pr_type, first_pbfd, abfd); + } + } +- else +- { +- /* Remove this property. */ +- *lastp = p->next; +- continue; +- } ++ ++ /* Remove this property. */ ++ *lastp = p->next; ++ continue; + } + else if (number_p) + { +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-x86-64/pr24721a.s binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721a.s +--- binutils-2.32/ld/testsuite/ld-x86-64/pr24721a.s 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721a.s 2019-11-19 20:47:13.004654127 +0100 +@@ -0,0 +1,34 @@ ++ .text ++ .globl foo ++ .type foo,@function ++ .p2align 4 ++foo: ++ ret ++ ++ .section ".note.gnu.property", "a" ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++ .long 1f - 0f /* name length */ ++ .long 5f - 2f /* data length */ ++ .long 5 /* note type */ ++0: .asciz "GNU" /* vendor name */ ++1: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++2: .long 0xc0000002 /* pr_type. */ ++ .long 4f - 3f /* pr_datasz. */ ++3: ++ .long 0x1 ++4: ++.ifdef __64_bit__ ++ .p2align 3 ++.else ++ .p2align 2 ++.endif ++5: +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-x86-64/pr24721b.s binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721b.s +--- binutils-2.32/ld/testsuite/ld-x86-64/pr24721b.s 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721b.s 2019-11-19 20:47:13.004654127 +0100 +@@ -0,0 +1,6 @@ ++ .text ++ .globl bar ++ .type bar,@function ++ .p2align 4 ++bar: ++ ret +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-x86-64/pr24721.d binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721.d +--- binutils-2.32/ld/testsuite/ld-x86-64/pr24721.d 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721.d 2019-11-19 20:47:13.004654127 +0100 +@@ -0,0 +1,6 @@ ++#source: pr24721a.s ++#source: pr24721b.s ++#as: --64 -defsym __64_bit__=1 -mx86-used-note=no ++#ld: -r -melf_x86_64 -Map tmpdir/pr24721.map ++#readelf: -n ++#map: pr24721.map +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-x86-64/pr24721.map binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721.map +--- binutils-2.32/ld/testsuite/ld-x86-64/pr24721.map 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721.map 2019-11-19 20:47:13.004654127 +0100 +@@ -0,0 +1,3 @@ ++#... ++Removed property 0xc0000002 to merge tmpdir/pr24721a.o \(0x1\) and tmpdir/pr24721b.o \(not found\) ++#pass +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-x86-64/pr24721-x32.d binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721-x32.d +--- binutils-2.32/ld/testsuite/ld-x86-64/pr24721-x32.d 1970-01-01 01:00:00.000000000 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-x86-64/pr24721-x32.d 2019-11-19 20:47:13.003654121 +0100 +@@ -0,0 +1,6 @@ ++#source: pr24721a.s ++#source: pr24721b.s ++#as: --x32 -mx86-used-note=no ++#ld: -r -m elf32_x86_64 -Map tmpdir/pr24721.map ++#readelf: -n ++#map: pr24721.map +diff -rupN --no-dereference binutils-2.32/ld/testsuite/ld-x86-64/x86-64.exp binutils-2.32-new/ld/testsuite/ld-x86-64/x86-64.exp +--- binutils-2.32/ld/testsuite/ld-x86-64/x86-64.exp 2019-11-19 20:47:04.837607078 +0100 ++++ binutils-2.32-new/ld/testsuite/ld-x86-64/x86-64.exp 2019-11-19 20:47:13.004654127 +0100 +@@ -424,6 +424,8 @@ run_dump_test "pr23486d-x32" + run_dump_test "pr23854" + run_dump_test "pr23930" + run_dump_test "pr23930-x32" ++run_dump_test "pr24721" ++run_dump_test "pr24721-x32" + + if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} { + return diff --git a/binutils-special-sections-in-groups.patch b/binutils-special-sections-in-groups.patch new file mode 100644 index 0000000000000000000000000000000000000000..b114c5015ee1e649692aa07e21730ce26bb91600 --- /dev/null +++ b/binutils-special-sections-in-groups.patch @@ -0,0 +1,28 @@ +diff -rupN --no-dereference binutils-2.32/bfd/elf.c binutils-2.32-new/bfd/elf.c +--- binutils-2.32/bfd/elf.c 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/elf.c 2019-11-19 20:47:03.372598821 +0100 +@@ -831,7 +831,13 @@ setup_group (bfd *abfd, Elf_Internal_Shd + } + } + +- if (elf_group_name (newsect) == NULL) ++ if (elf_group_name (newsect) == NULL ++ /* OS specific sections might be in a group (eg ARM's ARM_EXIDX section) ++ but they will not have been added to the group because they do not ++ have contents that the ELF code in the BFD library knows how to ++ process. This is OK though - we rely upon the target backends to ++ handle these sections for us. */ ++ && hdr->sh_type < SHT_LOOS) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: no group info for section '%pA'"), +@@ -937,7 +943,8 @@ _bfd_elf_setup_sections (bfd *abfd) + else if (idx->shdr->bfd_section) + elf_sec_group (idx->shdr->bfd_section) = shdr->bfd_section; + else if (idx->shdr->sh_type != SHT_RELA +- && idx->shdr->sh_type != SHT_REL) ++ && idx->shdr->sh_type != SHT_REL ++ && idx->shdr->sh_type < SHT_LOOS) + { + /* There are some unknown sections in the group. */ + _bfd_error_handler diff --git a/binutils_24267.patch b/binutils_24267.patch new file mode 100644 index 0000000000000000000000000000000000000000..5c9f2bcdc71c360b6dce50b803e846aff92c3ea5 --- /dev/null +++ b/binutils_24267.patch @@ -0,0 +1,36 @@ +diff -rupN --no-dereference binutils-2.32/bfd/coffgen.c binutils-2.32-new/bfd/coffgen.c +--- binutils-2.32/bfd/coffgen.c 2019-11-19 20:47:08.571628378 +0100 ++++ binutils-2.32-new/bfd/coffgen.c 2019-11-19 20:47:17.460680520 +0100 +@@ -2639,6 +2639,9 @@ _bfd_coff_section_already_linked (bfd *a + struct bfd_section_already_linked_hash_entry *already_linked_list; + struct coff_comdat_info *s_comdat; + ++ if (sec->output_section == bfd_abs_section_ptr) ++ return FALSE; ++ + flags = sec->flags; + if ((flags & SEC_LINK_ONCE) == 0) + return FALSE; +diff -rupN --no-dereference binutils-2.32/bfd/cofflink.c binutils-2.32-new/bfd/cofflink.c +--- binutils-2.32/bfd/cofflink.c 2019-01-19 17:01:32.000000000 +0100 ++++ binutils-2.32-new/bfd/cofflink.c 2019-11-19 20:47:17.460680520 +0100 +@@ -310,7 +310,9 @@ coff_link_add_symbols (bfd *abfd, + case COFF_SYMBOL_GLOBAL: + flags = BSF_EXPORT | BSF_GLOBAL; + section = coff_section_from_bfd_index (abfd, sym.n_scnum); +- if (! obj_pe (abfd)) ++ if (discarded_section (section)) ++ section = bfd_und_section_ptr; ++ else if (! obj_pe (abfd)) + value -= section->vma; + break; + +@@ -327,6 +329,8 @@ coff_link_add_symbols (bfd *abfd, + case COFF_SYMBOL_PE_SECTION: + flags = BSF_SECTION_SYM | BSF_GLOBAL; + section = coff_section_from_bfd_index (abfd, sym.n_scnum); ++ if (discarded_section (section)) ++ section = bfd_und_section_ptr; + break; + } + diff --git a/mingw-binutils.spec b/mingw-binutils.spec new file mode 100644 index 0000000000000000000000000000000000000000..f8322e77936a7feb44089da23e1c9833b165c442 --- /dev/null +++ b/mingw-binutils.spec @@ -0,0 +1,403 @@ +%global run_testsuite 1 + +Name: mingw-binutils +Version: 2.32 +Release: 7%{?dist} +Summary: Cross-compiled version of binutils for Win32 and Win64 environments + +License: GPLv2+ and LGPLv2+ and GPLv3+ and LGPLv3+ + +URL: http://www.gnu.org/software/binutils/ +Source0: http://ftp.gnu.org/gnu/binutils/binutils-%{version}.tar.bz2 + +### Patches from native package + +# Unneeded, mingw does not have lib64 +# Patch01: binutils-2.20.51.0.2-libtool-lib64.patch + +# Purpose: Appends a RHEL or Fedora release string to the generic binutils +# version string. +# Lifetime: Permanent. This is a RHEL/Fedora specific patch. +Patch02: binutils-2.25-version.patch + +# Purpose: Exports the demangle.h header file (associated with the libiberty +# sources) with the binutils-devel rpm. +# Lifetime: Permanent. This is a RHEL/Fedora specific patch. +Patch03: binutils-export-demangle.h.patch + +# Purpose: Disables the check in the BFD library's bfd.h header file that +# config.h has been included before the bfd.h header. See BZ +# #845084 for more details. +# Lifetime: Permanent - but it should not be. The bfd.h header defines +# various types that are dependent upon configuration options, so +# the order of inclusion is important. +# FIXME: It would be better if the packages using the bfd.h header were +# fixed so that they do include the header files in the correct +# order. +Patch04: binutils-2.22.52.0.4-no-config-h-check.patch + +# Purpose: Include the filename concerned in readelf error messages. This +# makes readelf's output more helpful when it is run on multiple +# input files. +# Lifetime: Permanent. This patch changes the format of readelf's output, +# making it better (IMHO) but also potentially breaking tools that +# depend upon readelf's current format. Hence it remains a local +# patch. +Patch05: binutils-2.29-filename-in-error-messages.patch + +# Unneeded, affects ELF only +# Patch06: binutils-2.29-revert-PLT-elision.patch + +# Purpose: Changes readelf so that when it displays extra information about +# a symbol, this information is placed at the end of the line. +# Lifetime: Permanent. +# FIXME: The proper fix would be to update the scripts that are expecting +# a fixed output from readelf. But it seems that some of them are +# no longer being maintained. +Patch07: binutils-readelf-other-sym-info.patch + +# Unneeded, affects ELF only +# Patch08: binutils-2.27-aarch64-ifunc.patch + +# Purpose: Stop the binutils from statically linking with libstdc++. +# Lifetime: Permanent. +Patch09: binutils-do-not-link-with-static-libstdc++.patch + +# Unneeded, affects ELF only +# Patch10: binutils-attach-to-group.patch + +# Purpose: Stop gold from complaining about relocs in the .gnu.build.attribute +# section that reference symbols in discarded sections. +# Lifetime: Fixed in 2.33 (maybe) +Patch11: binutils-gold-ignore-discarded-note-relocs.patch + +# Purpose: Allow OS specific sections in section groups. +# Lifetime: Might be fixed in 2.33 +Patch12: binutils-special-sections-in-groups.patch + +# Purpose: Fix linker testsuite failures. +# Lifetime: Fixed in 2.33 (possibly) +Patch13: binutils-fix-testsuite-failures.patch + +# Purpose: Improve objdump's handling of corrupt input files. +# Lifetime: Fixed in 2.33 +Patch14: binutils-CVE-2019-9073.patch + +# Purpose: Stop illegal memory access parsing corrupt PE files. +# Lifetime: Fixed in 2.33 +Patch15: binutils-CVE-2019-9074.patch + +# Purpose: Stop illegal memory access parsing corrupt archives. +# Lifetime: Fixed in 2.33 +Patch16: binutils-CVE-2019-9075.patch + +# Purpose: Stop illegal memory access parsing a corrupt MIPS binary. +# Lifetime: Fixed in 2.33 +Patch17: binutils-CVE-2019-9077.patch + +# Purpose: Stop a seg-fault when disassembling an EFI binary. +# Lifetime: Fixed in 2.33 +Patch18: binutils-disassembling-efi-files.patch + +# Purpose: Fix a stack exhaustion problem in libiberty's name demangling code. +# Lifetime: Fixed in 2.33 +Patch19: binutils-CVE-2019-9071.patch + +# Purpose: Have the GOLD linker for AArch64 generate PLT entries for MOVW_ABS +# relocations if necessary. +# Lifetime: Fixed in 2.33 +Patch20: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch + +# Purpose: Stop gold from aborting when input sections with the same name +# have different flags. +# Lifetime: Fixed in 2.33 (probably) +Patch21: binutils-gold-mismatched-section-flags.patch + +# Purpose: Corrcect a memory corruption when generating relocs for build +# notes in the assembler. +# Lifetime: Fixed in 2.33 +Patch22: binutils-gas-build-note-relocs.patch + +# Purpose: Stop the BFD library from issueing warning messages about allocated +# sections being found outside of loadable segments, if they are +# found inside debuginfo files. +# Lifetime: Fixed in 2.33 +Patch23: binutils-do-not-warn-about-debuginfo-files.patch + +# Purpose: Stops the linker from merging section groups with different exclusion flags. +# Lifetime: Fixed in 2.33 +Patch24: binutils-do-not-merge-differing-SHF_EXCLUDE-groups.patch + +# Purpose: Fix -Map and property merging +# Lifetime: Fixed in 2.33 +Patch25: binutils-rh1736114.patch + +# Purpose: Change objcopy/strip so that they do not complain if the +# first note in a sequence of build notes is not a version note. +# Lifetime: Fixed in 2.33 +Patch26: binutils-objcopy-gnu-build-version-notes.patch + +# Purpose: Add a check to the GOLD linker for a corrupt input file +# with a fuzzed section offset. +# Lifetime: Fixed in 2.33 +Patch27: binutils-CVE-2019-1010204.patch + +# Purpose: Add check to libiberty library in order to prevent an integer overflow in the gold linker. +# Lifetime: Fixed in 2.33 +Patch28: binutils-CVE-2019-14250.patch + +# Purpose: Add check to readelf in order to prevent an integer overflow. +# Lifetime: Fixed in 2.33 +Patch29: binutils-CVE-2019-14444.patch + +### MINGW specific patches + +# Backport https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=999d6dff80fab12d22c2a8d91923db6bde7fb3e5 +# Fixes "too many open files" when linking libLLVM.dll +Patch100: 0001-Plugin-target-handling.patch +# Backport https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=patch;h=2219ae0b0ebe14373850b000c2abaa31dab1d741 +# Fixes an LTO issue (#1475237) +Patch101: binutils_24267.patch + +BuildRequires: gcc +BuildRequires: flex +BuildRequires: bison +BuildRequires: texinfo +BuildRequires: zlib-devel +BuildRequires: mingw32-filesystem >= 102 +BuildRequires: mingw64-filesystem >= 102 +%if %{run_testsuite} +BuildRequires: dejagnu +BuildRequires: sharutils +%endif +Provides: bundled(libiberty) + + +%description +Cross compiled binutils (utilities like 'strip', 'as', 'ld') which +understand Windows executables and DLLs. + +%package -n mingw-binutils-generic +Summary: Utilities which are needed for both the Win32 and Win64 toolchains + +%description -n mingw-binutils-generic +Utilities (like strip and objdump) which are needed for +both the Win32 and Win64 toolchains + +%package -n mingw32-binutils +Summary: Cross-compiled version of binutils for the Win32 environment +Requires: mingw-binutils-generic = %{version}-%{release} + +# NB: This must be left in. +Requires: mingw32-filesystem >= 95 + +%description -n mingw32-binutils +Cross compiled binutils (utilities like 'strip', 'as', 'ld') which +understand Windows executables and DLLs. + +%package -n mingw64-binutils +Summary: Cross-compiled version of binutils for the Win64 environment +Requires: mingw-binutils-generic = %{version}-%{release} + +# NB: This must be left in. +Requires: mingw64-filesystem >= 95 + +%description -n mingw64-binutils +Cross compiled binutils (utilities like 'strip', 'as', 'ld') which +understand Windows executables and DLLs. + + +%prep +%autosetup -p1 -n binutils-%{version} + + +%build +mkdir build_win32 +pushd build_win32 +CFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --build=%_build --host=%_host \ + --target=%{mingw32_target} \ + --disable-nls \ + --with-sysroot=%{mingw32_sysroot} \ + --prefix=%{_prefix} \ + --bindir=%{_bindir} \ + --includedir=%{_includedir} \ + --libdir=%{_libdir} \ + --mandir=%{_mandir} \ + --infodir=%{_infodir} + +make all %{?_smp_mflags} +popd + +mkdir build_win64 +pushd build_win64 +CFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --build=%_build --host=%_host \ + --target=%{mingw64_target} \ + --disable-nls \ + --with-sysroot=%{mingw64_sysroot} \ + --prefix=%{_prefix} \ + --bindir=%{_bindir} \ + --includedir=%{_includedir} \ + --libdir=%{_libdir} \ + --mandir=%{_mandir} \ + --infodir=%{_infodir} + +make all %{?_smp_mflags} +popd + +# Create multilib versions for the tools strip, objdump nm, and objcopy +mkdir build_multilib +pushd build_multilib +CFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --build=%_build --host=%_host \ + --target=%{mingw64_target} \ + --enable-targets=%{mingw64_target},%{mingw32_target} \ + --disable-nls \ + --with-sysroot=%{mingw64_sysroot} \ + --prefix=%{_prefix} \ + --bindir=%{_bindir} \ + --includedir=%{_includedir} \ + --libdir=%{_libdir} \ + --mandir=%{_mandir} \ + --infodir=%{_infodir} + +make %{?_smp_mflags} +popd + + +%check +%if !%{run_testsuite} +echo ====================TESTSUITE DISABLED========================= +%else +pushd build_win32 + make -k check < /dev/null || : + echo ====================TESTING WIN32 ========================= + cat {gas/testsuite/gas,ld/ld,binutils/binutils}.sum + echo ====================TESTING WIN32 END===================== + for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log} + do + ln $file binutils-%{mingw32_target}-$(basename $file) || : + done + tar cjf binutils-%{mingw32_target}.tar.bz2 binutils-%{mingw32_target}-*.{sum,log} + uuencode binutils-%{mingw32_target}.tar.bz2 binutils-%{mingw32_target}.tar.bz2 + rm -f binutils-%{mingw32_target}.tar.bz2 binutils-%{mingw32_target}-*.{sum,log} +popd + +pushd build_win64 + make -k check < /dev/null || : + echo ====================TESTING WIN64 ========================= + cat {gas/testsuite/gas,ld/ld,binutils/binutils}.sum + echo ====================TESTING WIN64 END===================== + for file in {gas/testsuite/gas,ld/ld,binutils/binutils}.{sum,log} + do + ln $file binutils-%{mingw64_target}-$(basename $file) || : + done + tar cjf binutils-%{mingw64_target}.tar.bz2 binutils-%{mingw64_target}-*.{sum,log} + uuencode binutils-%{mingw64_target}.tar.bz2 binutils-%{mingw64_target}.tar.bz2 + rm -f binutils-%{mingw64_target}.tar.bz2 binutils-%{mingw64_target}-*.{sum,log} +popd +%endif + + +%install +%mingw_make_install DESTDIR=$RPM_BUILD_ROOT +make -C build_multilib DESTDIR=$RPM_BUILD_ROOT/multilib install + +# These files conflict with ordinary binutils. +rm -rf $RPM_BUILD_ROOT%{_infodir} +rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty* + +# Keep the multilib versions of the strip, objdump and objcopy commands +# We need these for the RPM integration as these tools must be able to +# both process win32 and win64 binaries +mv $RPM_BUILD_ROOT/multilib%{_bindir}/%{mingw64_strip} $RPM_BUILD_ROOT%{_bindir}/%{mingw_strip} +mv $RPM_BUILD_ROOT/multilib%{_bindir}/%{mingw64_objdump} $RPM_BUILD_ROOT%{_bindir}/%{mingw_objdump} +mv $RPM_BUILD_ROOT/multilib%{_bindir}/%{mingw64_objcopy} $RPM_BUILD_ROOT%{_bindir}/%{mingw_objcopy} +mv $RPM_BUILD_ROOT/multilib%{_bindir}/%{mingw64_nm} $RPM_BUILD_ROOT%{_bindir}/%{mingw_nm} +rm -rf $RPM_BUILD_ROOT/multilib + + +%files -n mingw-binutils-generic +%doc COPYING +%{_mandir}/man1/* +%{_bindir}/%{mingw_strip} +%{_bindir}/%{mingw_objdump} +%{_bindir}/%{mingw_objcopy} +%{_bindir}/%{mingw_nm} + +%files -n mingw32-binutils +%{_bindir}/%{mingw32_target}-addr2line +%{_bindir}/%{mingw32_target}-ar +%{_bindir}/%{mingw32_target}-as +%{_bindir}/%{mingw32_target}-c++filt +%{_bindir}/%{mingw32_target}-dlltool +%{_bindir}/%{mingw32_target}-dllwrap +%{_bindir}/%{mingw32_target}-elfedit +%{_bindir}/%{mingw32_target}-gprof +%{_bindir}/%{mingw32_target}-ld +%{_bindir}/%{mingw32_target}-ld.bfd +%{_bindir}/%{mingw32_target}-nm +%{_bindir}/%{mingw32_target}-objcopy +%{_bindir}/%{mingw32_target}-objdump +%{_bindir}/%{mingw32_target}-ranlib +%{_bindir}/%{mingw32_target}-readelf +%{_bindir}/%{mingw32_target}-size +%{_bindir}/%{mingw32_target}-strings +%{_bindir}/%{mingw32_target}-strip +%{_bindir}/%{mingw32_target}-windmc +%{_bindir}/%{mingw32_target}-windres +%{_prefix}/%{mingw32_target}/bin/ar +%{_prefix}/%{mingw32_target}/bin/as +%{_prefix}/%{mingw32_target}/bin/dlltool +%{_prefix}/%{mingw32_target}/bin/ld +%{_prefix}/%{mingw32_target}/bin/ld.bfd +%{_prefix}/%{mingw32_target}/bin/nm +%{_prefix}/%{mingw32_target}/bin/objcopy +%{_prefix}/%{mingw32_target}/bin/objdump +%{_prefix}/%{mingw32_target}/bin/ranlib +%{_prefix}/%{mingw32_target}/bin/readelf +%{_prefix}/%{mingw32_target}/bin/strip +%{_prefix}/%{mingw32_target}/lib/ldscripts + +%files -n mingw64-binutils +%{_bindir}/%{mingw64_target}-addr2line +%{_bindir}/%{mingw64_target}-ar +%{_bindir}/%{mingw64_target}-as +%{_bindir}/%{mingw64_target}-c++filt +%{_bindir}/%{mingw64_target}-dlltool +%{_bindir}/%{mingw64_target}-dllwrap +%{_bindir}/%{mingw64_target}-elfedit +%{_bindir}/%{mingw64_target}-gprof +%{_bindir}/%{mingw64_target}-ld +%{_bindir}/%{mingw64_target}-ld.bfd +%{_bindir}/%{mingw64_target}-nm +%{_bindir}/%{mingw64_target}-objcopy +%{_bindir}/%{mingw64_target}-objdump +%{_bindir}/%{mingw64_target}-ranlib +%{_bindir}/%{mingw64_target}-readelf +%{_bindir}/%{mingw64_target}-size +%{_bindir}/%{mingw64_target}-strings +%{_bindir}/%{mingw64_target}-strip +%{_bindir}/%{mingw64_target}-windmc +%{_bindir}/%{mingw64_target}-windres +%{_prefix}/%{mingw64_target}/bin/ar +%{_prefix}/%{mingw64_target}/bin/as +%{_prefix}/%{mingw64_target}/bin/dlltool +%{_prefix}/%{mingw64_target}/bin/ld +%{_prefix}/%{mingw64_target}/bin/ld.bfd +%{_prefix}/%{mingw64_target}/bin/nm +%{_prefix}/%{mingw64_target}/bin/objcopy +%{_prefix}/%{mingw64_target}/bin/objdump +%{_prefix}/%{mingw64_target}/bin/ranlib +%{_prefix}/%{mingw64_target}/bin/readelf +%{_prefix}/%{mingw64_target}/bin/strip +%{_prefix}/%{mingw64_target}/lib/ldscripts + + +%changelog +* Thu Oct 08 2020 Zhiyi Weng - 2.32-7 +- Initial version