From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24279 invoked by alias); 21 Mar 2017 11:48:40 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Received: (qmail 24072 invoked by uid 89); 21 Mar 2017 11:48:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=colon X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Mar 2017 11:48:27 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 058794AEB5 for ; Tue, 21 Mar 2017 11:48:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 058794AEB5 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=nickc@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 058794AEB5 Received: from snowball.redhat.com (ovpn-117-137.ams2.redhat.com [10.36.117.137]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50C657F36C for ; Tue, 21 Mar 2017 11:48:23 +0000 (UTC) From: Nick Clifton To: binutils@sourceware.org Subject: Commit: Date: Tue, 21 Mar 2017 11:48:00 -0000 Message-ID: <877f3i4zqz.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2017-03/txt/msg00288.txt.bz2 Hi Guys, I am applying the patch below to update the binutils support for GNU BUILD notes. There are two changes - the version note can now contain extra version information covering the tools that produce the notes, and the stack protection notes can contain a numeric value indicating the type of stack protection requested. Cheers Nick binutils/ChangeLog 2017-03-21 Nick Clifton * readelf.c (print_gnu_build_attribute_name): Allow stack protection notes to contain numeric values. Use a colon rather than a space to separate a string name from its values. Decode the numeric value of a stack protection note. * objcopy.c (merge_gnu_build_notes): Allow version notes to contain extra text after the protocol version number. diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 868f122..4af4d92 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -1933,7 +1933,7 @@ merge_gnu_build_notes (bfd * abfd, asection * sec, bfd_size_type size, bfd_byte } 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; diff --git a/binutils/readelf.c b/binutils/readelf.c index 8b1d924..6ede239 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -16809,7 +16809,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) break; case GNU_BUILD_ATTRIBUTE_STACK_PROT: text = _(""); - expected_types = "!+"; + expected_types = "!+*"; ++ name; break; case GNU_BUILD_ATTRIBUTE_RELRO: @@ -16850,7 +16850,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) if (len > left && ! do_wide) len = left; - printf ("%.*s ", len, name); + printf ("%.*s:", len, name); left -= len; name += len; } @@ -16871,7 +16871,7 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) } 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) { @@ -16888,9 +16888,10 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) { 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 --) { @@ -16900,33 +16901,44 @@ print_gnu_build_attribute_name (Elf_Internal_Note * pnote) 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: