From 77c4286f09c75dfcdcc5f01b7c250e3e3b8f4109 Mon Sep 17 00:00:00 2001 From: Peter Robinson Date: May 27 2019 19:11:59 +0000 Subject: Sync with binutils-2.31.1-31 --- diff --git a/binutils-CVE-2018-20002.patch b/binutils-CVE-2018-20002.patch new file mode 100644 index 0000000..69057c7 --- /dev/null +++ b/binutils-CVE-2018-20002.patch @@ -0,0 +1,56 @@ +diff -rup binutils.ori/bfd/syms.c binutils-2.31.1/bfd/syms.c +--- binutils.ori/bfd/syms.c 2019-01-03 13:51:05.784005438 +0000 ++++ binutils-2.31.1/bfd/syms.c 2019-01-03 13:53:43.238815129 +0000 +@@ -822,10 +822,18 @@ _bfd_generic_read_minisymbols (bfd *abfd + if (symcount < 0) + goto error_return; + +- *minisymsp = syms; +- *sizep = sizeof (asymbol *); ++ if (symcount == 0) ++ /* We return 0 above when storage is 0. Exit in the same state ++ here, so as to not complicate callers with having to deal with ++ freeing memory for zero symcount. */ ++ free (syms); ++ else ++ { ++ *minisymsp = syms; ++ *sizep = sizeof (asymbol *); ++ } + +- return symcount; ++ return symcount; + + error_return: + bfd_set_error (bfd_error_no_symbols); +diff -rup binutils.ori/binutils/nm.c binutils-2.31.1/binutils/nm.c +--- binutils.ori/binutils/nm.c 2019-01-03 13:51:06.337001258 +0000 ++++ binutils-2.31.1/binutils/nm.c 2019-01-03 13:52:37.542311774 +0000 +@@ -1162,13 +1162,11 @@ display_rel_file (bfd *abfd, bfd *archiv + if (synth_count > 0) + { + asymbol **symp; +- void *new_mini; + long i; + +- new_mini = xmalloc ((symcount + synth_count + 1) * sizeof (*symp)); +- symp = (asymbol **) new_mini; +- memcpy (symp, minisyms, symcount * sizeof (*symp)); +- symp += symcount; ++ minisyms = xrealloc (minisyms, ++ (symcount + synth_count + 1) * sizeof (*symp)); ++ symp = (asymbol **) minisyms + symcount; + for (i = 0; i < synth_count; i++) + *symp++ = synthsyms + i; + *symp = 0; +diff -rup binutils.orig/binutils/nm.c binutils-2.31.1/binutils/nm.c +--- binutils.orig/binutils/nm.c 2019-01-03 14:18:21.086458519 +0000 ++++ binutils-2.31.1/binutils/nm.c 2019-01-03 14:18:23.642438853 +0000 +@@ -1170,7 +1170,6 @@ display_rel_file (bfd *abfd, bfd *archiv + for (i = 0; i < synth_count; i++) + *symp++ = synthsyms + i; + *symp = 0; +- minisyms = new_mini; + symcount += synth_count; + } + } diff --git a/binutils-CVE-2019-9071.patch b/binutils-CVE-2019-9071.patch new file mode 100644 index 0000000..0b0736d --- /dev/null +++ b/binutils-CVE-2019-9071.patch @@ -0,0 +1,110 @@ +--- binutils.orig/libiberty/cp-demangle.c 2019-04-10 10:31:27.854997707 +0100 ++++ binutils-2.31.1/libiberty/cp-demangle.c 2019-04-10 16:00:35.820350978 +0100 +@@ -858,7 +858,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; +@@ -4032,7 +4032,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) +@@ -4052,13 +4052,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: +@@ -4122,42 +4122,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 > MAX_RECURSION_COUNT) ++ /* 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; + } + } +@@ -4192,8 +4192,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 < MAX_RECURSION_COUNT) ++ 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 0000000..37256f4 --- /dev/null +++ b/binutils-CVE-2019-9073.patch @@ -0,0 +1,13 @@ +--- binutils.orig/binutils/objdump.c 2019-02-25 16:12:30.394056901 +0000 ++++ binutils-2.31.1/binutils/objdump.c 2019-02-25 16:13:07.224778005 +0000 +@@ -2993,7 +2993,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 0000000..84f0fd5 --- /dev/null +++ b/binutils-CVE-2019-9074.patch @@ -0,0 +1,32 @@ +--- binutils.orig/bfd/pei-x86_64.c 2019-02-25 16:12:29.798061414 +0000 ++++ binutils-2.31.1/bfd/pei-x86_64.c 2019-02-25 17:09:02.783425236 +0000 +@@ -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 0000000..ec3e8ca --- /dev/null +++ b/binutils-CVE-2019-9075.patch @@ -0,0 +1,73 @@ +diff -rup binutils.orig/bfd/archive64.c binutils-2.31.1/bfd/archive64.c +--- binutils.orig/bfd/archive64.c 2019-02-26 11:17:11.882530151 +0000 ++++ binutils-2.31.1/bfd/archive64.c 2019-02-26 11:19:18.422488805 +0000 +@@ -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 -rup binutils.orig/bfd/archive.c binutils-2.31.1/bfd/archive.c +--- binutils.orig/bfd/archive.c 2019-02-26 11:17:11.884530134 +0000 ++++ binutils-2.31.1/bfd/archive.c 2019-02-26 11:18:33.354859687 +0000 +@@ -1014,6 +1014,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; +@@ -1073,22 +1074,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 0000000..1790bfa --- /dev/null +++ b/binutils-CVE-2019-9077.patch @@ -0,0 +1,16 @@ +--- binutils.orig/binutils/readelf.c 2019-02-26 11:17:12.414525772 +0000 ++++ binutils-2.31.1/binutils/readelf.c 2019-02-26 12:11:40.642876742 +0000 +@@ -16009,6 +16009,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 0000000..2cdb734 --- /dev/null +++ b/binutils-aarch64-gold-PLT-for-MOVW_ABS.patch @@ -0,0 +1,20 @@ +--- binutils.orig/gold/aarch64.cc 2019-05-21 11:24:07.642560743 +0100 ++++ binutils-2.32/gold/aarch64.cc 2019-05-21 11:25:02.425157682 +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-alignment-of-decompressed-sections.patch b/binutils-alignment-of-decompressed-sections.patch new file mode 100644 index 0000000..b115cbb --- /dev/null +++ b/binutils-alignment-of-decompressed-sections.patch @@ -0,0 +1,447 @@ +diff -rup binutils.orig/bfd/bfd.c binutils-2.31.1/bfd/bfd.c +--- binutils.orig/bfd/bfd.c 2019-02-18 11:53:32.155652114 +0000 ++++ binutils-2.31.1/bfd/bfd.c 2019-02-18 12:03:21.591459682 +0000 +@@ -2332,6 +2332,8 @@ bfd_update_compression_header (bfd *abfd + bfd_put_32 (abfd, sec->size, &echdr->ch_size); + bfd_put_32 (abfd, 1 << sec->alignment_power, + &echdr->ch_addralign); ++ /* bfd_log2 (alignof (Elf32_Chdr)). */ ++ bfd_set_section_alignment (abfd, sec, 2); + } + else + { +@@ -2342,6 +2344,8 @@ bfd_update_compression_header (bfd *abfd + bfd_put_64 (abfd, sec->size, &echdr->ch_size); + bfd_put_64 (abfd, 1 << sec->alignment_power, + &echdr->ch_addralign); ++ /* bfd_log2 (alignof (Elf64_Chdr)). */ ++ bfd_set_section_alignment (abfd, sec, 3); + } + } + else +@@ -2354,6 +2358,8 @@ bfd_update_compression_header (bfd *abfd + order. */ + memcpy (contents, "ZLIB", 4); + bfd_putb64 (sec->size, contents + 4); ++ /* No way to keep the original alignment, just use 1 always. */ ++ bfd_set_section_alignment (abfd, sec, 0); + } + } + } +@@ -2368,12 +2374,15 @@ bfd_update_compression_header (bfd *abfd + SYNOPSIS + bfd_boolean bfd_check_compression_header + (bfd *abfd, bfd_byte *contents, asection *sec, +- bfd_size_type *uncompressed_size); ++ bfd_size_type *uncompressed_size, ++ unsigned int *uncompressed_alignment_power); ++ + + DESCRIPTION + Check the compression header at CONTENTS of SEC in ABFD and +- store the uncompressed size in UNCOMPRESSED_SIZE if the +- compression header is valid. ++ store the uncompressed size in UNCOMPRESSED_SIZE and the ++ uncompressed data alignment in UNCOMPRESSED_ALIGNMENT_POWER ++ if the compression header is valid. + + RETURNS + Return TRUE if the compression header is valid. +@@ -2382,7 +2391,8 @@ RETURNS + bfd_boolean + bfd_check_compression_header (bfd *abfd, bfd_byte *contents, + asection *sec, +- bfd_size_type *uncompressed_size) ++ bfd_size_type *uncompressed_size, ++ unsigned int *uncompressed_alignment_power) + { + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour + && (elf_section_flags (sec) & SHF_COMPRESSED) != 0) +@@ -2404,9 +2414,10 @@ bfd_check_compression_header (bfd *abfd, + chdr.ch_addralign = bfd_get_64 (abfd, &echdr->ch_addralign); + } + if (chdr.ch_type == ELFCOMPRESS_ZLIB +- && chdr.ch_addralign == 1U << sec->alignment_power) ++ && chdr.ch_addralign == (1U << bfd_log2 (chdr.ch_addralign))) + { + *uncompressed_size = chdr.ch_size; ++ *uncompressed_alignment_power = bfd_log2 (chdr.ch_addralign); + return TRUE; + } + } +diff -rup binutils.orig/bfd/bfd-in2.h binutils-2.31.1/bfd/bfd-in2.h +--- binutils.orig/bfd/bfd-in2.h 2019-02-18 11:53:32.156652107 +0000 ++++ binutils-2.31.1/bfd/bfd-in2.h 2019-02-18 12:00:23.849723903 +0000 +@@ -7274,7 +7274,8 @@ void bfd_update_compression_header + + bfd_boolean bfd_check_compression_header + (bfd *abfd, bfd_byte *contents, asection *sec, +- bfd_size_type *uncompressed_size); ++ bfd_size_type *uncompressed_size, ++ unsigned int *uncompressed_alignment_power); + + int bfd_get_compression_header_size (bfd *abfd, asection *sec); + +@@ -7850,7 +7851,8 @@ void bfd_cache_section_contents + bfd_boolean bfd_is_section_compressed_with_header + (bfd *abfd, asection *section, + int *compression_header_size_p, +- bfd_size_type *uncompressed_size_p); ++ bfd_size_type *uncompressed_size_p, ++ unsigned int *uncompressed_alignment_power_p); + + bfd_boolean bfd_is_section_compressed + (bfd *abfd, asection *section); +diff -rup binutils.orig/bfd/compress.c binutils-2.31.1/bfd/compress.c +--- binutils.orig/bfd/compress.c 2019-02-18 11:53:32.153652128 +0000 ++++ binutils-2.31.1/bfd/compress.c 2019-02-18 12:11:44.899886376 +0000 +@@ -84,11 +84,13 @@ bfd_compress_section_contents (bfd *abfd + int zlib_size = 0; + int orig_compression_header_size; + bfd_size_type orig_uncompressed_size; ++ unsigned int orig_uncompressed_alignment_pow; + int header_size = bfd_get_compression_header_size (abfd, NULL); + bfd_boolean compressed + = bfd_is_section_compressed_with_header (abfd, sec, + &orig_compression_header_size, +- &orig_uncompressed_size); ++ &orig_uncompressed_size, ++ &orig_uncompressed_alignment_pow); + + /* Either ELF compression header or the 12-byte, "ZLIB" + 8-byte size, + overhead in .zdebug* section. */ +@@ -153,6 +155,8 @@ bfd_compress_section_contents (bfd *abfd + return 0; + } + free (uncompressed_buffer); ++ bfd_set_section_alignment (abfd, sec, ++ orig_uncompressed_alignment_pow); + sec->contents = buffer; + sec->compress_status = COMPRESS_SECTION_DONE; + return orig_uncompressed_size; +@@ -364,20 +368,25 @@ SYNOPSIS + bfd_boolean bfd_is_section_compressed_with_header + (bfd *abfd, asection *section, + int *compression_header_size_p, +- bfd_size_type *uncompressed_size_p); ++ bfd_size_type *uncompressed_size_p, ++ unsigned int *uncompressed_alignment_power_p); ++ + + DESCRIPTION + Return @code{TRUE} if @var{section} is compressed. Compression +- header size is returned in @var{compression_header_size_p} and +- uncompressed size is returned in @var{uncompressed_size_p}. If +- compression is unsupported, compression header size is returned +- with -1 and uncompressed size is returned with 0. ++ header size is returned in @var{compression_header_size_p}, ++ uncompressed size is returned in @var{uncompressed_size_p} ++ and the uncompressed data alignement power is returned in ++ @var{uncompressed_align_pow_p}. If compression is ++ unsupported, compression header size is returned with -1 ++ and uncompressed size is returned with 0. + */ + + bfd_boolean + bfd_is_section_compressed_with_header (bfd *abfd, sec_ptr sec, + int *compression_header_size_p, +- bfd_size_type *uncompressed_size_p) ++ bfd_size_type *uncompressed_size_p, ++ unsigned int *uncompressed_align_pow_p) + { + bfd_byte header[MAX_COMPRESSION_HEADER_SIZE]; + int compression_header_size; +@@ -385,6 +394,8 @@ bfd_is_section_compressed_with_header (b + unsigned int saved = sec->compress_status; + bfd_boolean compressed; + ++ *uncompressed_align_pow_p = 0; ++ + compression_header_size = bfd_get_compression_header_size (abfd, sec); + if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE) + abort (); +@@ -412,7 +423,8 @@ bfd_is_section_compressed_with_header (b + if (compression_header_size != 0) + { + if (!bfd_check_compression_header (abfd, header, sec, +- uncompressed_size_p)) ++ uncompressed_size_p, ++ uncompressed_align_pow_p)) + compression_header_size = -1; + } + /* Check for the pathalogical case of a debug string section that +@@ -449,9 +461,11 @@ bfd_is_section_compressed (bfd *abfd, se + { + int compression_header_size; + bfd_size_type uncompressed_size; ++ unsigned int uncompressed_align_power; + return (bfd_is_section_compressed_with_header (abfd, sec, + &compression_header_size, +- &uncompressed_size) ++ &uncompressed_size, ++ &uncompressed_align_power) + && compression_header_size >= 0 + && uncompressed_size > 0); + } +@@ -480,6 +494,7 @@ bfd_init_section_decompress_status (bfd + int compression_header_size; + int header_size; + bfd_size_type uncompressed_size; ++ unsigned int uncompressed_alignment_power = 0; + + compression_header_size = bfd_get_compression_header_size (abfd, sec); + if (compression_header_size > MAX_COMPRESSION_HEADER_SIZE) +@@ -508,7 +523,8 @@ bfd_init_section_decompress_status (bfd + uncompressed_size = bfd_getb64 (header + 4); + } + else if (!bfd_check_compression_header (abfd, header, sec, +- &uncompressed_size)) ++ &uncompressed_size, ++ &uncompressed_alignment_power)) + { + bfd_set_error (bfd_error_wrong_format); + return FALSE; +@@ -516,6 +532,7 @@ bfd_init_section_decompress_status (bfd + + sec->compressed_size = sec->size; + sec->size = uncompressed_size; ++ bfd_set_section_alignment (abfd, sec, uncompressed_alignment_power); + sec->compress_status = DECOMPRESS_SECTION_SIZED; + + return TRUE; +diff -rup binutils.orig/bfd/elf.c binutils-2.31.1/bfd/elf.c +--- binutils.orig/bfd/elf.c 2019-02-18 11:53:32.161652071 +0000 ++++ binutils-2.31.1/bfd/elf.c 2019-02-18 12:08:52.135108638 +0000 +@@ -1177,10 +1177,12 @@ _bfd_elf_make_section_from_shdr (bfd *ab + enum { nothing, compress, decompress } action = nothing; + int compression_header_size; + bfd_size_type uncompressed_size; ++ unsigned int uncompressed_align_power; + bfd_boolean compressed + = bfd_is_section_compressed_with_header (abfd, newsect, + &compression_header_size, +- &uncompressed_size); ++ &uncompressed_size, ++ &uncompressed_align_power); + + if (compressed) + { +diff -rup binutils.orig/binutils/readelf.c binutils-2.31.1/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2019-02-18 11:53:32.947646480 +0000 ++++ binutils-2.31.1/binutils/readelf.c 2019-02-18 12:10:13.142535034 +0000 +@@ -13366,12 +13366,6 @@ dump_section_as_strings (Elf_Internal_Sh + printable_section_name (filedata, section), chdr.ch_type); + return FALSE; + } +- else if (chdr.ch_addralign != section->sh_addralign) +- { +- warn (_("compressed section '%s' is corrupted\n"), +- printable_section_name (filedata, section)); +- return FALSE; +- } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + new_size -= compression_header_size; +@@ -13513,12 +13507,6 @@ dump_section_as_bytes (Elf_Internal_Shdr + printable_section_name (filedata, section), chdr.ch_type); + return FALSE; + } +- else if (chdr.ch_addralign != section->sh_addralign) +- { +- warn (_("compressed section '%s' is corrupted\n"), +- printable_section_name (filedata, section)); +- return FALSE; +- } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + new_size -= compression_header_size; +@@ -13688,12 +13676,6 @@ load_specific_debug_section (enum dwarf_ + section->name, chdr.ch_type); + return FALSE; + } +- else if (chdr.ch_addralign != sec->sh_addralign) +- { +- warn (_("compressed section '%s' is corrupted\n"), +- section->name); +- return FALSE; +- } + uncompressed_size = chdr.ch_size; + start += compression_header_size; + size -= compression_header_size; +diff -rup binutils.orig/binutils/testsuite/binutils-all/dw2-3.rS binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rS +--- binutils.orig/binutils/testsuite/binutils-all/dw2-3.rS 2019-02-18 11:53:32.908646758 +0000 ++++ binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rS 2019-02-18 12:10:40.884338917 +0000 +@@ -1,3 +1,3 @@ + #... +- +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +1 ++ +\[[ 0-9]+\] .debug_info +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ [0-9a-f]+ +C +0 +0 +(4|8) + #pass +diff -rup binutils.orig/binutils/testsuite/binutils-all/dw2-3.rt binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rt +--- binutils.orig/binutils/testsuite/binutils-all/dw2-3.rt 2019-02-18 11:53:32.905646779 +0000 ++++ binutils-2.31.1/binutils/testsuite/binutils-all/dw2-3.rt 2019-02-18 12:11:13.476108521 +0000 +@@ -1,6 +1,6 @@ + #... + +\[[ 0-9]+\] .debug_info +- +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +1 ++ +(PROGBITS|MIPS_DWARF) +0+ +[0-9a-f]+ +[0-9a-f]+ +[0-9a-f]+ +0 +0 +(4|8) + +\[0+800\]: COMPRESSED + +ZLIB, 0+9d, 1 + #pass +diff -rup binutils.orig/gold/merge.cc binutils-2.31.1/gold/merge.cc +--- binutils.orig/gold/merge.cc 2019-02-18 11:53:32.210651723 +0000 ++++ binutils-2.31.1/gold/merge.cc 2019-02-18 12:12:59.027362334 +0000 +@@ -440,9 +440,11 @@ Output_merge_string::do_add_i + { + section_size_type sec_len; + bool is_new; ++ uint64_t addralign = this->addralign(); + const unsigned char* pdata = object->decompressed_section_contents(shndx, + &sec_len, +- &is_new); ++ &is_new, ++ &addralign); + + const Char_type* p = reinterpret_cast(pdata); + const Char_type* pend = p + sec_len / sizeof(Char_type); +@@ -494,7 +496,7 @@ Output_merge_string::do_add_i + // aligned, so each string within the section must retain the same + // modulo. + uintptr_t init_align_modulo = (reinterpret_cast(pdata) +- & (this->addralign() - 1)); ++ & (addralign - 1)); + bool has_misaligned_strings = false; + + while (p < pend) +@@ -503,7 +505,7 @@ Output_merge_string::do_add_i + + // Within merge input section each string must be aligned. + if (len != 0 +- && ((reinterpret_cast(p) & (this->addralign() - 1)) ++ && ((reinterpret_cast(p) & (addralign - 1)) + != init_align_modulo)) + has_misaligned_strings = true; + +diff -rup binutils.orig/gold/object.cc binutils-2.31.1/gold/object.cc +--- binutils.orig/gold/object.cc 2019-02-18 11:53:32.208651737 +0000 ++++ binutils-2.31.1/gold/object.cc 2019-02-18 12:16:35.938828914 +0000 +@@ -751,11 +751,13 @@ build_compressed_section_map( + const unsigned char* contents = + obj->section_contents(i, &len, false); + uint64_t uncompressed_size; ++ Compressed_section_info info; + if (is_zcompressed) + { + // Skip over the ".zdebug" prefix. + name += 7; + uncompressed_size = get_uncompressed_size(contents, len); ++ info.addralign = shdr.get_sh_addralign(); + } + else + { +@@ -763,8 +765,8 @@ build_compressed_section_map( + name += 6; + elfcpp::Chdr chdr(contents); + uncompressed_size = chdr.get_ch_size(); ++ info.addralign = chdr.get_ch_addralign(); + } +- Compressed_section_info info; + info.size = convert_to_section_size_type(uncompressed_size); + info.flag = shdr.get_sh_flags(); + info.contents = NULL; +@@ -3060,7 +3062,8 @@ const unsigned char* + Object::decompressed_section_contents( + unsigned int shndx, + section_size_type* plen, +- bool* is_new) ++ bool* is_new, ++ uint64_t* palign) + { + section_size_type buffer_size; + const unsigned char* buffer = this->do_section_contents(shndx, &buffer_size, +@@ -3087,6 +3090,8 @@ Object::decompressed_section_contents( + { + *plen = uncompressed_size; + *is_new = false; ++ if (palign != NULL) ++ *palign = p->second.addralign; + return p->second.contents; + } + +@@ -3108,6 +3113,8 @@ Object::decompressed_section_contents( + // once in this pass. + *plen = uncompressed_size; + *is_new = true; ++ if (palign != NULL) ++ *palign = p->second.addralign; + return uncompressed_data; + } + +diff -rup binutils.orig/gold/object.h binutils-2.31.1/gold/object.h +--- binutils.orig/gold/object.h 2019-02-18 11:53:32.210651723 +0000 ++++ binutils-2.31.1/gold/object.h 2019-02-18 12:17:50.625300926 +0000 +@@ -373,6 +373,7 @@ struct Compressed_section_info + { + section_size_type size; + elfcpp::Elf_Xword flag; ++ uint64_t addralign; + const unsigned char* contents; + }; + typedef std::map Compressed_section_map; +@@ -808,7 +809,8 @@ class Object + + bool + section_is_compressed(unsigned int shndx, +- section_size_type* uncompressed_size) const ++ section_size_type* uncompressed_size, ++ elfcpp::Elf_Xword* palign = NULL) const + { + if (this->compressed_sections_ == NULL) + return false; +@@ -818,6 +820,8 @@ class Object + { + if (uncompressed_size != NULL) + *uncompressed_size = p->second.size; ++ if (palign != NULL) ++ *palign = p->second.addralign; + return true; + } + return false; +@@ -828,7 +832,7 @@ class Object + // by the caller. + const unsigned char* + decompressed_section_contents(unsigned int shndx, section_size_type* plen, +- bool* is_cached); ++ bool* is_cached, uint64_t* palign = NULL); + + // Discard any buffers of decompressed sections. This is done + // at the end of the Add_symbols task. +diff -rup binutils.orig/gold/output.cc binutils-2.31.1/gold/output.cc +--- binutils.orig/gold/output.cc 2019-02-18 11:53:32.209651729 +0000 ++++ binutils-2.31.1/gold/output.cc 2019-02-18 12:18:39.729953797 +0000 +@@ -2448,7 +2448,14 @@ Output_section::add_input_section(Layout + unsigned int reloc_shndx, + bool have_sections_script) + { ++ section_size_type input_section_size = shdr.get_sh_size(); ++ section_size_type uncompressed_size; + elfcpp::Elf_Xword addralign = shdr.get_sh_addralign(); ++ ++ if (object->section_is_compressed(shndx, &uncompressed_size, ++ &addralign)) ++ input_section_size = uncompressed_size; ++ + if ((addralign & (addralign - 1)) != 0) + { + object->error(_("invalid alignment %lu for section \"%s\""), +@@ -2498,11 +2505,6 @@ Output_section::add_input_section(Layout + } + } + +- section_size_type input_section_size = shdr.get_sh_size(); +- section_size_type uncompressed_size; +- if (object->section_is_compressed(shndx, &uncompressed_size)) +- input_section_size = uncompressed_size; +- + off_t offset_in_section; + + if (this->has_fixed_layout()) diff --git a/binutils-disassembling-efi-files.patch b/binutils-disassembling-efi-files.patch new file mode 100644 index 0000000..75d4275 --- /dev/null +++ b/binutils-disassembling-efi-files.patch @@ -0,0 +1,39 @@ +diff -rup binutils.orig/bfd/coffgen.c binutils-2.31.1/bfd/coffgen.c +--- binutils.orig/bfd/coffgen.c 2019-03-06 08:49:19.500586870 +0000 ++++ binutils-2.31.1/bfd/coffgen.c 2019-03-06 08:49:45.798394582 +0000 +@@ -2289,7 +2289,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) +@@ -2301,10 +2301,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; +Only in binutils-2.31.1/bfd: coffgen.c.orig +diff -rup binutils.orig/bfd/dwarf2.c binutils-2.31.1/bfd/dwarf2.c +--- binutils.orig/bfd/dwarf2.c 2019-03-06 08:49:19.498586884 +0000 ++++ binutils-2.31.1/bfd/dwarf2.c 2019-03-06 08:49:45.799394575 +0000 +@@ -4463,7 +4463,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) +Only in binutils-2.31.1/bfd: dwarf2.c.orig diff --git a/binutils-gas-input-matches-output.patch b/binutils-gas-input-matches-output.patch new file mode 100644 index 0000000..76eab57 --- /dev/null +++ b/binutils-gas-input-matches-output.patch @@ -0,0 +1,37 @@ +--- binutils.orig/gas/as.c 2019-01-30 11:02:04.055574300 +0000 ++++ binutils-2.31.1/gas/as.c 2019-01-30 11:03:12.212050935 +0000 +@@ -1254,14 +1254,27 @@ main (int argc, char ** argv) + { + struct stat sib; + +- if (stat (argv[i], &sib) == 0) ++ /* Check that the input file and output file are different. */ ++ if (stat (argv[i], &sib) == 0 ++ && sib.st_ino == sob.st_ino ++ /* POSIX emulating systems may support stat() but if the ++ underlying file system does not support a file serial number ++ of some kind then they will return 0 for the inode. So ++ two files with an inode of 0 may not actually be the same. ++ On real POSIX systems no ordinary file will ever have an ++ inode of 0. */ ++ && sib.st_ino != 0 ++ /* Different files may have the same inode number if they ++ reside on different devices, so check the st_dev field as ++ well. */ ++ && sib.st_dev == sob.st_dev) + { +- if (sib.st_ino == sob.st_ino && sib.st_ino != 0) +- { +- /* Don't let as_fatal remove the output file! */ +- out_file_name = NULL; +- as_fatal (_("The input and output files must be distinct")); +- } ++ const char *saved_out_file_name = out_file_name; ++ ++ /* Don't let as_fatal remove the output file! */ ++ out_file_name = NULL; ++ as_fatal (_("The input '%s' and output '%s' files are the same"), ++ argv[i], saved_out_file_name); + } + } + } diff --git a/binutils-gold-discard-version-info.patch b/binutils-gold-discard-version-info.patch new file mode 100644 index 0000000..2279021 --- /dev/null +++ b/binutils-gold-discard-version-info.patch @@ -0,0 +1,35 @@ +diff -rup binutils.orig/gold/options.h binutils-2.31.1/gold/options.h +--- binutils.orig/gold/options.h 2018-11-28 13:43:45.192094029 +0000 ++++ binutils-2.31.1/gold/options.h 2018-11-28 13:44:30.616758345 +0000 +@@ -1358,6 +1358,10 @@ class General_options + N_("Warn about duplicate common symbols"), + N_("Do not warn about duplicate common symbols")); + ++ DEFINE_bool(warn_drop_version, options::TWO_DASHES, '\0', false, ++ N_("Warn when discarding version information"), ++ N_("Do not warn when discarding version information")); ++ + DEFINE_bool_ignore(warn_constructors, options::TWO_DASHES, '\0', + N_("Ignored"), N_("Ignored")); + +diff -rup binutils.orig/gold/symtab.cc binutils-2.31.1/gold/symtab.cc +--- binutils.orig/gold/symtab.cc 2018-11-28 13:43:45.193094021 +0000 ++++ binutils-2.31.1/gold/symtab.cc 2018-11-28 13:45:13.479441595 +0000 +@@ -2623,11 +2623,12 @@ Symbol_table::set_dynsym_indexes(unsigne + versions->record_version(this, dynpool, sym); + else + { +- gold_warning(_("discarding version information for " +- "%s@%s, defined in unused shared library %s " +- "(linked with --as-needed)"), +- sym->name(), sym->version(), +- sym->object()->name().c_str()); ++ if (parameters->options().warn_drop_version()) ++ gold_warning(_("discarding version information for " ++ "%s@%s, defined in unused shared library %s " ++ "(linked with --as-needed)"), ++ sym->name(), sym->version(), ++ sym->object()->name().c_str()); + sym->clear_version(); + } + } diff --git a/binutils-ppc64-local-ifunc-relocs.patch b/binutils-ppc64-local-ifunc-relocs.patch new file mode 100644 index 0000000..b5637be --- /dev/null +++ b/binutils-ppc64-local-ifunc-relocs.patch @@ -0,0 +1,12 @@ +--- binutils.orig/bfd/elf64-ppc.c 2019-02-20 10:58:09.700552616 +0000 ++++ binutils-2.31.1/bfd/elf64-ppc.c 2019-02-20 10:59:15.989062349 +0000 +@@ -13530,7 +13530,8 @@ write_plt_relocs_for_local_syms (struct + } + + val = sym->st_value + ent->addend; +- val += PPC64_LOCAL_ENTRY_OFFSET (sym->st_other); ++ if (ELF_ST_TYPE (sym->st_info) != STT_GNU_IFUNC) ++ val += PPC64_LOCAL_ENTRY_OFFSET (sym->st_other); + if (sym_sec != NULL && sym_sec->output_section != NULL) + val += sym_sec->output_offset + sym_sec->output_section->vma; + diff --git a/binutils-x86-no-scale-8bit-displacements.patch b/binutils-x86-no-scale-8bit-displacements.patch new file mode 100644 index 0000000..2317bbd --- /dev/null +++ b/binutils-x86-no-scale-8bit-displacements.patch @@ -0,0 +1,38 @@ +Only in binutils-2.31.1/gas: ChangeLog.orig +diff -rup binutils.orig/gas/config/tc-i386.c binutils-2.31.1/gas/config/tc-i386.c +--- binutils.orig/gas/config/tc-i386.c 2019-04-10 10:31:32.788961110 +0100 ++++ binutils-2.31.1/gas/config/tc-i386.c 2019-04-10 10:31:57.669774802 +0100 +@@ -7857,7 +7857,8 @@ output_disp (fragS *insn_start_frag, off + int size = disp_size (n); + offsetT val = i.op[n].disps->X_add_number; + +- val = offset_in_range (val >> i.memshift, size); ++ val = offset_in_range (val >> (size == 1 ? i.memshift : 0), ++ size); + p = frag_more (size); + md_number_to_chars (p, val, size); + } +Only in binutils-2.31.1/gas/config: tc-i386.c.orig +Only in binutils-2.31.1/gas/testsuite/gas/i386: evex-no-scale-32.d +Only in binutils-2.31.1/gas/testsuite/gas/i386: evex-no-scale-64.d +Only in binutils-2.31.1/gas/testsuite/gas/i386: evex-no-scale.s +diff -rup binutils.orig/gas/testsuite/gas/i386/i386.exp binutils-2.31.1/gas/testsuite/gas/i386/i386.exp +--- binutils.orig/gas/testsuite/gas/i386/i386.exp 2019-04-10 10:31:32.160965768 +0100 ++++ binutils-2.31.1/gas/testsuite/gas/i386/i386.exp 2019-04-10 10:31:57.670774795 +0100 +@@ -224,6 +224,7 @@ if [expr ([istarget "i*86-*-*"] || [ist + run_dump_test "evex-lig512-intel" + run_dump_test "evex-wig1" + run_dump_test "evex-wig1-intel" ++ run_dump_test "evex-no-scale-32" + run_dump_test "sse2avx" + run_list_test "inval-avx" "-al" + run_list_test "inval-avx512f" "-al" +@@ -733,6 +734,7 @@ if [expr ([istarget "i*86-*-*"] || [ista + run_dump_test "x86-64-evex-lig512-intel" + run_dump_test "x86-64-evex-wig1" + run_dump_test "x86-64-evex-wig1-intel" ++ run_dump_test "evex-no-scale-64" + run_dump_test "x86-64-sse2avx" + run_list_test "x86-64-inval-avx" "-al" + run_list_test "x86-64-inval-avx512f" "-al" +Only in binutils-2.31.1/gas/testsuite/gas/i386: i386.exp.orig diff --git a/cross-binutils.spec b/cross-binutils.spec index e31a516..baed621 100644 --- a/cross-binutils.spec +++ b/cross-binutils.spec @@ -65,7 +65,7 @@ Summary: A GNU collection of cross-compilation binary utilities Name: %{cross}-binutils Version: 2.31.1 -Release: 2%{?dist} +Release: 3%{?dist} License: GPLv3+ URL: https://sourceware.org/binutils @@ -203,6 +203,60 @@ Patch22: binutils-CVE-2018-17358.patch # Lifetime: Might be fixed in 2.32 Patch23: binutils-special-sections-in-groups.patch +# Purpose: Stop gold from issuing warnings about dropped version +# information, unless explicitly requested otherwise. +# Lifetime: Fixed in 2.32 +Patch24: binutils-gold-discard-version-info.patch + +# Purpose: Fix a memory leak reading minisymbols. +# Lifetime: Fixed in 2.32 +Patch25: binutils-CVE-2018-20002.patch + +# Purpose: Fix assembler check for an output file matching an input file. +# Lifetime: Fixed in 2.32 +Patch26: binutils-gas-input-matches-output.patch + +# Purpose: Ensure that decompressed sections have the correct alignment. +# Lifetime: Fixed in 2.32 +Patch27: binutils-alignment-of-decompressed-sections.patch + +# Purpose: Correct the generation of relocations for local ifuncs on PowerPC64 +# Lifetime: Fixed in 2.32 +Patch28: binutils-ppc64-local-ifunc-relocs.patch + +# Purpose: Improve objdump's handling of corrupt input files. +# Lifetime: Fixed in 2.33 +Patch29: binutils-CVE-2019-9073.patch + +# Purpose: Stop illegal memory access parsing corrupt PE files. +# Lifetime: Fixed in 2.33 +Patch30: binutils-CVE-2019-9074.patch + +# Purpose: Stop illegal memory access parsing corrupt archives. +# Lifetime: Fixed in 2.33 +Patch31: binutils-CVE-2019-9075.patch + +# Purpose: Stop illegal memory access parsing a corrupt MIPS binary. +# Lifetime: Fixed in 2.33 +Patch32: binutils-CVE-2019-9077.patch + +# Purpose: Stop a seg-fault when disassembling an EFI binary. +# Lifetime: Fixed in 2.33 +Patch33: binutils-disassembling-efi-files.patch + +# Purpose: Fix a bug handling 8-bit displacements in some x86 insns. +# Lifetime: Fixed in 2.32 +Patch34: binutils-x86-no-scale-8bit-displacements.patch + +# Purpose: Fix a stack exhaustion problem in libiberty's name demangling code. +# Lifetime: Fixed in 2.33 +Patch35: 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 +Patch36: binutils-aarch64-gold-PLT-for-MOVW_ABS.patch + # NOTE!!! Don't add cross-binutils patches here as "binutils-xxx". Name them # cross-binutils-xxx instead! @@ -339,7 +393,19 @@ cd %{srcdir} %patch21 -p1 %patch22 -p1 %patch23 -p1 - +%patch24 -p1 +%patch25 -p1 +%patch26 -p1 +%patch27 -p1 +%patch28 -p1 +%patch29 -p1 +%patch30 -p1 +%patch31 -p1 +%patch32 -p1 +%patch33 -p1 +%patch34 -p1 +%patch35 -p1 +%patch36 -p1 # We cannot run autotools as there is an exact requirement of autoconf-2.59. @@ -812,6 +878,9 @@ cd - %do_files xtensa-linux-gnu %{build_xtensa} %changelog +* Sun May 26 2019 Peter Robinson 2.31.1-3 +- Sync with binutils-2.31.1-31 + * Thu Jan 31 2019 Fedora Release Engineering - 2.31.1-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild