From 7d817f6ba94da48a037a1791ca9653ecb8f00aab Mon Sep 17 00:00:00 2001 From: David Howells Date: May 16 2017 13:56:02 +0000 Subject: Sync with binutils-2.28-6 --- diff --git a/binutils-2.28-dynamic-section-warning.patch b/binutils-2.28-dynamic-section-warning.patch new file mode 100644 index 0000000..804286c --- /dev/null +++ b/binutils-2.28-dynamic-section-warning.patch @@ -0,0 +1,33 @@ +diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c +--- binutils.orig/binutils/readelf.c 2017-03-20 17:06:41.260789454 +0000 ++++ binutils-2.28/binutils/readelf.c 2017-03-20 17:08:09.181289807 +0000 +@@ -4965,12 +4965,6 @@ process_program_headers (FILE * file) + section in the DYNAMIC segment. */ + dynamic_addr = segment->p_offset; + dynamic_size = segment->p_filesz; +- /* PR binutils/17512: Avoid corrupt dynamic section info in the segment. */ +- if (dynamic_addr + dynamic_size >= current_file_size) +- { +- error (_("the dynamic segment offset + size exceeds the size of the file\n")); +- dynamic_addr = dynamic_size = 0; +- } + + /* Try to locate the .dynamic section. If there is + a section header table, we can easily locate it. */ +@@ -5005,6 +4999,16 @@ process_program_headers (FILE * file) + warn (_("the .dynamic section is not the first section" + " in the dynamic segment.\n")); + } ++ ++ /* PR binutils/17512: Avoid corrupt dynamic section info in the ++ segment. Check this after matching against the section headers ++ so we don't warn on debuginfo file (which have NOBITS .dynamic ++ sections). */ ++ if (dynamic_addr + dynamic_size >= current_file_size) ++ { ++ error (_("the dynamic segment offset + size exceeds the size of the file\n")); ++ dynamic_addr = dynamic_size = 0; ++ } + break; + + case PT_INTERP: diff --git a/binutils-gnu-build-notes.patch b/binutils-gnu-build-notes.patch index 4772f0a..ae6d5e5 100644 --- a/binutils-gnu-build-notes.patch +++ b/binutils-gnu-build-notes.patch @@ -1,6 +1,6 @@ diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.28/binutils/doc/binutils.texi ---- binutils.orig/binutils/doc/binutils.texi 2017-03-03 10:36:54.749752520 +0000 -+++ binutils-2.28/binutils/doc/binutils.texi 2017-03-03 10:55:09.843757253 +0000 +--- binutils.orig/binutils/doc/binutils.texi 2017-03-20 17:03:56.166605442 +0000 ++++ binutils-2.28/binutils/doc/binutils.texi 2017-03-20 17:04:07.688408917 +0000 @@ -1140,6 +1140,7 @@ objcopy [@option{-F} @var{bfdname}|@opti [@option{--compress-debug-sections}] [@option{--decompress-debug-sections}] @@ -21,8 +21,8 @@ diff -rup binutils.orig/binutils/doc/binutils.texi binutils-2.28/binutils/doc/bi @itemx --version Show the version number of @command{objcopy}. diff -rup binutils.orig/binutils/NEWS binutils-2.28/binutils/NEWS ---- binutils.orig/binutils/NEWS 2017-03-03 10:36:54.777751983 +0000 -+++ binutils-2.28/binutils/NEWS 2017-03-03 10:49:43.114021660 +0000 +--- binutils.orig/binutils/NEWS 2017-03-20 17:03:56.167605425 +0000 ++++ binutils-2.28/binutils/NEWS 2017-03-20 17:04:07.688408917 +0000 @@ -1,5 +1,8 @@ -*- text -*- @@ -33,8 +33,8 @@ diff -rup binutils.orig/binutils/NEWS binutils-2.28/binutils/NEWS * Add support for locating separate debug info files using the build-id diff -rup binutils.orig/binutils/objcopy.c binutils-2.28/binutils/objcopy.c ---- binutils.orig/binutils/objcopy.c 2017-03-03 10:36:54.780751925 +0000 -+++ binutils-2.28/binutils/objcopy.c 2017-03-03 10:54:00.510086591 +0000 +--- binutils.orig/binutils/objcopy.c 2017-03-20 17:03:56.167605425 +0000 ++++ binutils-2.28/binutils/objcopy.c 2017-03-20 17:04:07.718408405 +0000 @@ -30,6 +30,7 @@ #include "elf-bfd.h" #include "coff/internal.h" @@ -196,7 +196,7 @@ diff -rup binutils.orig/binutils/objcopy.c binutils-2.28/binutils/objcopy.c + } + + if (pnotes[0].namedata[0] != GNU_BUILD_ATTRIBUTE_TYPE_STRING -+ || strcmp (pnotes[0].namedata + 2, "1") != 0) ++ || pnotes[0].namedata[2] != '1') + { + err = _("bad GNU build attribute notes: version note not v1"); + goto done; @@ -502,8 +502,8 @@ diff -rup binutils.orig/binutils/objcopy.c binutils-2.28/binutils/objcopy.c add_specific_symbol (optarg, strip_specific_htab); break; diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c ---- binutils.orig/binutils/readelf.c 2017-03-03 10:36:54.907749491 +0000 -+++ binutils-2.28/binutils/readelf.c 2017-03-03 10:49:10.247651809 +0000 +--- binutils.orig/binutils/readelf.c 2017-03-20 17:03:56.164605476 +0000 ++++ binutils-2.28/binutils/readelf.c 2017-03-20 17:06:13.368265213 +0000 @@ -15557,6 +15557,10 @@ get_note_type (unsigned e_type) return _("NT_VERSION (version)"); case NT_ARCH: @@ -528,16 +528,16 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c default: { static char buff[64]; -@@ -15675,6 +15685,122 @@ get_gnu_elf_note_type (unsigned e_type) +@@ -15675,6 +15685,155 @@ get_gnu_elf_note_type (unsigned e_type) } } +static void -+decode_x86_isa (unsigned long bitmask) ++decode_x86_isa (unsigned int bitmask) +{ + while (bitmask) + { -+ unsigned long bit = bitmask & (- bitmask); ++ unsigned int bit = bitmask & (- bitmask); + + bitmask &= ~ bit; + switch (bit) @@ -560,7 +560,7 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c + case GNU_PROPERTY_X86_ISA_1_AVX512VL: printf ("AVX512VL"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512DQ: printf ("AVX512DQ"); break; + case GNU_PROPERTY_X86_ISA_1_AVX512BW: printf ("AVX512BW"); break; -+ default: printf (_(""), bit); break; ++ default: printf (_(""), bit); break; + } + if (bitmask) + printf (", "); @@ -576,73 +576,106 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c + + printf (_(" Properties: ")); + -+ if (pnote->descsz % size) ++ if (pnote->descsz < 8 || (pnote->descsz % size) != 0) + { + printf (_("\n"), pnote->descsz); + return; + } + -+ while (ptr < (ptr_end - (size * 2))) ++ while (1) + { -+ unsigned long j; -+ unsigned long type = byte_get (ptr, size); -+ unsigned long datasz = byte_get (ptr + size, size); ++ unsigned int j; ++ unsigned int type = byte_get (ptr, 4); ++ unsigned int datasz = byte_get (ptr + 4, 4); + -+ ptr += 2 * size; ++ ptr += 8; + -+ switch (type) ++ if ((ptr + datasz) > ptr_end) + { -+ case GNU_PROPERTY_STACK_SIZE: -+ printf (_("stack size: ")); -+ if (datasz != size || (ptr + size > ptr_end)) -+ printf (_(" "), datasz); -+ else -+ printf ("%#lx", (unsigned long) byte_get (ptr, size)); ++ printf (_("\n"), ++ type, datasz); + break; ++ } + -+ case GNU_PROPERTY_NO_COPY_ON_PROTECTED: -+ printf ("no copy on protected "); -+ if (datasz) -+ printf (_(" "), datasz); -+ break; ++ if (type >= GNU_PROPERTY_LOPROC && type <= GNU_PROPERTY_HIPROC) ++ { ++ if (elf_header.e_machine == EM_X86_64 ++ || elf_header.e_machine == EM_IAMCU ++ || elf_header.e_machine == EM_386) ++ { ++ switch (type) ++ { ++ case GNU_PROPERTY_X86_ISA_1_USED: ++ printf ("x86 ISA used: "); ++ if (datasz != 4) ++ printf (_(" "), datasz); ++ else ++ decode_x86_isa (byte_get (ptr, 4)); ++ goto next; ++ ++ case GNU_PROPERTY_X86_ISA_1_NEEDED: ++ printf ("x86 ISA needed: "); ++ if (datasz != 4) ++ printf (_(" "), datasz); ++ else ++ decode_x86_isa (byte_get (ptr, 4)); ++ goto next; ++ ++ default: ++ break; ++ } ++ } ++ } ++ else ++ { ++ switch (type) ++ { ++ case GNU_PROPERTY_STACK_SIZE: ++ printf (_("stack size: ")); ++ if (datasz != size) ++ printf (_(" "), datasz); ++ else ++ printf ("%#lx", (unsigned long) byte_get (ptr, size)); ++ goto next; + -+ case GNU_PROPERTY_X86_ISA_1_USED: -+ printf ("x86 ISA used: "); -+ if (datasz != size || (ptr + size > ptr_end)) -+ printf (_(" "), datasz); -+ else -+ decode_x86_isa (byte_get (ptr, size)); -+ break; ++ case GNU_PROPERTY_NO_COPY_ON_PROTECTED: ++ printf ("no copy on protected "); ++ if (datasz) ++ printf (_(" "), datasz); ++ goto next; + -+ case GNU_PROPERTY_X86_ISA_1_NEEDED: -+ printf ("x86 ISA needed: "); -+ if (datasz != size || (ptr + size > ptr_end)) -+ printf (_(" "), datasz); -+ else -+ decode_x86_isa (byte_get (ptr, size)); -+ break; -+ -+ default: -+ printf (_(" ptr_end) -+ { -+ printf (_("corrupt datasz: %#lx>\n"), datasz); ++ default: + break; + } -+ for (j = 0; j < datasz; ++j) -+ printf ("%02x ", ptr[j] & 0xff); -+ printf (">"); -+ break; + } + ++ if (type < GNU_PROPERTY_LOPROC) ++ printf (_(""); ++ ++next: + ptr += ((datasz + (size - 1)) & ~ (size - 1)); -+ if (ptr < (ptr_end - (size * 2))) ++ if (ptr == ptr_end) ++ break; ++ else + { + if (do_wide) + printf (", "); + else + printf ("\n\t"); + } ++ ++ if (ptr > (ptr_end - 8)) ++ { ++ printf (_("\n"), pnote->descsz); ++ break; ++ } + } + + printf ("\n"); @@ -651,7 +684,7 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c static int print_gnu_note (Elf_Internal_Note *pnote) { -@@ -15775,6 +15901,10 @@ print_gnu_note (Elf_Internal_Note *pnote +@@ -15775,6 +15934,10 @@ print_gnu_note (Elf_Internal_Note *pnote } break; @@ -662,119 +695,171 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c default: /* Handle unrecognised types. An error message should have already been created by get_gnu_elf_note_type(), so all that we need to do is to -@@ -16164,15 +16294,300 @@ print_ia64_vms_note (Elf_Internal_Note * +@@ -16164,15 +16327,370 @@ print_ia64_vms_note (Elf_Internal_Note * return 1; } ++/* Print the name of the symbol associated with a build attribute ++ that is attached to address OFFSET. */ ++ +static bfd_boolean -+print_gnu_build_attribute_description (Elf_Internal_Note * pnote, -+ FILE * file, -+ Elf_Internal_Shdr * section ATTRIBUTE_UNUSED) ++print_symbol_for_build_attribute (FILE * file, ++ unsigned long offset, ++ bfd_boolean is_open_attr) +{ -+ static unsigned long global_offset = 0; -+ unsigned long i; -+ unsigned long strtab_size = 0; -+ char * strtab = NULL; -+ Elf_Internal_Sym * symtab = NULL; -+ unsigned long nsyms = 0; -+ Elf_Internal_Shdr * symsec = NULL; -+ unsigned int desc_size = is_32bit_elf ? 4 : 8; -+ -+ if (pnote->descsz == 0) ++ static FILE * saved_file = NULL; ++ static char * strtab; ++ static unsigned long strtablen; ++ static Elf_Internal_Sym * symtab; ++ static unsigned long nsyms; ++ Elf_Internal_Sym * saved_sym = NULL; ++ Elf_Internal_Sym * sym; ++ ++ if (saved_file == NULL || file != saved_file) + { -+ printf (_(" Applies from offset %#lx\n"), global_offset); -+ return TRUE; -+ } ++ Elf_Internal_Shdr * symsec; + -+ if (pnote->descsz != desc_size) -+ { -+ error (_(" \n"), pnote->descsz); -+ printf (_(" ")); -+ return FALSE; -+ } -+ -+ /* Load the symbols. */ -+ for (symsec = section_headers; -+ symsec < section_headers + elf_header.e_shnum; -+ symsec ++) -+ { -+ if (symsec->sh_type == SHT_SYMTAB) ++ /* Load the symbol and string sections. */ ++ for (symsec = section_headers; ++ symsec < section_headers + elf_header.e_shnum; ++ symsec ++) + { -+ symtab = GET_ELF_SYMBOLS (file, symsec, & nsyms); -+ -+ if (symsec->sh_link < elf_header.e_shnum) ++ if (symsec->sh_type == SHT_SYMTAB) + { -+ Elf_Internal_Shdr * strtab_sec = section_headers + symsec->sh_link; ++ symtab = GET_ELF_SYMBOLS (file, symsec, & nsyms); ++ ++ if (symsec->sh_link < elf_header.e_shnum) ++ { ++ Elf_Internal_Shdr * strtab_sec = section_headers + symsec->sh_link; + -+ strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset, -+ 1, strtab_sec->sh_size, -+ _("string table")); -+ strtab_size = strtab != NULL ? strtab_sec->sh_size : 0; ++ strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset, ++ 1, strtab_sec->sh_size, ++ _("string table")); ++ strtablen = strtab != NULL ? strtab_sec->sh_size : 0; ++ } + } + } ++ saved_file = file; + } + -+ printf (_(" Applies from offset")); -+ -+ for (i = 0; i < pnote->descsz; i += desc_size) ++ if (symtab == NULL || strtab == NULL) + { -+ Elf_Internal_Sym * saved_sym = NULL; -+ Elf_Internal_Sym * sym; -+ unsigned long offset; ++ printf ("\n"); ++ return FALSE; ++ } + -+ offset = byte_get ((unsigned char *) pnote->descdata + i, desc_size); ++ /* Find a symbol whose value matches offset. */ ++ for (sym = symtab; sym < symtab + nsyms; sym ++) ++ if (sym->st_value == offset) ++ { ++ if (sym->st_name >= strtablen) ++ /* Huh ? This should not happen. */ ++ continue; + -+ if (i + desc_size == pnote->descsz) -+ printf (_(" %#lx"), offset); -+ else -+ printf (_(" %#lx, "), offset); ++ if (strtab[sym->st_name] == 0) ++ continue; + -+ if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN) -+ global_offset = offset; ++ if (is_open_attr) ++ { ++ /* For OPEN attributes we prefer GLOBAL over LOCAL symbols ++ and FILE or OBJECT symbols over NOTYPE symbols. We skip ++ FUNC symbols entirely. */ ++ switch (ELF_ST_TYPE (sym->st_info)) ++ { ++ case STT_FILE: ++ saved_sym = sym; ++ /* We can stop searching now. */ ++ sym = symtab + nsyms; ++ continue; + -+ if (symtab == NULL || strtab == NULL) -+ continue; ++ case STT_OBJECT: ++ saved_sym = sym; ++ continue; + -+ /* Find a symbol whose value matches offset. */ -+ for (sym = symtab; sym < symtab + nsyms; sym ++) -+ if (sym->st_value == offset) -+ { -+ if (sym->st_name < strtab_size) ++ case STT_FUNC: ++ /* Ignore function symbols. */ ++ continue; ++ ++ default: ++ break; ++ } ++ ++ switch (ELF_ST_BIND (sym->st_info)) + { -+ if (strtab[sym->st_name] == 0) -+ continue; -+ -+ if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN) -+ { -+ /* For OPEN attributes we prefer GLOBAL symbols, if there -+ is one that matches. But keep a record of a matching -+ LOCAL symbol, just in case that is all that we can find. */ -+ if (ELF_ST_BIND (sym->st_info) == STB_LOCAL) -+ { -+ saved_sym = sym; -+ continue; -+ } -+ printf (_(" (file: %s)"), strtab + sym->st_name); -+ } -+ else if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) -+ continue; -+ else -+ printf (_(" (function: %s)"), strtab + sym->st_name); ++ case STB_GLOBAL: ++ if (saved_sym == NULL ++ || ELF_ST_TYPE (saved_sym->st_info) != STT_OBJECT) ++ saved_sym = sym; ++ break; ++ ++ case STB_LOCAL: ++ if (saved_sym == NULL) ++ saved_sym = sym; ++ break; ++ ++ default: + break; + } + } ++ else ++ { ++ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC) ++ continue; ++ ++ saved_sym = sym; ++ break; ++ } ++ } + -+ if (sym == symtab + nsyms) ++ printf (" (%s: %s)\n", ++ is_open_attr ? _("file") : _("func"), ++ saved_sym ? strtab + saved_sym->st_name : _(")")); ++ return TRUE; ++} ++ ++static bfd_boolean ++print_gnu_build_attribute_description (Elf_Internal_Note * pnote, ++ FILE * file) ++{ ++ static unsigned long global_offset = 0; ++ unsigned long offset; ++ unsigned int desc_size = is_32bit_elf ? 4 : 8; ++ bfd_boolean is_open_attr = pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN; ++ ++ if (pnote->descsz == 0) ++ { ++ if (is_open_attr) + { -+ if (saved_sym) -+ printf (_(" (file: %s)"), strtab + saved_sym->st_name); -+ else -+ printf (_(" ()")); ++ printf (_(" Applies from offset %#lx\n"), global_offset); ++ return TRUE; ++ } ++ else ++ { ++ printf (_(" Applies to func at %#lx"), global_offset); ++ return print_symbol_for_build_attribute (file, global_offset, is_open_attr); + } + } + -+ printf ("\n"); -+ return TRUE; ++ if (pnote->descsz != desc_size) ++ { ++ error (_(" \n"), pnote->descsz); ++ printf (_(" ")); ++ return FALSE; ++ } ++ ++ offset = byte_get ((unsigned char *) pnote->descdata, desc_size); ++ ++ if (is_open_attr) ++ { ++ printf (_(" Applies from offset %#lx"), offset); ++ global_offset = offset; ++ } ++ else ++ { ++ printf (_(" Applies to func at %#lx"), offset); ++ } ++ ++ return print_symbol_for_build_attribute (file, offset, is_open_attr); +} + +static bfd_boolean @@ -821,7 +906,7 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c + break; + case GNU_BUILD_ATTRIBUTE_STACK_PROT: + text = _(""); -+ expected_types = "!+"; ++ expected_types = "!+*"; + ++ name; + break; + case GNU_BUILD_ATTRIBUTE_RELRO: @@ -849,6 +934,11 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c + expected_types = "*"; + ++ name; + break; ++ case GNU_BUILD_ATTRIBUTE_SHORT_ENUM: ++ text = _(""); ++ expected_types = "!+"; ++ ++ name; ++ break; + + default: + if (ISPRINT (* name)) @@ -857,9 +947,9 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c + + if (len > left && ! do_wide) + len = left; -+ printf ("%.*s ", len, name); ++ printf ("%.*s:", len, name); + left -= len; -+ name += len + 1; ++ name += len; + } + else + { @@ -878,7 +968,7 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c + } + + if (strchr (expected_types, name_type) == NULL) -+ warn (_("attribute does not have the expected type\n")); ++ warn (_("attribute does not have an expected type (%c)\n"), name_type); + + if ((unsigned long)(name - pnote->namedata) > pnote->namesz) + { @@ -895,43 +985,57 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c + { + case GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC: + { -+ unsigned int bytes = pnote->namesz - (name - pnote->namedata); -+ unsigned long val = 0; -+ unsigned int shift = 0; ++ unsigned int bytes = pnote->namesz - (name - pnote->namedata); ++ unsigned long val = 0; ++ unsigned int shift = 0; ++ char * decoded = NULL; + + while (bytes --) + { -+ val |= ((* name ++) << shift); ++ unsigned long byte = (* name ++) & 0xff; ++ ++ val |= byte << shift; + shift += 8; + } + -+ if (name_attribute == GNU_BUILD_ATTRIBUTE_PIC) ++ switch (name_attribute) + { -+ char * pic_type = NULL; -+ ++ case GNU_BUILD_ATTRIBUTE_PIC: + switch (val) + { -+ case 0: pic_type = "static"; break; -+ case 1: pic_type = "pic"; break; -+ case 2: pic_type = "PIC"; break; -+ case 3: pic_type = "pie"; break; -+ case 4: pic_type = "PIE"; break; ++ case 0: decoded = "static"; break; ++ case 1: decoded = "pic"; break; ++ case 2: decoded = "PIC"; break; ++ case 3: decoded = "pie"; break; ++ case 4: decoded = "PIE"; break; ++ default: break; + } -+ -+ if (pic_type != NULL) ++ break; ++ case GNU_BUILD_ATTRIBUTE_STACK_PROT: ++ switch (val) + { -+ if (do_wide) -+ left -= printf ("%s", pic_type); -+ else -+ left -= printf ("%-.*s", left, pic_type); -+ break; ++ /* Based upon the SPCT_FLAG_xxx enum values in gcc/cfgexpand.c. */ ++ case 0: decoded = "off"; break; ++ case 1: decoded = "on"; break; ++ case 2: decoded = "all"; break; ++ case 3: decoded = "strong"; break; ++ case 4: decoded = "explicit"; break; ++ default: break; + } ++ break; ++ default: ++ break; + } + -+ if (do_wide) -+ left -= printf ("0x%lx", val); ++ if (decoded != NULL) ++ print_symbol (-left, decoded); + else -+ left -= printf ("0x%-.*lx", left, val); ++ { ++ if (do_wide) ++ left -= printf ("0x%lx", val); ++ else ++ left -= printf ("0x%-.*lx", left, val); ++ } + } + break; + case GNU_BUILD_ATTRIBUTE_TYPE_STRING: @@ -961,12 +1065,11 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c - FILE * file ATTRIBUTE_UNUSED, - Elf_Internal_Shdr * section ATTRIBUTE_UNUSED) +process_note (Elf_Internal_Note * pnote, -+ FILE * file, -+ Elf_Internal_Shdr * section) ++ FILE * file) { const char * name = pnote->namesz ? pnote->namedata : "(NONE)"; const char * nt; -@@ -16218,8 +16633,17 @@ process_note (Elf_Internal_Note * pnote, +@@ -16218,8 +16736,17 @@ process_note (Elf_Internal_Note * pnote, nt = get_note_type (pnote->type); printf (" "); @@ -986,13 +1089,13 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c if (const_strneq (pnote->namedata, "IPF/VMS")) return print_ia64_vms_note (pnote); -@@ -16229,17 +16653,22 @@ process_note (Elf_Internal_Note * pnote, +@@ -16229,17 +16756,22 @@ process_note (Elf_Internal_Note * pnote, return print_stapsdt_note (pnote); else if (const_strneq (pnote->namedata, "CORE")) return print_core_note (pnote); + else if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN + || pnote->type == NT_GNU_BUILD_ATTRIBUTE_FUNC) -+ return print_gnu_build_attribute_description (pnote, file, section); ++ return print_gnu_build_attribute_description (pnote, file); - else if (pnote->descsz) + if (pnote->descsz) @@ -1011,13 +1114,30 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c return 1; } +@@ -16369,14 +16901,14 @@ process_notes_at (FILE * fi + break; + } + +- strncpy (temp, inote.namedata, inote.namesz); ++ memcpy (temp, inote.namedata, inote.namesz); + temp[inote.namesz] = 0; + + /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */ + inote.namedata = temp; + } + +- res &= process_note (& inote, file, section); ++ res &= process_note (& inote, file); + + if (temp != NULL) + { Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-32.d Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-32.s Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-64.d Only in binutils-2.28/binutils/testsuite/binutils-all: note-2-64.s diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.28/binutils/testsuite/binutils-all/objcopy.exp ---- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2017-03-03 10:36:54.973748226 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/objcopy.exp 2017-03-03 10:56:08.251637396 +0000 +--- binutils.orig/binutils/testsuite/binutils-all/objcopy.exp 2017-03-20 17:03:56.174605306 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/objcopy.exp 2017-03-20 17:04:07.721408353 +0000 @@ -1053,6 +1053,11 @@ if [is_elf_format] { run_dump_test "group-6" run_dump_test "copy-1" @@ -1031,8 +1151,8 @@ diff -rup binutils.orig/binutils/testsuite/binutils-all/objcopy.exp binutils-2.2 run_dump_test "copy-2" diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h ---- binutils.orig/include/elf/common.h 2017-03-03 10:36:57.673696476 +0000 -+++ binutils-2.28/include/elf/common.h 2017-03-03 10:38:21.515089483 +0000 +--- binutils.orig/include/elf/common.h 2017-03-20 17:03:56.417601161 +0000 ++++ binutils-2.28/include/elf/common.h 2017-03-20 17:04:07.733408149 +0000 @@ -538,6 +538,7 @@ /* #define SHF_MASKOS 0x0F000000 *//* OS-specific semantics */ @@ -1041,7 +1161,7 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h #define SHF_MASKPROC 0xF0000000 /* Processor-specific semantics */ /* This used to be implemented as a processor specific section flag. -@@ -669,6 +670,51 @@ +@@ -669,6 +670,62 @@ #define NT_GNU_HWCAP 2 /* Used by ld.so and kernel vDSO. */ #define NT_GNU_BUILD_ID 3 /* Generated by ld --build-id. */ #define NT_GNU_GOLD_VERSION 4 /* Generated by gold. */ @@ -1062,6 +1182,7 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h +#define GNU_BUILD_ATTRIBUTE_TOOL 5 +#define GNU_BUILD_ATTRIBUTE_ABI 6 +#define GNU_BUILD_ATTRIBUTE_PIC 7 ++#define GNU_BUILD_ATTRIBUTE_SHORT_ENUM 8 + +#define NOTE_GNU_PROPERTY_SECTION_NAME ".note.gnu.property" +#define GNU_BUILD_ATTRS_SECTION_NAME ".gnu.build.attributes" @@ -1069,6 +1190,16 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h +/* Values used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0). */ +#define GNU_PROPERTY_STACK_SIZE 1 +#define GNU_PROPERTY_NO_COPY_ON_PROTECTED 2 ++ ++/* Processor-specific semantics, lo */ ++#define GNU_PROPERTY_LOPROC 0xc0000000 ++/* Processor-specific semantics, hi */ ++#define GNU_PROPERTY_HIPROC 0xdfffffff ++/* Application-specific semantics, lo */ ++#define GNU_PROPERTY_LOUSER 0xe0000000 ++/* Application-specific semantics, hi */ ++#define GNU_PROPERTY_HIUSER 0xffffffff ++ +#define GNU_PROPERTY_X86_ISA_1_USED 0xc0000000 +#define GNU_PROPERTY_X86_ISA_1_NEEDED 0xc0000001 + @@ -1093,9 +1224,9 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h /* Values used in GNU .note.ABI-tag notes (NT_GNU_ABI_TAG). */ #define GNU_ABI_TAG_LINUX 0 ---- /dev/null 2017-03-03 08:02:17.248891465 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.s 2017-03-03 10:56:46.811898078 +0000 -@@ -0,0 +1,93 @@ +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.s 2017-03-20 17:16:18.922951480 +0000 +@@ -0,0 +1,95 @@ + .text + .org 0x100 + .global note1.s @@ -1137,6 +1268,8 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h + + .global note2.s +note2.s: ++ .type func1, STT_FUNC ++func1: + .word 0x100 + + .pushsection .gnu.build.attributes, "0x100000", %note @@ -1189,8 +1322,8 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h + .popsection + + ---- /dev/null 2017-03-03 08:02:17.248891465 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.d 2017-03-03 10:56:46.811898078 +0000 +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-32.d 2017-03-20 17:16:18.922951480 +0000 @@ -0,0 +1,17 @@ +#PROG: objcopy +#readelf: --notes --wide @@ -1207,10 +1340,10 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h +[ ]+\*0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 +[ ]+\$1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\) +[ ]+!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. -+[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies from offset 0x10. ++[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\) +#... ---- /dev/null 2017-03-03 08:02:17.248891465 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.d 2017-03-03 10:56:52.235794085 +0000 +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.d 2017-03-20 17:16:18.922951480 +0000 @@ -0,0 +1,17 @@ +#PROG: objcopy +#readelf: --notes --wide @@ -1227,11 +1360,11 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h +[ ]+\*0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100 +[ ]+\$1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\) +[ ]+!false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. -+[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies from offset 0x10. ++[ ]+\*pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies to func at 0x10. \(func: func1\) +#... ---- /dev/null 2017-03-03 08:02:17.248891465 +0000 -+++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.s 2017-03-03 10:56:52.235794085 +0000 -@@ -0,0 +1,94 @@ +--- /dev/null 2017-03-20 08:02:04.287194455 +0000 ++++ binutils-2.28/binutils/testsuite/binutils-all/note-2-64.s 2017-03-20 17:16:18.922951480 +0000 +@@ -0,0 +1,97 @@ + .text + .org 0x100 + .global note1.s @@ -1273,8 +1406,11 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h + + .global note2.s +note2.s: ++ .global func1 ++ .type func1, STT_FUNC ++func1: + .word 0x100 -+ ++ + .pushsection .gnu.build.attributes, "0x100000", %note + .dc.l 4 + .dc.l 8 @@ -1326,25 +1462,3 @@ diff -rup binutils.orig/include/elf/common.h binutils-2.28/include/elf/common.h + .popsection + + ---- binutils.orig/binutils/readelf.c 2017-03-06 16:55:38.741902216 +0000 -+++ binutils-2.28/binutils/readelf.c 2017-03-06 16:55:50.435746360 +0000 -@@ -16529,7 +16529,9 @@ print_gnu_build_attribute_name (Elf_Inte - - while (bytes --) - { -- val |= ((* name ++) << shift); -+ unsigned long byte = (* name ++) & 0xff; -+ -+ val |= byte << shift; - shift += 8; - } - -@@ -16798,7 +16800,7 @@ process_notes_at (FILE * fi - break; - } - -- strncpy (temp, inote.namedata, inote.namesz); -+ memcpy (temp, inote.namedata, inote.namesz); - temp[inote.namesz] = 0; - - /* warn (_("'%s' NOTE name not properly null terminated\n"), temp); */ diff --git a/cross-binutils.spec b/cross-binutils.spec index f0afbbd..bfa824d 100644 --- a/cross-binutils.spec +++ b/cross-binutils.spec @@ -57,7 +57,7 @@ Summary: A GNU collection of cross-compilation binary utilities Name: %{cross}-binutils Version: 2.28 -Release: 1%{?dist} +Release: 2%{?dist} License: GPLv3+ Group: Development/Tools URL: http://sources.redhat.com/binutils @@ -103,6 +103,8 @@ Patch17: binutils-gnu-build-notes.patch Patch18: binutils-2.28-gas-comp_dir.patch # Import fix for PR 21124 and 20519 Patch19: binutils-2.28-ppc-dynamic-relocs.patch +# Have readelf skip checks of the dynamic section when its type is SHT_NOBITS. +Patch20: binutils-2.28-dynamic-section-warning.patch # NOTE!!! Don't add cross-binutils patches here as "binutils-xxx". Name them # cross-binutils-xxx instead! @@ -246,6 +248,7 @@ cd %{srcdir} %patch17 -p1 %patch18 -p1 %patch19 -p1 +%patch20 -p1 %if %{build_sh64} %patch100 -p1 -b .sh64-fixup~ @@ -715,6 +718,9 @@ rm -rf %{buildroot} %do_files xtensa-linux-gnu %{build_xtensa} %changelog +* Tue May 16 2017 David Howells - 2.28-2 +- Sync with binutils-2.28-6. + * Wed Mar 15 2017 David Howells - 2.28-1 - Sync with binutils-2.28-4.