From 0bb98c5003a710e4caa3b3c551b952e9156c57db Mon Sep 17 00:00:00 2001 From: pfg Date: Fri, 4 Jan 2013 03:54:22 +0000 Subject: [PATCH] MFC 244776, 244792: gcc: avoid generating negative values to DW_AT_byte_size. There is a bug in gcc (GCC/35998) where dwarf reports sizes of unsigned -1 (0xffffffff). On NetBSD this generated a faulty CTF entry which then caused a segfault in ctfmerge. The issue was worked around in NetBSD's Dtrace but since the issue originated in gcc, it seems reasonable to fix it here. Thanks to Christoph Mallon for pointing out a correct fix. git-svn-id: svn://svn.freebsd.org/base/stable/8@245024 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- contrib/gcc/dwarf2out.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/gcc/dwarf2out.c b/contrib/gcc/dwarf2out.c index 25a906bad..5e4354a40 100644 --- a/contrib/gcc/dwarf2out.c +++ b/contrib/gcc/dwarf2out.c @@ -10812,9 +10812,9 @@ add_byte_size_attribute (dw_die_ref die, tree tree_node) /* Note that `size' might be -1 when we get to this point. If it is, that indicates that the byte size of the entity in question is variable. We - have no good way of expressing this fact in Dwarf at the present time, - so just let the -1 pass on through. */ - add_AT_unsigned (die, DW_AT_byte_size, size); + have no good way of expressing this fact in Dwarf at the present time. + GCC/35998: Avoid passing negative sizes to Dtrace and gdb. */ + add_AT_unsigned (die, DW_AT_byte_size, (size != (unsigned)-1 ? size : 0)); } /* For a FIELD_DECL node which represents a bit-field, output an attribute -- 2.45.2