On Fri, Sep 30, 2016 at 07:07:22PM +0200, Jan-Benedict Glaw wrote: > When building for --target=sparc-leon-elf (using config-list.mk) with > a current GCC, I get this error message (cf. > http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=632317): > > g++ -fno-PIE -c -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE > -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall > -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute > -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros > -Wno-overlength-strings -Werror -fno-common -DHAVE_CONFIG_H -I. -I. > -I/home/jbglaw/repos-configlist_mk/gcc/gcc > -I/home/jbglaw/repos-configlist_mk/gcc/gcc/. > -I/home/jbglaw/repos-configlist_mk/gcc/gcc/../include > -I/home/jbglaw/repos-configlist_mk/gcc/gcc/../libcpp/include > -I/opt/cfarm/mpc/include > -I/home/jbglaw/repos-configlist_mk/gcc/gcc/../libdecnumber > -I/home/jbglaw/repos-configlist_mk/gcc/gcc/../libdecnumber/dpd > -I../libdecnumber -I/home/jbglaw/repos-configlist_mk/gcc/gcc/../libbacktrace > -o dwarf2out.o -MT dwarf2out.o -MMD -MP -MF ./.deps/dwarf2out.TPo > /home/jbglaw/repos-configlist_mk/gcc/gcc/dwarf2out.c > /home/jbglaw/repos-configlist_mk/gcc/gcc/dwarf2out.c: In function ‘void > dwarf2out_do_cfi_startproc(bool)’: > /home/jbglaw/repos-configlist_mk/gcc/gcc/dwarf2out.c:942:1: error: may write > a terminating nul past the end of the destination [-Werror=format-length=] > dwarf2out_do_cfi_startproc (bool second) > ^~~~~~~~~~~~~~~~~~~~~~~~~~ > /home/jbglaw/repos-configlist_mk/gcc/gcc/dwarf2out.c:973:36: note: format > output between 10 and 21 bytes into a destination of size 20 > current_function_funcdef_no); > ^ > cc1plus: all warnings being treated as errors > Makefile:1102: recipe for target 'dwarf2out.o' failed > > I haven't really tracked down since when that error/warning shows up > and whether or not it's valid, but maybe you might want to have a look?
I think sparc-leon-elf uses "*.L%s%ld" format, so for string of length 6 and int cast to long int it needs theoretically up to 21 bytes (3 + 6 + 11 + 1) byt that would only trigger if the counters overflow from INT_MAX to INT_MIN (so wouldn't be valid assembly anyway). That said, most of spots in dwarf2out.c use the MAX_ARTIFICIAL_LABEL_BYTES macro for sizing such buffers, so instead of changing the [20] to [21] if the prefix can be 6 bytes I think it is cleaner to switch to using that macro everywhere. Ok if it passes bootstrap/regtest? 2016-09-30 Jakub Jelinek <ja...@redhat.com> * dwarf2out.c (output_fde, output_call_frame_info, dwarf2out_do_cfi_startproc, set_indirect_string, gen_internal_sym, output_die, output_line_info): Use MAX_ARTIFICIAL_LABEL_BYTES as char array sizes for ASM_GENERATE_INTERNAL_LABEL output. --- gcc/dwarf2out.c.jj 2016-09-29 22:53:14.000000000 +0200 +++ gcc/dwarf2out.c 2016-09-30 20:41:00.839532467 +0200 @@ -567,7 +567,7 @@ output_fde (dw_fde_ref fde, bool for_eh, { const char *begin, *end; static unsigned int j; - char l1[20], l2[20]; + char l1[MAX_ARTIFICIAL_LABEL_BYTES], l2[MAX_ARTIFICIAL_LABEL_BYTES]; targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, for_eh, /* empty */ 0); @@ -722,7 +722,8 @@ output_call_frame_info (int for_eh) unsigned int i; dw_fde_ref fde; dw_cfi_ref cfi; - char l1[20], l2[20], section_start_label[20]; + char l1[MAX_ARTIFICIAL_LABEL_BYTES], l2[MAX_ARTIFICIAL_LABEL_BYTES]; + char section_start_label[MAX_ARTIFICIAL_LABEL_BYTES]; bool any_lsda_needed = false; char augmentation[6]; int augmentation_size; @@ -966,7 +967,7 @@ dwarf2out_do_cfi_startproc (bool second) if (crtl->uses_eh_lsda) { - char lab[20]; + char lab[MAX_ARTIFICIAL_LABEL_BYTES]; enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0); ASM_GENERATE_INTERNAL_LABEL (lab, second ? "LLSDAC" : "LLSDA", @@ -4128,7 +4129,7 @@ AT_string (dw_attr_node *a) static void set_indirect_string (struct indirect_string_node *node) { - char label[32]; + char label[MAX_ARTIFICIAL_LABEL_BYTES]; /* Already indirect is a no op. */ if (node->form == DW_FORM_strp || node->form == DW_FORM_GNU_str_index) { @@ -7076,7 +7077,7 @@ is_template_instantiation (dw_die_ref di static char * gen_internal_sym (const char *prefix) { - char buf[256]; + char buf[MAX_ARTIFICIAL_LABEL_BYTES]; ASM_GENERATE_INTERNAL_LABEL (buf, prefix, label_num++); return xstrdup (buf); @@ -9382,7 +9383,7 @@ output_die (dw_die_ref die) case dw_val_class_fde_ref: { - char l1[20]; + char l1[MAX_ARTIFICIAL_LABEL_BYTES]; ASM_GENERATE_INTERNAL_LABEL (l1, FDE_LABEL, a->dw_attr_val.v.val_fde_index * 2); @@ -10710,7 +10711,8 @@ output_one_line_info_table (dw_line_info static void output_line_info (bool prologue_only) { - char l1[20], l2[20], p1[20], p2[20]; + char l1[MAX_ARTIFICIAL_LABEL_BYTES], l2[MAX_ARTIFICIAL_LABEL_BYTES]; + char p1[MAX_ARTIFICIAL_LABEL_BYTES], p2[MAX_ARTIFICIAL_LABEL_BYTES]; /* We don't support DWARFv5 line tables yet. */ int ver = dwarf_version < 5 ? dwarf_version : 4; bool saw_one = false; Jakub