Import FSF binutils patch to fix running readelf on debug info binaries.

Update GNU BUILD NOTES patch.
Resolves: #1434050
This commit is contained in:
Nick Clifton 2017-03-20 17:27:38 +00:00
parent 40ca8bea3c
commit 3b2ebb27b1
3 changed files with 381 additions and 226 deletions

View File

@ -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:

View File

@ -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 (_("<unknown: %lx>"), bit); break;
+ default: printf (_("<unknown: %x>"), 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 (_("<corrupt GNU_PROPERTY_TYPE, size = %#lx>\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 (_("<corrupt length: %#lx> "), datasz);
+ else
+ printf ("%#lx", (unsigned long) byte_get (ptr, size));
+ break;
+
+ case GNU_PROPERTY_NO_COPY_ON_PROTECTED:
+ printf ("no copy on protected ");
+ if (datasz)
+ printf (_("<corrupt length: %#lx> "), datasz);
+ break;
+
+ case GNU_PROPERTY_X86_ISA_1_USED:
+ printf ("x86 ISA used: ");
+ if (datasz != size || (ptr + size > ptr_end))
+ printf (_("<corrupt length: %#lx> "), datasz);
+ else
+ decode_x86_isa (byte_get (ptr, size));
+ break;
+
+ case GNU_PROPERTY_X86_ISA_1_NEEDED:
+ printf ("x86 ISA needed: ");
+ if (datasz != size || (ptr + size > ptr_end))
+ printf (_("<corrupt length: %#lx> "), datasz);
+ else
+ decode_x86_isa (byte_get (ptr, size));
+ break;
+
+ default:
+ printf (_("<unknown type %#lx data: "), type);
+ if (ptr + datasz > ptr_end)
+ {
+ printf (_("corrupt datasz: %#lx>\n"), datasz);
+ break;
+ }
+ for (j = 0; j < datasz; ++j)
+ printf ("%02x ", ptr[j] & 0xff);
+ printf (">");
+ printf (_("<corrupt type (%#x) datasz: %#x>\n"),
+ type, datasz);
+ break;
+ }
+
+ if (type >= GNU_PROPERTY_LOPROC && type <= GNU_PROPERTY_HIPROC)
+ {
+ if (elf_header.e_machine == EM_X86_64
+ || elf_header.e_machine == EM_IAMCU
+ || elf_header.e_machine == EM_386)
+ {
+ switch (type)
+ {
+ case GNU_PROPERTY_X86_ISA_1_USED:
+ printf ("x86 ISA used: ");
+ if (datasz != 4)
+ printf (_("<corrupt length: %#x> "), 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 (_("<corrupt length: %#x> "), 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 (_("<corrupt length: %#x> "), datasz);
+ else
+ printf ("%#lx", (unsigned long) byte_get (ptr, size));
+ goto next;
+
+ case GNU_PROPERTY_NO_COPY_ON_PROTECTED:
+ printf ("no copy on protected ");
+ if (datasz)
+ printf (_("<corrupt length: %#x> "), datasz);
+ goto next;
+
+ default:
+ break;
+ }
+ }
+
+ if (type < GNU_PROPERTY_LOPROC)
+ printf (_("<unknown type %#x data: "), type);
+ else if (type < GNU_PROPERTY_LOUSER)
+ printf (_("<procesor-specific type %#x data: "), type);
+ else
+ printf (_("<application-specific type %#x data: "), type);
+ for (j = 0; j < datasz; ++j)
+ printf ("%02x ", ptr[j] & 0xff);
+ 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 (_("<corrupt descsz: %#lx>\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,28 +695,149 @@ 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_symbol_for_build_attribute (FILE * file,
+ unsigned long offset,
+ bfd_boolean is_open_attr)
+{
+ static FILE * saved_file = NULL;
+ static char * strtab;
+ static unsigned long strtablen;
+ static Elf_Internal_Sym * symtab;
+ static unsigned long nsyms;
+ Elf_Internal_Sym * saved_sym = NULL;
+ Elf_Internal_Sym * sym;
+
+ if (saved_file == NULL || file != saved_file)
+ {
+ Elf_Internal_Shdr * symsec;
+
+ /* Load the symbol and string sections. */
+ for (symsec = section_headers;
+ symsec < section_headers + elf_header.e_shnum;
+ symsec ++)
+ {
+ if (symsec->sh_type == SHT_SYMTAB)
+ {
+ symtab = GET_ELF_SYMBOLS (file, symsec, & nsyms);
+
+ if (symsec->sh_link < elf_header.e_shnum)
+ {
+ Elf_Internal_Shdr * strtab_sec = section_headers + symsec->sh_link;
+
+ strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset,
+ 1, strtab_sec->sh_size,
+ _("string table"));
+ strtablen = strtab != NULL ? strtab_sec->sh_size : 0;
+ }
+ }
+ }
+ saved_file = file;
+ }
+
+ if (symtab == NULL || strtab == NULL)
+ {
+ printf ("\n");
+ return FALSE;
+ }
+
+ /* Find a symbol whose value matches offset. */
+ for (sym = symtab; sym < symtab + nsyms; sym ++)
+ if (sym->st_value == offset)
+ {
+ if (sym->st_name >= strtablen)
+ /* Huh ? This should not happen. */
+ continue;
+
+ if (strtab[sym->st_name] == 0)
+ continue;
+
+ if (is_open_attr)
+ {
+ /* For OPEN attributes we prefer GLOBAL over LOCAL symbols
+ and FILE or OBJECT symbols over NOTYPE symbols. We skip
+ FUNC symbols entirely. */
+ switch (ELF_ST_TYPE (sym->st_info))
+ {
+ case STT_FILE:
+ saved_sym = sym;
+ /* We can stop searching now. */
+ sym = symtab + nsyms;
+ continue;
+
+ case STT_OBJECT:
+ saved_sym = sym;
+ continue;
+
+ case STT_FUNC:
+ /* Ignore function symbols. */
+ continue;
+
+ default:
+ break;
+ }
+
+ switch (ELF_ST_BIND (sym->st_info))
+ {
+ case STB_GLOBAL:
+ if (saved_sym == NULL
+ || ELF_ST_TYPE (saved_sym->st_info) != STT_OBJECT)
+ saved_sym = sym;
+ break;
+
+ case STB_LOCAL:
+ if (saved_sym == NULL)
+ saved_sym = sym;
+ break;
+
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if (ELF_ST_TYPE (sym->st_info) != STT_FUNC)
+ continue;
+
+ saved_sym = sym;
+ break;
+ }
+ }
+
+ printf (" (%s: %s)\n",
+ is_open_attr ? _("file") : _("func"),
+ saved_sym ? strtab + saved_sym->st_name : _("<no symbol found>)"));
+ return TRUE;
+}
+
+static bfd_boolean
+print_gnu_build_attribute_description (Elf_Internal_Note * pnote,
+ FILE * file,
+ Elf_Internal_Shdr * section ATTRIBUTE_UNUSED)
+ FILE * file)
+{
+ 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;
+ 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 (pnote->descsz == 0)
+ {
+ printf (_(" Applies from offset %#lx\n"), global_offset);
+ return TRUE;
+ if (is_open_attr)
+ {
+ printf (_(" Applies from offset %#lx\n"), global_offset);
+ return TRUE;
+ }
+ else
+ {
+ printf (_(" Applies to func at %#lx"), global_offset);
+ return print_symbol_for_build_attribute (file, global_offset, is_open_attr);
+ }
+ }
+
+ if (pnote->descsz != desc_size)
@ -693,88 +847,19 @@ diff -rup binutils.orig/binutils/readelf.c binutils-2.28/binutils/readelf.c
+ return FALSE;
+ }
+
+ /* Load the symbols. */
+ for (symsec = section_headers;
+ symsec < section_headers + elf_header.e_shnum;
+ symsec ++)
+ offset = byte_get ((unsigned char *) pnote->descdata, desc_size);
+
+ if (is_open_attr)
+ {
+ if (symsec->sh_type == SHT_SYMTAB)
+ {
+ symtab = GET_ELF_SYMBOLS (file, symsec, & nsyms);
+
+ if (symsec->sh_link < elf_header.e_shnum)
+ {
+ Elf_Internal_Shdr * strtab_sec = section_headers + symsec->sh_link;
+
+ strtab = (char *) get_data (NULL, file, strtab_sec->sh_offset,
+ 1, strtab_sec->sh_size,
+ _("string table"));
+ strtab_size = strtab != NULL ? strtab_sec->sh_size : 0;
+ }
+ }
+ printf (_(" Applies from offset %#lx"), offset);
+ global_offset = offset;
+ }
+ else
+ {
+ printf (_(" Applies to func at %#lx"), offset);
+ }
+
+ printf (_(" Applies from offset"));
+
+ for (i = 0; i < pnote->descsz; i += desc_size)
+ {
+ Elf_Internal_Sym * saved_sym = NULL;
+ Elf_Internal_Sym * sym;
+ unsigned long offset;
+
+ offset = byte_get ((unsigned char *) pnote->descdata + i, desc_size);
+
+ if (i + desc_size == pnote->descsz)
+ printf (_(" %#lx"), offset);
+ else
+ printf (_(" %#lx, "), offset);
+
+ if (pnote->type == NT_GNU_BUILD_ATTRIBUTE_OPEN)
+ global_offset = offset;
+
+ if (symtab == NULL || strtab == NULL)
+ 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)
+ {
+ 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);
+ break;
+ }
+ }
+
+ if (sym == symtab + nsyms)
+ {
+ if (saved_sym)
+ printf (_(" (file: %s)"), strtab + saved_sym->st_name);
+ else
+ printf (_(" (<symbol name unknown>)"));
+ }
+ }
+
+ printf ("\n");
+ return TRUE;
+ 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 = _("<stack prot>");
+ 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 = _("<short enum>");
+ 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
+[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
+[ ]+\$<version>1[ ]+0x00000004[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\)
+[ ]+!<stack prot>false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10.
+[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies from offset 0x10.
+[ ]+\*<PIC>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
+[ ]+\*<ABI>0x0[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x100
+[ ]+\$<version>1[ ]+0x00000008[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10. \(file: note2.s\)
+[ ]+!<stack prot>false[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_OPEN[ ]+Applies from offset 0x10.
+[ ]+\*<PIC>pic[ ]+0x00000000[ ]+NT_GNU_BUILD_ATTRIBUTE_FUNC[ ]+Applies from offset 0x10.
+[ ]+\*<PIC>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); */

View File

@ -43,7 +43,7 @@
Summary: A GNU collection of binary utilities
Name: %{?cross}binutils%{?_with_debug:-debug}
Version: 2.28
Release: 4%{?dist}
Release: 5%{?dist}
License: GPLv3+
Group: Development/Tools
URL: http://sources.redhat.com/binutils
@ -87,6 +87,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
Provides: bundled(libiberty)
@ -227,6 +229,7 @@ using libelf instead of BFD.
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
# We cannot run autotools as there is an exact requirement of autoconf-2.59.
@ -593,6 +596,11 @@ exit 0
%endif # %{isnative}
%changelog
* Mon Mar 20 2017 Nick Clifton <nickc@redhat.com> 2.28-5
- Update GNU BUILD NOTES patch.
- Import FSF binutils patch to fix running readelf on debug info binaries.
(#1434050)
* Wed Mar 08 2017 Nick Clifton <nickc@redhat.com> 2.28-4
- Update GNU BUILD NOTES patch.
- Import FSF binutils patch to fix an abort with PowerPC dynamic relocs.