[PATCH] Fix dwarf2asm crashes on alpha-vms
Jakub Jelinek
jakub@redhat.com
Thu Feb 12 15:09:00 GMT 2015
Hi!
-Wformat-security shows a real problem, although it supposedly affects only
alpha-vms target (but the code is compiled in everywhere except for
ia64-vms).
dw2_asm_output_delta is printf like, so passing just comment to it
will lead to segfault, because the comment will usually be "%s" and there is
no further argument.
Turning dw2_asm_output_delta into a wrapper around dw2_asm_output_delta_1
that would take va_list instead of ... looks to me like pessimizing all
targets for the sake of an almost extinct alpha-vms, so I'm attaching 3
other options. One is to change dwarf2out.c only to call the
dw2_asm_output_vms_delta function only on ia64-vms and nowhere else, the
other is to just don't print the -dA comments on the alpha-vms deltas,
and the last one duplicate tiny bit of dw2_asm_output_delta into
dw2_asm_output_vms_delta (after all, big chunk is already duplicated there
anyway).
Any preferences?
Jakub
-------------- next part --------------
2015-02-12 Jakub Jelinek <jakub@redhat.com>
* dwarf2asm.c (dw2_asm_output_vms_delta): Only define
if ASM_OUTPUT_DWARF_VMS_DELTA is defined.
* dwarf2out.c (output_die): Use dw2_asm_output_vms_delta
only if ASM_OUTPUT_DWARF_VMS_DELTA is defined.
--- gcc/dwarf2asm.c.jj 2015-01-09 21:59:29.000000000 +0100
+++ gcc/dwarf2asm.c 2015-02-12 15:40:35.644027145 +0100
@@ -159,6 +159,7 @@ dw2_asm_output_delta (int size, const ch
va_end (ap);
}
+#ifdef ASM_OUTPUT_DWARF_VMS_DELTA
/* Output the difference between two symbols in instruction units
in a given size. */
@@ -171,11 +172,6 @@ dw2_asm_output_vms_delta (int size ATTRI
va_start (ap, comment);
-#ifndef ASM_OUTPUT_DWARF_VMS_DELTA
- /* VMS Delta is only special on ia64-vms, but this function also gets
- called on alpha-vms so it has to do something sane. */
- dw2_asm_output_delta (size, lab1, lab2, comment);
-#else
ASM_OUTPUT_DWARF_VMS_DELTA (asm_out_file, size, lab1, lab2);
if (flag_debug_asm && comment)
{
@@ -183,10 +179,10 @@ dw2_asm_output_vms_delta (int size ATTRI
vfprintf (asm_out_file, comment, ap);
}
fputc ('\n', asm_out_file);
-#endif
va_end (ap);
}
+#endif
/* Output a section-relative reference to a LABEL, which was placed in
BASE. In general this can only be done for debugging symbols.
--- gcc/dwarf2out.c.jj 2015-02-11 13:52:00.000000000 +0100
+++ gcc/dwarf2out.c 2015-02-12 15:41:59.127656674 +0100
@@ -9002,9 +9002,15 @@ output_die (dw_die_ref die)
break;
case dw_val_class_vms_delta:
+#ifdef ASM_OUTPUT_DWARF_VMS_DELTA
dw2_asm_output_vms_delta (DWARF_OFFSET_SIZE,
AT_vms_delta2 (a), AT_vms_delta1 (a),
"%s", name);
+#else
+ dw2_asm_output_delta (DWARF_OFFSET_SIZE,
+ AT_vms_delta2 (a), AT_vms_delta1 (a),
+ "%s", name);
+#endif
break;
case dw_val_class_lbl_id:
-------------- next part --------------
2015-02-12 Jakub Jelinek <jakub@redhat.com>
* dwarf2asm.c (dw2_asm_output_vms_delta): Pass NULL instead
of comment to dw2_asm_output_delta.
--- gcc/dwarf2asm.c.jj 2015-01-09 21:59:29.000000000 +0100
+++ gcc/dwarf2asm.c 2015-02-12 15:54:49.299013264 +0100
@@ -174,7 +174,7 @@ dw2_asm_output_vms_delta (int size ATTRI
#ifndef ASM_OUTPUT_DWARF_VMS_DELTA
/* VMS Delta is only special on ia64-vms, but this function also gets
called on alpha-vms so it has to do something sane. */
- dw2_asm_output_delta (size, lab1, lab2, comment);
+ dw2_asm_output_delta (size, lab1, lab2, NULL);
#else
ASM_OUTPUT_DWARF_VMS_DELTA (asm_out_file, size, lab1, lab2);
if (flag_debug_asm && comment)
-------------- next part --------------
2015-02-12 Jakub Jelinek <jakub@redhat.com>
* dwarf2asm.c (dw2_asm_output_vms_delta): Avoid calling
dw2_asm_output_delta.
--- gcc/dwarf2asm.c.jj 2015-01-09 21:59:29.000000000 +0100
+++ gcc/dwarf2asm.c 2015-02-12 15:56:25.943426539 +0100
@@ -172,18 +172,23 @@ dw2_asm_output_vms_delta (int size ATTRI
va_start (ap, comment);
#ifndef ASM_OUTPUT_DWARF_VMS_DELTA
- /* VMS Delta is only special on ia64-vms, but this function also gets
- called on alpha-vms so it has to do something sane. */
- dw2_asm_output_delta (size, lab1, lab2, comment);
+#ifdef ASM_OUTPUT_DWARF_DELTA
+ ASM_OUTPUT_DWARF_DELTA (asm_out_file, size, lab1, lab2);
+#else
+ dw2_assemble_integer (size,
+ gen_rtx_MINUS (Pmode,
+ gen_rtx_SYMBOL_REF (Pmode, lab1),
+ gen_rtx_SYMBOL_REF (Pmode, lab2)));
+#endif
#else
ASM_OUTPUT_DWARF_VMS_DELTA (asm_out_file, size, lab1, lab2);
+#endif
if (flag_debug_asm && comment)
{
fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
vfprintf (asm_out_file, comment, ap);
}
fputc ('\n', asm_out_file);
-#endif
va_end (ap);
}
More information about the Gcc-patches
mailing list