From: "H.J. Lu" <hongjiu.lu@intel.com>
To: binutils@sourceware.org
Subject: [committed, PATCH] Change pointers from char * to unsigned char *
Date: Fri, 15 May 2015 17:32:00 -0000 [thread overview]
Message-ID: <20150515173204.GA27799@intel.com> (raw)
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 <hongjiu.lu@intel.com>
+ * readelf.c (dump_section_as_strings): Change pointers from
+ char * to unsigned char *.
+
+2015-05-15 H.J. Lu <hongjiu.lu@intel.com>
+
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
reply other threads:[~2015-05-15 17:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150515173204.GA27799@intel.com \
--to=hongjiu.lu@intel.com \
--cc=binutils@sourceware.org \
--cc=hjl.tools@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).