Blame SOURCES/binutils-gas-dwarf-skip-empty-functions.patch

ddc4e9
diff -rupN --no-dereference binutils-2.39/gas/dwarf2dbg.c binutils-2.39-new/gas/dwarf2dbg.c
ddc4e9
--- binutils-2.39/gas/dwarf2dbg.c	2022-07-08 11:46:47.000000000 +0200
ddc4e9
+++ binutils-2.39-new/gas/dwarf2dbg.c	2022-10-30 12:41:40.297023812 +0100
ddc4e9
@@ -2882,6 +2882,7 @@ out_debug_info (segT info_seg, segT abbr
ddc4e9
 	{
ddc4e9
 	  const char *name;
ddc4e9
 	  size_t len;
ddc4e9
+	  expressionS size = { .X_op = O_constant };
ddc4e9
 
ddc4e9
 	  /* Skip warning constructs (see above).  */
ddc4e9
 	  if (symbol_get_bfdsym (symp)->flags & BSF_WARNING)
ddc4e9
@@ -2895,6 +2896,18 @@ out_debug_info (segT info_seg, segT abbr
ddc4e9
 	  if (!S_IS_DEFINED (symp) || !S_IS_FUNCTION (symp))
ddc4e9
 	    continue;
ddc4e9
 
ddc4e9
+#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */
ddc4e9
+	  size.X_add_number = S_GET_SIZE (symp);
ddc4e9
+	  if (size.X_add_number == 0 && IS_ELF
ddc4e9
+	      && symbol_get_obj (symp)->size != NULL)
ddc4e9
+	    {
ddc4e9
+	      size.X_op = O_add;
ddc4e9
+	      size.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size);
ddc4e9
+	    }
ddc4e9
+#endif
ddc4e9
+	  if (size.X_op == O_constant && size.X_add_number == 0)
ddc4e9
+	    continue;
ddc4e9
+
ddc4e9
 	  subseg_set (str_seg, 0);
ddc4e9
 	  name_sym = symbol_temp_new_now_octets ();
ddc4e9
 	  name = S_GET_NAME (symp);
ddc4e9
@@ -2920,29 +2933,17 @@ out_debug_info (segT info_seg, segT abbr
ddc4e9
 	  emit_expr (&exp, sizeof_address);
ddc4e9
 
ddc4e9
 	  /* DW_AT_high_pc */
ddc4e9
-	  exp.X_op = O_constant;
ddc4e9
-#if defined (OBJ_ELF) /* || defined (OBJ_MAYBE_ELF) */
ddc4e9
-	  exp.X_add_number = S_GET_SIZE (symp);
ddc4e9
-	  if (exp.X_add_number == 0 && IS_ELF
ddc4e9
-	      && symbol_get_obj (symp)->size != NULL)
ddc4e9
-	    {
ddc4e9
-	      exp.X_op = O_add;
ddc4e9
-	      exp.X_op_symbol = make_expr_symbol (symbol_get_obj (symp)->size);
ddc4e9
-	    }
ddc4e9
-#else
ddc4e9
-	  exp.X_add_number = 0;
ddc4e9
-#endif
ddc4e9
 	  if (DWARF2_VERSION < 4)
ddc4e9
 	    {
ddc4e9
-	      if (exp.X_op == O_constant)
ddc4e9
-		exp.X_op = O_symbol;
ddc4e9
-	      exp.X_add_symbol = symp;
ddc4e9
-	      emit_expr (&exp, sizeof_address);
ddc4e9
+	      if (size.X_op == O_constant)
ddc4e9
+		size.X_op = O_symbol;
ddc4e9
+	      size.X_add_symbol = symp;
ddc4e9
+	      emit_expr (&size, sizeof_address);
ddc4e9
 	    }
ddc4e9
-	  else if (exp.X_op == O_constant)
ddc4e9
-	    out_uleb128 (exp.X_add_number);
ddc4e9
+	  else if (size.X_op == O_constant)
ddc4e9
+	    out_uleb128 (size.X_add_number);
ddc4e9
 	  else
ddc4e9
-	    emit_leb128_expr (symbol_get_value_expression (exp.X_op_symbol), 0);
ddc4e9
+	    emit_leb128_expr (symbol_get_value_expression (size.X_op_symbol), 0);
ddc4e9
 	}
ddc4e9
 
ddc4e9
       /* End of children.  */