diff mbox

[DWARF] AIX dwarf2out label fix

Message ID CAGWvnymCg3CtNM9j8zcj+BALCno6GStO+mMCrFihqYmkmWTp_w@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn May 17, 2017, 1:01 a.m. UTC
The AIX Assembler inserts the DWARF section lengths itself.
dwarf2out.c previously has been modified to not emit the length on
AIX.  All well and good until GCC emits a label that it believes
references the start of a DWARF section, but actually references an
address _after_ the section length inserted by AIX.

        .dwsect 0x20000
<AIX inserts section length>
        .vbyte 2,0x4

This particular issue causes an incorrect offset for DW_AT_stmt_list.

The following patch adjusts the reference to the label on AIX to
subtract the size of the section length information, which makes GDB
much happier.

Bootstrapped on powerpc-ibm-aix7.2.0.0


Thanks, David

        * dwarf2out.c (dwarf2out_finish): Use a local copy of
        On AIX, append an expression to subtract the size of the
section length info.
diff mbox


Index: dwarf2out.c
--- dwarf2out.c (revision 248131)
+++ dwarf2out.c (working copy)
@@ -29650,6 +29650,7 @@  dwarf2out_finish (const char *)
   comdat_type_node *ctnode;
   dw_die_ref main_comp_unit_die;
   unsigned char checksum[16];
+  char dl_section_label[MAX_ARTIFICIAL_LABEL_BYTES];

   /* Flush out any latecomers to the limbo party.  */
   flush_limbo_die_list ();
@@ -29767,9 +29768,13 @@  dwarf2out_finish (const char *)

+  strcpy (dl_section_label, debug_line_section_label);
+    strcat (dl_section_label, TARGET_64BIT ? "-12" : "-4");
   if (debug_info_level >= DINFO_LEVEL_TERSE)
     add_AT_lineptr (main_comp_unit_die, DW_AT_stmt_list,
-                   debug_line_section_label);
+                   dl_section_label);

   if (have_macinfo)
     add_AT_macptr (comp_unit_die (),
@@ -29845,7 +29850,7 @@  dwarf2out_finish (const char *)
       if (debug_info_level >= DINFO_LEVEL_TERSE)
         add_AT_lineptr (ctnode->root_die, DW_AT_stmt_list,
-                         ? debug_line_section_label
+                         ? dl_section_label
                          : debug_skeleton_line_section_label));

       output_comdat_type_unit (ctnode);