[binutils-gdb] gas: Use udata for DW_AT_high_pc when emitting DWARF4

Mark Wielaard mark@sourceware.org
Tue Aug 4 09:47:29 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6b9a135d72c3826b9b5e2a5d35acfb777ec18dcd

commit 6b9a135d72c3826b9b5e2a5d35acfb777ec18dcd
Author: Mark Wielaard <mark@klomp.org>
Date:   Mon Aug 3 22:02:24 2020 +0200

    gas: Use udata for DW_AT_high_pc when emitting DWARF4
    
    For DWARF4 DW_AT_high_pc can be expressed as constant offset from
    DW_AT_low_pc which saves a relocation. Use DW_FORM_udate (uleb128)
    to keep the constant value as small as possible.
    
    gas/ChangeLog:
    
           * dwarf2dbg.c (out_debug_abbrev): When DWARF2_VERSION >= 4, use
           DW_FORM_udata for DW_AT_high_pc.
           (out_debug_info): Use emit_leb128_expr for DW_AT_high_pc, when
           DWARF2_VERSION >= 4.
           * read.c (emit_leb128_exp): No longer static.
           * read.h (emit_leb128_exp): Define.

Diff:
---
 gas/ChangeLog   | 9 +++++++++
 gas/dwarf2dbg.c | 8 +++++---
 gas/read.c      | 2 +-
 gas/read.h      | 1 +
 4 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 8895c0c0c7f..28a6b1b2b93 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,12 @@
+2020-08-04  Mark Wielaard  <mark@klomp.org>
+
+	* dwarf2dbg.c (out_debug_abbrev): When DWARF2_VERSION >= 4, use
+	DW_FORM_udata for DW_AT_high_pc.
+	(out_debug_info): Use emit_leb128_expr for DW_AT_high_pc, when
+	DWARF2_VERSION >= 4.
+	* read.c (emit_leb128_exp): No longer static.
+	* read.h (emit_leb128_exp): Define.
+
 2020-08-02  Mark Wielaard  <mark@klomp.org>
 
 	* gas/dwarf2dbg.c (out_dir_and_file_list): For DWARF5 emit at
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 7877c563887..a95c29736f0 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -2444,8 +2444,7 @@ out_debug_abbrev (segT abbrev_seg,
       if (DWARF2_VERSION < 4)
 	out_abbrev (DW_AT_high_pc, DW_FORM_addr);
       else
-	out_abbrev (DW_AT_high_pc, (sizeof_address == 4
-				    ? DW_FORM_data4 : DW_FORM_data8));
+	out_abbrev (DW_AT_high_pc, DW_FORM_udata);
     }
   else
     {
@@ -2528,7 +2527,10 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg,
 	}
       exp.X_add_symbol = all_segs->text_end;
       exp.X_add_number = 0;
-      emit_expr (&exp, sizeof_address);
+      if (DWARF2_VERSION < 4)
+	emit_expr (&exp, sizeof_address);
+      else
+	emit_leb128_expr (&exp, 0);
     }
   else
     {
diff --git a/gas/read.c b/gas/read.c
index 8f93c2ba2b4..f192cc16d57 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -5138,7 +5138,7 @@ output_big_leb128 (char *p, LITTLENUM_TYPE *bignum, unsigned int size, int sign)
 /* Generate the appropriate fragments for a given expression to emit a
    leb128 value.  SIGN is 1 for sleb, 0 for uleb.  */
 
-static void
+void
 emit_leb128_expr (expressionS *exp, int sign)
 {
   operatorT op = exp->X_op;
diff --git a/gas/read.h b/gas/read.h
index 502f3b6f2da..ffcdbb69a7b 100644
--- a/gas/read.h
+++ b/gas/read.h
@@ -132,6 +132,7 @@ extern void emit_expr_with_reloc (expressionS *exp, unsigned int nbytes,
 				  TC_PARSE_CONS_RETURN_TYPE);
 extern void emit_expr_fix (expressionS *, unsigned int, fragS *, char *,
 			   TC_PARSE_CONS_RETURN_TYPE);
+extern void emit_leb128_expr (expressionS *, int);
 extern void equals (char *, int);
 extern void float_cons (int);
 extern void ignore_rest_of_line (void);


More information about the Binutils-cvs mailing list