[3/7,gas] dwarf2: Use octets for dwarf2 headers

Message ID 20190310182158.23705-4-ceggers@gmx.de
State New
Headers show
Series
  • gas: Fixes for DWARF2 debug info with OCTETS_PER_BYTE>1
Related show

Commit Message

Christian Eggers March 10, 2019, 6:21 p.m.
The content of the dwarf2 sections .debug_line, .debug_aranges and
.debug_info starts with an u32 containing the the size of the remaining
data. According to the dwarf2 specification this value must be expressed
in octets instead of bytes.

This change should not affect existing targets as all targets currently
using DWARF2 have 8 bit per byte.

Signed-off-by: Christian Eggers <ceggers@gmx.de>

---
 gas/ChangeLog   | 7 +++++++
 gas/dwarf2dbg.c | 8 ++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

-- 
2.16.4

Patch

diff --git a/gas/ChangeLog b/gas/ChangeLog
index be1c6d99b0..08dd959afd 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,10 @@ 
+2019-03-10  Christian Eggers  <ceggers@gmx.de>
+
+	* dwarf2dbg.c: Use octets for dwarf2 headers.
+	(out_debug_line): symbol_set_value_now() --> symbol_set_value_now_octets()
+	(out_debug_aranges): Likewise.
+	(out_debug_info): Likewise.
+
 2019-03-10  Christian Eggers  <ceggers@gmx.de>
 
 	* symbols.h: New functions.
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 45d86a6ee3..7b0e8fdc4a 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -1745,7 +1745,7 @@  out_header (asection *sec, expressionS *exp)
     }
   else
     {
-      start_sym = symbol_temp_new_now ();
+      start_sym = symbol_temp_new_now_octets ();
       end_sym = symbol_temp_make ();
     }
 
@@ -1848,7 +1848,7 @@  out_debug_line (segT line_seg)
        in the DWARF Line Number header.  */
     subseg_set (subseg_get (".debug_line_end", FALSE), 0);
 
-  symbol_set_value_now (line_end);
+  symbol_set_value_now_octets (line_end);
 }
 
 static void
@@ -1967,7 +1967,7 @@  out_debug_aranges (segT aranges_seg, segT info_seg)
   md_number_to_chars (p, 0, addr_size);
   md_number_to_chars (p + addr_size, 0, addr_size);
 
-  symbol_set_value_now (aranges_end);
+  symbol_set_value_now_octets (aranges_end);
 }
 
 /* Emit data for .debug_abbrev.  Note that this must be kept in
@@ -2082,7 +2082,7 @@  out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg,
      dwarf2 draft has no standard code for assembler.  */
   out_two (DW_LANG_Mips_Assembler);
 
-  symbol_set_value_now (info_end);
+  symbol_set_value_now_octets (info_end);
 }
 
 /* Emit the three debug strings needed in .debug_str and setup symbols