public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout
@ 2021-05-11 14:36 Hans-Peter Nilsson
  2021-05-11 22:41 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Hans-Peter Nilsson @ 2021-05-11 14:36 UTC (permalink / raw)
  To: binutils

Committed as obvious.  I can't find f2f9554bf0d15 (the
offending patch) CC:ed to the list, so I can't quote it.
Also tested on an actual i686 (without the need for "-m32").

Building as ILP32 shows:

 gcc -m32 -DHAVE_CONFIG_H -I. -I/checkout/binutils  -I. -I/checkout/binutils -I../bfd -I/checkout/binutils/../bfd -I/checkout/binutils/../include -DLOCALEDIR="\"/usr/local/share/locale\"" -Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror -I/checkout/binutils/../zlib -g -O2   -MT dwarf.o -MD -MP -MF $depbase.Tpo -c -o dwarf.o /checkout/binutils/dwarf.c &&\
 mv -f $depbase.Tpo $depbase.Po
 In file included from /checkout/binutils/sysdep.h:101:0,
                  from /checkout/binutils/dwarf.c:21:
 /checkout/binutils/dwarf.c: In function 'process_abbrev_set':
 /checkout/binutils/dwarf.c:1072:15: error: format '%lx' expects argument of type 'long unsigned int', but argument 2 has type 'dwarf_vma {aka long long unsigned int}' [-Werror=format=]
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
                ^
 /checkout/binutils/dwarf.c:1072:13: note: in expansion of macro '_'
        warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
              ^
 cc1: all warnings being treated as errors
 Makefile:1101: recipe for target 'dwarf.o' failed

The recent commit, casting one of the terms, has an obvious
typo.  To wit, the (non-cast) term abbrev_size is a
dwarf_vma and causes the whole expression to (still) be 64
bits.

binutils:
	* dwarf.c (process_abbrev_set): Properly parenthesize before
	casting to unsigned long.
---
 binutils/ChangeLog | 5 +++++
 binutils/dwarf.c   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6703b16b2b0c..242563ed3a53 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-11  Hans-Peter Nilsson  <hp@axis.com>
+
+	* dwarf.c (process_abbrev_set): Properly parenthesize before
+	casting to unsigned long.
+
 2021-05-11  Alan Modra  <amodra@gmail.com>
 
 	PR 27845
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index aa48f69bbd45..8bc0acb270c2 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -1071,7 +1071,7 @@ process_abbrev_set (struct dwarf_section *section,
       /* PR 17531: file:4bcd9ce9.  */
       warn (_("Debug info is corrupted, abbrev size (%lx) is larger than "
 	      "abbrev section size (%lx)\n"),
-	      (unsigned long) abbrev_base + abbrev_size,
+	      (unsigned long) (abbrev_base + abbrev_size),
 	      (unsigned long) section->size);
       return NULL;
     }
-- 
2.11.0

brgds, H-P

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout
  2021-05-11 14:36 dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout Hans-Peter Nilsson
@ 2021-05-11 22:41 ` Alan Modra
  2021-05-18  6:45   ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2021-05-11 22:41 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

On Tue, May 11, 2021 at 04:36:19PM +0200, Hans-Peter Nilsson wrote:
> Committed as obvious.  I can't find f2f9554bf0d15 (the
> offending patch) CC:ed to the list, so I can't quote it.

I'm not sure how that happened.  I certainly meant to post the patch.

> The recent commit, casting one of the terms, has an obvious
> typo.  To wit, the (non-cast) term abbrev_size is a
> dwarf_vma and causes the whole expression to (still) be 64
> bits.

Yes, I left the code I moved unchanged, and didn't notice that
abbrev_size was a size_t in the original location.

> binutils:
> 	* dwarf.c (process_abbrev_set): Properly parenthesize before
> 	casting to unsigned long.

Thanks for fixing this.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout
  2021-05-11 22:41 ` Alan Modra
@ 2021-05-18  6:45   ` Alan Modra
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Modra @ 2021-05-18  6:45 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: binutils

On Wed, May 12, 2021 at 08:11:28AM +0930, Alan Modra wrote:
> I'm not sure how that happened.  I certainly meant to post the patch.

And now I know what happened, I had a mail configuration error that
ate lots of emails.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-18  6:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 14:36 dwarf.c (process_abbrev_set): Properly parenthesize, fix fallout Hans-Peter Nilsson
2021-05-11 22:41 ` Alan Modra
2021-05-18  6:45   ` Alan Modra

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).