dwarf2: Pad size of .debug_line section.
authorChristian Eggers <ceggers@gmx.de>
Sun, 10 Mar 2019 18:21:57 +0000 (19:21 +0100)
committerAlan Modra <amodra@gmail.com>
Wed, 13 Mar 2019 02:59:35 +0000 (13:29 +1030)
As all dwarf debug information is organized in octets, the size of all
dwarf sections must be aligned to OCTETS_PER_BYTE.  Most DWARF sections
meet this requirement, only the .debug_line section can reach an
arbitrary octet size.

In order to align the size to a multiple of OCTETS_PER_BYTE, the section
is padded with "nop" statements at the end.

* dwarf2dbg.c (out_debug_line): Pad size of .debug_line section.

gas/ChangeLog
gas/dwarf2dbg.c

index 368a73cb4479468a96abfc3214402dea5f1f8a02..5b209741f1579ec96ef07e9767556e7eb4256551 100644 (file)
@@ -1,3 +1,7 @@
+2019-03-13  Christian Eggers  <ceggers@gmx.de>
+
+       * dwarf2dbg.c (out_debug_line): Pad size of .debug_line section.
+
 2019-03-13  Christian Eggers  <ceggers@gmx.de>
 
        * dwarf2dbg.c (out_debug_str): Use octets for .debug_string pointers.
index d46913857672abd0b92c9037911bf93c9a1d9f39..0b7b78c8c3acbd23d3dadebb0ff2a3d7a3f7152c 100644 (file)
@@ -1787,6 +1787,7 @@ out_debug_line (segT line_seg)
   symbolS *line_end;
   struct line_seg *s;
   int sizeof_offset;
+  addressT section_end, section_end_aligned;
 
   memset (&exp, 0, sizeof exp);
   sizeof_offset = out_header (line_seg, &exp);
@@ -1848,6 +1849,16 @@ out_debug_line (segT line_seg)
        in the DWARF Line Number header.  */
     subseg_set (subseg_get (".debug_line_end", FALSE), 0);
 
+  /* Pad size of .debug_line section to a multiple of OCTETS_PER_BYTE.
+     Simply sizing the section in md_section_align() is not sufficient,
+     also the size field in the .debug_line header must be a multiple
+     of OCTETS_PER_BYTE.  Not doing so will introduce gaps within the
+     .debug_line sections after linking.  */
+  section_end = frag_now_fix_octets ();
+  section_end_aligned = (section_end + OCTETS_PER_BYTE - 1) & -OCTETS_PER_BYTE;
+  for ( ; section_end != section_end_aligned; section_end++)
+    out_inc_line_addr (0, 0);  /* NOP */
+
   symbol_set_value_now_octets (line_end);
 }
 
This page took 0.025078 seconds and 4 git commands to generate.