From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1386) id 00BAB385829A; Wed, 10 Aug 2022 08:31:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00BAB385829A Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jan Beulich To: bfd-cvs@sourceware.org Subject: [binutils-gdb] gas/Dwarf: properly skip zero-size functions X-Act-Checkin: binutils-gdb X-Git-Author: Jan Beulich X-Git-Refname: refs/heads/master X-Git-Oldrev: 6158b25f77db11712b84e6a4609898f2615ac749 X-Git-Newrev: d7abcbcea5ddd40a3bf28758b62f35933c59f996 Message-Id: <20220810083101.00BAB385829A@sourceware.org> Date: Wed, 10 Aug 2022 08:31:01 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2022 08:31:01 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd7abcbcea5dd= d40a3bf28758b62f35933c59f996 commit d7abcbcea5ddd40a3bf28758b62f35933c59f996 Author: Jan Beulich Date: Wed Aug 10 10:30:46 2022 +0200 gas/Dwarf: properly skip zero-size functions =20 PR gas/29451 =20 While out_debug_abbrev() properly skips such functions, out_debug_info() mistakenly didn't. It needs to calculate the high_pc expression ahead of time, in order to skip emitting any data for the function if the value is zero. =20 The one case which would still leave a zero-size entry is when symbol_get_obj(symp)->size ends up evaluating to zero. I hope we can expect that to not be the case, otherwise we'd need to have a way to post-process .debug_info contents between resolving expressions and actually writing the data out to the file. Even then it wouldn't be entirely obvious in which way to alter the data. Diff: --- gas/dwarf2dbg.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index 868ec79ee2c..f346bd6a412 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -2882,6 +2882,7 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT = line_seg, segT str_seg, { const char *name; size_t len; + expressionS size =3D { .X_op =3D O_constant }; =20 /* Skip warning constructs (see above). */ if (symbol_get_bfdsym (symp)->flags & BSF_WARNING) @@ -2895,6 +2896,18 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT= line_seg, segT str_seg, if (!S_IS_DEFINED (symp) || !S_IS_FUNCTION (symp)) continue; =20 +#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ + size.X_add_number =3D S_GET_SIZE (symp); + if (size.X_add_number =3D=3D 0 && IS_ELF + && symbol_get_obj (symp)->size !=3D NULL) + { + size.X_op =3D O_add; + size.X_op_symbol =3D make_expr_symbol (symbol_get_obj (symp)->size); + } +#endif + if (size.X_op =3D=3D O_constant && size.X_add_number =3D=3D 0) + continue; + subseg_set (str_seg, 0); name_sym =3D symbol_temp_new_now_octets (); name =3D S_GET_NAME (symp); @@ -2920,29 +2933,17 @@ out_debug_info (segT info_seg, segT abbrev_seg, seg= T line_seg, segT str_seg, emit_expr (&exp, sizeof_address); =20 /* DW_AT_high_pc */ - exp.X_op =3D O_constant; -#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */ - exp.X_add_number =3D S_GET_SIZE (symp); - if (exp.X_add_number =3D=3D 0 && IS_ELF - && symbol_get_obj (symp)->size !=3D NULL) - { - exp.X_op =3D O_add; - exp.X_op_symbol =3D make_expr_symbol (symbol_get_obj (symp)->size); - } -#else - exp.X_add_number =3D 0; -#endif if (DWARF2_VERSION < 4) { - if (exp.X_op =3D=3D O_constant) - exp.X_op =3D O_symbol; - exp.X_add_symbol =3D symp; - emit_expr (&exp, sizeof_address); + if (size.X_op =3D=3D O_constant) + size.X_op =3D O_symbol; + size.X_add_symbol =3D symp; + emit_expr (&size, sizeof_address); } - else if (exp.X_op =3D=3D O_constant) - out_uleb128 (exp.X_add_number); + else if (size.X_op =3D=3D O_constant) + out_uleb128 (size.X_add_number); else - emit_leb128_expr (symbol_get_value_expression (exp.X_op_symbol), 0); + emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0); } =20 /* End of children. */