public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Nick Clifton <nickc@redhat.com>, Binutils <binutils@sourceware.org>
Subject: [2.34][PATCH] Fix dwarf.c build with GCC 10
Date: Tue, 24 Mar 2020 05:14:44 -0700	[thread overview]
Message-ID: <CAMe9rOpdH_apzre9_o6QKFMW+PZPkL=k1o0fzBEUbqMDSgxodg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]

Hi Nick,

I am seeing the same error on Linux/x86-64 with GCC 10.  I'd like to
backport this patch to binutils 2.34.

-- 
H.J.

[-- Attachment #2: 0001-Fix-dwarf.c-build-with-GCC-10.patch --]
[-- Type: text/x-patch, Size: 1149 bytes --]

From 0cc14d3b95555549dec4416cd7c21375815ea422 Mon Sep 17 00:00:00 2001
From: Nick Clifton <nickc@redhat.com>
Date: Fri, 7 Feb 2020 12:49:42 +0000
Subject: [PATCH] Fix dwarf.c build with GCC 10

Silcence a compile time warning message building the binutils with
gcc-10.

	* dwarf.c (display_debug_lines_decoded): Force a NUL termination
	of the truncated file name.

(cherry picked from commit e1104d08fe2fbfabcfa98aa00525211e47548bd8)
---
 binutils/dwarf.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 35842f74b2..6ecfab5d5a 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -4905,6 +4905,11 @@ display_debug_lines_decoded (struct dwarf_section *  section,
 		  strncpy (newFileName,
 			   fileName + fileNameLength - MAX_FILENAME_LENGTH,
 			   MAX_FILENAME_LENGTH + 1);
+		  /* FIXME: This is to pacify gcc-10 which can warn that the
+		     strncpy above might leave a non-NUL terminated string
+		     in newFileName.  It won't, but gcc's analysis doesn't
+		     quite go far enough to discover this.  */
+		  newFileName[MAX_FILENAME_LENGTH] = 0;
 		}
 	      else
 		{
-- 
2.25.1


             reply	other threads:[~2020-03-24 12:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-24 12:14 H.J. Lu [this message]
2020-03-24 15:18 ` Nick Clifton

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='CAMe9rOpdH_apzre9_o6QKFMW+PZPkL=k1o0fzBEUbqMDSgxodg@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=nickc@redhat.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).