]> git.pld-linux.org Git - packages/binutils.git/blame - pr29451.patch
upstream fix for gas regression; rel 3
[packages/binutils.git] / pr29451.patch
CommitLineData
6061979e
JP
1From e8cf73215187b0c08679d726a5cc7c019fa3ea2e Mon Sep 17 00:00:00 2001
2From: Jan Beulich <jbeulich@suse.com>
3Date: Wed, 10 Aug 2022 10:34:22 +0200
4Subject: [PATCH] gas/Dwarf: properly skip zero-size functions
5
6PR gas/29451
7
8While out_debug_abbrev() properly skips such functions, out_debug_info()
9mistakenly didn't. It needs to calculate the high_pc expression ahead of
10time, in order to skip emitting any data for the function if the value
11is zero.
12
13The one case which would still leave a zero-size entry is when
14symbol_get_obj(symp)->size ends up evaluating to zero. I hope we can
15expect that to not be the case, otherwise we'd need to have a way to
16post-process .debug_info contents between resolving expressions and
17actually writing the data out to the file. Even then it wouldn't be
18entirely obvious in which way to alter the data.
19
20(cherry picked from commit d7abcbcea5ddd40a3bf28758b62f35933c59f996)
21---
22 gas/dwarf2dbg.c | 39 ++++++++++++++++++++-------------------
23 1 file changed, 20 insertions(+), 19 deletions(-)
24
25diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
26index 868ec79ee2c..f346bd6a412 100644
27--- a/gas/dwarf2dbg.c
28+++ b/gas/dwarf2dbg.c
29@@ -2882,6 +2882,7 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
30 {
31 const char *name;
32 size_t len;
33+ expressionS size = { .X_op = O_constant };
34
35 /* Skip warning constructs (see above). */
36 if (symbol_get_bfdsym (symp)->flags & BSF_WARNING)
37@@ -2895,6 +2896,18 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
38 if (!S_IS_DEFINED (symp) || !S_IS_FUNCTION (symp))
39 continue;
40
41+#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */
42+ size.X_add_number = S_GET_SIZE (symp);
43+ if (size.X_add_number == 0 && IS_ELF
44+ && symbol_get_obj (symp)->size != NULL)
45+ {
46+ size.X_op = O_add;
47+ size.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size);
48+ }
49+#endif
50+ if (size.X_op == O_constant && size.X_add_number == 0)
51+ continue;
52+
53 subseg_set (str_seg, 0);
54 name_sym = symbol_temp_new_now_octets ();
55 name = S_GET_NAME (symp);
56@@ -2920,29 +2933,17 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT str_seg,
57 emit_expr (&exp, sizeof_address);
58
59 /* DW_AT_high_pc */
60- exp.X_op = O_constant;
61-#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */
62- exp.X_add_number = S_GET_SIZE (symp);
63- if (exp.X_add_number == 0 && IS_ELF
64- && symbol_get_obj (symp)->size != NULL)
65- {
66- exp.X_op = O_add;
67- exp.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size);
68- }
69-#else
70- exp.X_add_number = 0;
71-#endif
72 if (DWARF2_VERSION < 4)
73 {
74- if (exp.X_op == O_constant)
75- exp.X_op = O_symbol;
76- exp.X_add_symbol = symp;
77- emit_expr (&exp, sizeof_address);
78+ if (size.X_op == O_constant)
79+ size.X_op = O_symbol;
80+ size.X_add_symbol = symp;
81+ emit_expr (&size, sizeof_address);
82 }
83- else if (exp.X_op == O_constant)
84- out_uleb128 (exp.X_add_number);
85+ else if (size.X_op == O_constant)
86+ out_uleb128 (size.X_add_number);
87 else
88- emit_leb128_expr (symbol_get_value_expression (exp.X_op_symbol), 0);
89+ emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0);
90 }
91
92 /* End of children. */
93--
942.31.1
95
This page took 0.105727 seconds and 4 git commands to generate.