From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37976 invoked by alias); 15 May 2015 17:32:08 -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 37966 invoked by uid 89); 15 May 2015 17:32:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,NO_DNS_FOR_FROM,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mga14.intel.com Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 May 2015 17:32:06 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 15 May 2015 10:32:06 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([172.25.70.52]) by orsmga001.jf.intel.com with ESMTP; 15 May 2015 10:32:04 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 1000) id 5E6A720065D; Fri, 15 May 2015 10:32:04 -0700 (PDT) Date: Fri, 15 May 2015 17:32:00 -0000 From: "H.J. Lu" To: binutils@sourceware.org Subject: [committed, PATCH] Change pointers from char * to unsigned char * Message-ID: <20150515173204.GA27799@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-05/txt/msg00144.txt.bz2 GCC 4.2 complaints: cc1: warnings being treated as errors binutils/readelf.c:12057: warning: dereferencing type-punned pointer will break strict-aliasing rules This patch silences this GCC warning. * readelf.c (dump_section_as_strings): Change pointers from char * to unsigned char *. --- binutils/ChangeLog | 5 +++++ binutils/readelf.c | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 2328f6e..4813a89 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,5 +1,10 @@ 2015-05-15 H.J. Lu + * readelf.c (dump_section_as_strings): Change pointers from + char * to unsigned char *. + +2015-05-15 H.J. Lu + PR binutis/18386 * doc/binutils.texi: Document -Mamd64 and -Mintel64. diff --git a/binutils/readelf.c b/binutils/readelf.c index 4bb31eb..6369aa9 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -12004,13 +12004,14 @@ dump_section_as_strings (Elf_Internal_Shdr * section, FILE * file) { Elf_Internal_Shdr * relsec; bfd_size_type num_bytes; - char * data; - char * end; - char * real_start; - char * start; + unsigned char * data; + unsigned char * end; + unsigned char * real_start; + unsigned char * start; bfd_boolean some_strings_shown; - real_start = start = get_section_contents (section, file); + real_start = start = (unsigned char *) get_section_contents (section, + file); if (start == NULL) return; num_bytes = section->sh_size; @@ -12054,11 +12055,11 @@ dump_section_as_strings (Elf_Internal_Shdr * section, FILE * file) } if (uncompressed_size - && uncompress_section_contents ((unsigned char **) & start, + && uncompress_section_contents (& start, uncompressed_size, & new_size)) num_bytes = new_size; } - + /* If the section being dumped has relocations against it the user might be expecting these relocations to have been applied. Check for this case and issue a warning message in order to avoid confusion. @@ -12102,9 +12103,9 @@ dump_section_as_strings (Elf_Internal_Shdr * section, FILE * file) #endif if (maxlen > 0) { - print_symbol ((int) maxlen, data); + print_symbol ((int) maxlen, (const char *) data); putchar ('\n'); - data += strnlen (data, maxlen); + data += strnlen ((const char *) data, maxlen); } else { -- 1.9.3