From: Alexandre Oliva Date: Fri, 21 Jul 2017 09:09:06 +0000 (+0100) Subject: This patch introduces support for specifing views in .loc directives, so that the... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ba8826a82a29a19b78c18ce4f44fe313de279af7;p=binutils-gdb.git This patch introduces support for specifing views in .loc directives, so that the compiler can use the assembler to generate line number information and have the assembler determine view numbers to multiple views at the same program counter. binutils* dwarf.c (struct State_Machine_Registers): Add view field. (reset_state_machine): Reset view. (process_extended_line_op): Reset view when appropriate. (display_debug_lines_raw): Increment or reset view when appropriate. Print nonzero views. Support print view resets, disabled by default. (display_debug_lines_decoded): Likewise. Disambiguate op_code tests, enabling printing of end_sequence. * testsuite/binutils-all/dw2-1.W: Add nonzero views. * testsuite/binutils-all/dw2-3.W: Likewise. * testsuite/binutils-all/dw2-3gabi.W: Likewise. * testsuite/binutils-all/dw5.W: Add end sequence lines. * testsuite/binutils-all/i386/compressed-1a.d: Add nonzero views. * testsuite/binutils-all/libdw2-compressedgabi.out: Likewise. * testsuite/binutils-all/objdump.W: Likewise. * testsuite/binutils-all/objdump.WL: Add end sequence lines. * testsuite/binutils-all/x86-64/compressed-1a.d: Add nonzero views. gas * doc/as.texinfo (.loc): Document view support. * dwarf2dbg.c (unused): Check offset of next in struct line_entry. (current): Initialize view. (force_reset_view, view_assert_failed): New variables. (reverse_line_entry_list): New function. (set_or_check_view): Likewise. (dwarf2_gen_line_info_1): Call it. (dwarf2_where): Set view to NULL. (dwarf2_emit_insn): Return early when called before first file. (dwarf2_directive_loc): Add view support. Emit insn immediately when view option is given. (process_entries): Avoid set_address to reset view when a known address change already implies the view reset. (dwarf2dbg_final_check): New function. * dwarf2dbg.h (struct dwarf2_line_info): Add view. (dwarf2dbg_final_check): Declare. * read.c (s_leb128): Parse expression as deferred. * testsuite/gas/all/gas.exp: Run sleb128-9. * testsuite/gas/all/sleb128-9.d: New. * testsuite/gas/all/sleb128-9.l: New. * testsuite/gas/all/sleb128-9.s: New. * testsuite/gas/elf/dwarf2-1.d: Add nonzero views. * testsuite/gas/elf/dwarf2-2.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: New. * testsuite/gas/elf/dwarf2-5.s: New. * testsuite/gas/elf/dwarf2-6.d: New. * testsuite/gas/elf/dwarf2-6.s: New. * testsuite/gas/elf/dwarf2-7.d: New. * testsuite/gas/elf/dwarf2-7.s: New. * testsuite/gas/elf/dwarf2-8.d: New. * testsuite/gas/elf/dwarf2-8.l: New. * testsuite/gas/elf/dwarf2-8.s: New. * testsuite/gas/elf/dwarf2-9.d: New. * testsuite/gas/elf/dwarf2-9.l: New. * testsuite/gas/elf/dwarf2-9.s: New. * testsuite/gas/elf/dwarf2-10.d: New. * testsuite/gas/elf/dwarf2-10.l: New. * testsuite/gas/elf/dwarf2-10.s: New. * testsuite/gas/elf/dwarf2-11.d: New. * testsuite/gas/elf/dwarf2-11.s: New. * testsuite/gas/elf/dwarf2-12.d: New. * testsuite/gas/elf/dwarf2-12.s: New. * testsuite/gas/elf/dwarf2-13.d: New. * testsuite/gas/elf/dwarf2-13.s: New. * testsuite/gas/elf/dwarf2-14.d: New. * testsuite/gas/elf/dwarf2-14.s: New. * testsuite/gas/elf/dwarf2-15.d: New. * testsuite/gas/elf/dwarf2-15.s: New. * testsuite/gas/elf/dwarf2-16.d: New. * testsuite/gas/elf/dwarf2-16.s: New. * testsuite/gas/elf/dwarf2-17.d: New. * testsuite/gas/elf/dwarf2-17.s: New. * testsuite/gas/elf/dwarf2-18.d: New. * testsuite/gas/elf/dwarf2-18.s: New. * testsuite/gas/elf/elf.exp: Run dwarf2-5..18 tests. * testsuite/gas/i386/dw2-compress-1.d: Add nonzero views. * testsuite/gas/i386/dw2-compressed-1.d: Likewise. * testsuite/gas/i386/ilp32/lns/lns-duplicate.d: Likewise. * testsuite/gas/lns/lns-big-delta.d: Likewise. * testsuite/gas/lns/lns-duplicate.d: Likewise. * testsuite/gas/mips/loc-swap-2.d: Likewise. * testsuite/gas/mips/loc-swap-3.d: Likewise. * testsuite/gas/mips/loc-swap.d: Likewise. * testsuite/gas/mips/micromips@loc-swap-2.d: Likewise. * testsuite/gas/mips/micromips@loc-swap.d: Likewise. * testsuite/gas/mips/mips16@loc-swap-2.d: Likewise. * testsuite/gas/mips/mips16@loc-swap.d: Likewise. * testsuite/gas/mips/mips16e@loc-swap.d: Likewise. * write.c (write_object_file): Check pending view asserts. (cvt_frag_to_fill): Complain about undefined leb128 operand. --- diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 7e9d809c143..4b1b9e038b6 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,22 @@ +2017-07-21 Alexandre Oliva + + * dwarf.c (struct State_Machine_Registers): Add view field. + (reset_state_machine): Reset view. + (process_extended_line_op): Reset view when appropriate. + (display_debug_lines_raw): Increment or reset view when appropriate. + Print nonzero views. Support print view resets, disabled by default. + (display_debug_lines_decoded): Likewise. Disambiguate op_code tests, + enabling printing of end_sequence. + * testsuite/binutils-all/dw2-1.W: Add nonzero views. + * testsuite/binutils-all/dw2-3.W: Likewise. + * testsuite/binutils-all/dw2-3gabi.W: Likewise. + * testsuite/binutils-all/dw5.W: Add end sequence lines. + * testsuite/binutils-all/i386/compressed-1a.d: Add nonzero views. + * testsuite/binutils-all/libdw2-compressedgabi.out: Likewise. + * testsuite/binutils-all/objdump.W: Likewise. + * testsuite/binutils-all/objdump.WL: Add end sequence lines. + * testsuite/binutils-all/x86-64/compressed-1a.d: Add nonzero views. + 2017-07-19 Tristan Gingold * nm.c (show_stats): Remove variable. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index f6fa157fed4..ab6446defb0 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -426,6 +426,7 @@ read_uleb128 (unsigned char * data, typedef struct State_Machine_Registers { dwarf_vma address; + unsigned int view; unsigned int file; unsigned int line; unsigned int column; @@ -433,8 +434,8 @@ typedef struct State_Machine_Registers int basic_block; unsigned char op_index; unsigned char end_sequence; -/* This variable hold the number of the last entry seen - in the File Table. */ + /* This variable hold the number of the last entry seen + in the File Table. */ unsigned int last_file_entry; } SMR; @@ -444,6 +445,7 @@ static void reset_state_machine (int is_stmt) { state_machine_regs.address = 0; + state_machine_regs.view = 0; state_machine_regs.op_index = 0; state_machine_regs.file = 1; state_machine_regs.line = 1; @@ -502,6 +504,7 @@ process_extended_line_op (unsigned char * data, SAFE_BYTE_GET (adr, data, len - bytes_read - 1, end); printf (_("set Address to 0x%s\n"), dwarf_vmatoa ("x", adr)); state_machine_regs.address = adr; + state_machine_regs.view = 0; state_machine_regs.op_index = 0; break; @@ -3190,6 +3193,7 @@ display_debug_lines_raw (struct dwarf_section *section, unsigned char *end, void *file) { unsigned char *start = section->start; + int verbose_view = 0; printf (_("Raw dump of debug contents of section %s:\n\n"), section->name); @@ -3381,30 +3385,45 @@ display_debug_lines_raw (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; printf (_(" Special opcode %d: " - "advance Address by %s to 0x%s"), + "advance Address by %s to 0x%s%s"), op_code, dwarf_vmatoa ("u", uladv), - dwarf_vmatoa ("x", state_machine_regs.address)); + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + + state_machine_regs.address += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; printf (_(" Special opcode %d: " - "advance Address by %s to 0x%s[%d]"), + "advance Address by %s to 0x%s[%d]%s"), op_code, dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address), - state_machine_regs.op_index); + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); } adv = (op_code % linfo.li_line_range) + linfo.li_line_base; state_machine_regs.line += adv; - printf (_(" and Line by %s to %d\n"), + printf (_(" and Line by %s to %d"), dwarf_vmatoa ("d", adv), state_machine_regs.line); + if (verbose_view || state_machine_regs.view) + printf (_(" (view %u)\n"), state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; } else switch (op_code) { @@ -3413,7 +3432,12 @@ display_debug_lines_raw (struct dwarf_section *section, break; case DW_LNS_copy: - printf (_(" Copy\n")); + printf (_(" Copy")); + if (verbose_view || state_machine_regs.view) + printf (_(" (view %u)\n"), state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; break; case DW_LNS_advance_pc: @@ -3423,23 +3447,33 @@ display_debug_lines_raw (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; - printf (_(" Advance PC by %s to 0x%s\n"), + if (uladv) + state_machine_regs.view = 0; + printf (_(" Advance PC by %s to 0x%s%s\n"), dwarf_vmatoa ("u", uladv), - dwarf_vmatoa ("x", state_machine_regs.address)); + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; - printf (_(" Advance PC by %s to 0x%s[%d]\n"), + if (addrdelta) + state_machine_regs.view = 0; + printf (_(" Advance PC by %s to 0x%s[%d]%s\n"), dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address), - state_machine_regs.op_index); + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); } break; @@ -3486,23 +3520,33 @@ display_debug_lines_raw (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; - printf (_(" Advance PC by constant %s to 0x%s\n"), + if (uladv) + state_machine_regs.view = 0; + printf (_(" Advance PC by constant %s to 0x%s%s\n"), dwarf_vmatoa ("u", uladv), - dwarf_vmatoa ("x", state_machine_regs.address)); + dwarf_vmatoa ("x", state_machine_regs.address), + verbose_view && uladv + ? _(" (reset view)") : ""); } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; - printf (_(" Advance PC by constant %s to 0x%s[%d]\n"), + if (addrdelta) + state_machine_regs.view = 0; + printf (_(" Advance PC by constant %s to 0x%s[%d]%s\n"), dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address), - state_machine_regs.op_index); + state_machine_regs.op_index, + verbose_view && addrdelta + ? _(" (reset view)") : ""); } break; @@ -3513,6 +3557,7 @@ display_debug_lines_raw (struct dwarf_section *section, printf (_(" Advance PC by fixed size amount %s to 0x%s\n"), dwarf_vmatoa ("u", uladv), dwarf_vmatoa ("x", state_machine_regs.address)); + /* Do NOT reset view. */ break; case DW_LNS_set_prologue_end: @@ -3925,7 +3970,7 @@ display_debug_lines_decoded (struct dwarf_section *section, printf ("%s:\n", file_table[0].name); } - printf (_("File name Line number Starting address\n")); + printf (_("File name Line number Starting address View\n")); saved_linfo = linfo; } @@ -3933,12 +3978,14 @@ display_debug_lines_decoded (struct dwarf_section *section, while (data < end_of_sequence) { unsigned char op_code; + int xop; int adv; unsigned long int uladv; unsigned int bytes_read; int is_special_opcode = 0; op_code = *data++; + xop = op_code; if (op_code >= linfo.li_opcode_base) { @@ -3948,21 +3995,28 @@ display_debug_lines_decoded (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; } adv = (op_code % linfo.li_line_range) + linfo.li_line_base; state_machine_regs.line += adv; is_special_opcode = 1; + /* Increment view after printing this row. */ } else switch (op_code) { @@ -3983,11 +4037,13 @@ display_debug_lines_decoded (struct dwarf_section *section, } ext_op_code_len += bytes_read; ext_op_code = *op_code_data++; + xop = ext_op_code; + xop = -xop; switch (ext_op_code) { case DW_LNE_end_sequence: - reset_state_machine (linfo.li_default_is_stmt); + /* Reset stuff after printing this row. */ break; case DW_LNE_set_address: SAFE_BYTE_GET_AND_INC (state_machine_regs.address, @@ -3995,6 +4051,7 @@ display_debug_lines_decoded (struct dwarf_section *section, ext_op_code_len - bytes_read - 1, end); state_machine_regs.op_index = 0; + state_machine_regs.view = 0; break; case DW_LNE_define_file: { @@ -4037,6 +4094,7 @@ display_debug_lines_decoded (struct dwarf_section *section, break; } case DW_LNS_copy: + /* Increment view after printing this row. */ break; case DW_LNS_advance_pc: @@ -4046,16 +4104,22 @@ display_debug_lines_decoded (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; } break; @@ -4124,16 +4188,22 @@ display_debug_lines_decoded (struct dwarf_section *section, { uladv *= linfo.li_min_insn_length; state_machine_regs.address += uladv; + if (uladv) + state_machine_regs.view = 0; } else { - state_machine_regs.address - += ((state_machine_regs.op_index + uladv) - / linfo.li_max_ops_per_insn) + unsigned addrdelta + = ((state_machine_regs.op_index + uladv) + / linfo.li_max_ops_per_insn) * linfo.li_min_insn_length; + state_machine_regs.address + += addrdelta; state_machine_regs.op_index = (state_machine_regs.op_index + uladv) % linfo.li_max_ops_per_insn; + if (addrdelta) + state_machine_regs.view = 0; } break; @@ -4141,6 +4211,7 @@ display_debug_lines_decoded (struct dwarf_section *section, SAFE_BYTE_GET_AND_INC (uladv, data, 2, end); state_machine_regs.address += uladv; state_machine_regs.op_index = 0; + /* Do NOT reset view. */ break; case DW_LNS_set_prologue_end: @@ -4172,8 +4243,8 @@ display_debug_lines_decoded (struct dwarf_section *section, /* Only Special opcodes, DW_LNS_copy and DW_LNE_end_sequence adds a row to the DWARF address/line matrix. */ - if ((is_special_opcode) || (op_code == DW_LNE_end_sequence) - || (op_code == DW_LNS_copy)) + if ((is_special_opcode) || (xop == -DW_LNE_end_sequence) + || (xop == DW_LNS_copy)) { const unsigned int MAX_FILENAME_LENGTH = 35; char *fileName; @@ -4214,11 +4285,11 @@ display_debug_lines_decoded (struct dwarf_section *section, if (!do_wide || (fileNameLength <= MAX_FILENAME_LENGTH)) { if (linfo.li_max_ops_per_insn == 1) - printf ("%-35s %11d %#18" DWARF_VMA_FMT "x\n", + printf ("%-35s %11d %#18" DWARF_VMA_FMT "x", newFileName, state_machine_regs.line, state_machine_regs.address); else - printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]\n", + printf ("%-35s %11d %#18" DWARF_VMA_FMT "x[%d]", newFileName, state_machine_regs.line, state_machine_regs.address, state_machine_regs.op_index); @@ -4226,18 +4297,27 @@ display_debug_lines_decoded (struct dwarf_section *section, else { if (linfo.li_max_ops_per_insn == 1) - printf ("%s %11d %#18" DWARF_VMA_FMT "x\n", + printf ("%s %11d %#18" DWARF_VMA_FMT "x", newFileName, state_machine_regs.line, state_machine_regs.address); else - printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]\n", + printf ("%s %11d %#18" DWARF_VMA_FMT "x[%d]", newFileName, state_machine_regs.line, state_machine_regs.address, state_machine_regs.op_index); } - if (op_code == DW_LNE_end_sequence) - printf ("\n"); + if (state_machine_regs.view) + printf (" %6u\n", state_machine_regs.view); + else + putchar ('\n'); + state_machine_regs.view++; + + if (xop == -DW_LNE_end_sequence) + { + reset_state_machine (linfo.li_default_is_stmt); + putchar ('\n'); + } free (newFileName); } diff --git a/binutils/testsuite/binutils-all/dw2-1.W b/binutils/testsuite/binutils-all/dw2-1.W index d70581b2956..fb9c7989f37 100644 --- a/binutils/testsuite/binutils-all/dw2-1.W +++ b/binutils/testsuite/binutils-all/dw2-1.W @@ -69,7 +69,7 @@ Raw dump of debug contents of section .z?debug_line: \[0x.*\] Extended opcode 2: set Address to 0x4 \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to 0x8 \[0x.*\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/dw2-3.W b/binutils/testsuite/binutils-all/dw2-3.W index 08a7f356df4..af77f87aca8 100644 --- a/binutils/testsuite/binutils-all/dw2-3.W +++ b/binutils/testsuite/binutils-all/dw2-3.W @@ -149,7 +149,7 @@ Raw dump of debug contents of section .z?debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/dw2-3gabi.W b/binutils/testsuite/binutils-all/dw2-3gabi.W index 0d0fe6afbbe..4a7926021b1 100644 --- a/binutils/testsuite/binutils-all/dw2-3gabi.W +++ b/binutils/testsuite/binutils-all/dw2-3gabi.W @@ -149,7 +149,7 @@ Raw dump of debug contents of section .debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/dw5.W b/binutils/testsuite/binutils-all/dw5.W index 6f3f8efa124..1fa0d5d07b6 100644 --- a/binutils/testsuite/binutils-all/dw5.W +++ b/binutils/testsuite/binutils-all/dw5.W @@ -345,11 +345,13 @@ Raw dump of debug contents of section .debug_line: Decoded dump of debug contents of section .debug_line: CU: ./main.c: -File name Line number Starting address +File name Line number Starting address View main.c 6 0x1234 main.c 6 0x12346 +main.c 6 0x1234 main.c 5 0x1234 main.c 5 0x1234 +main.c 5 0x1234 diff --git a/binutils/testsuite/binutils-all/i386/compressed-1a.d b/binutils/testsuite/binutils-all/i386/compressed-1a.d index 5f02defbfcc..a45c6b88a4a 100644 --- a/binutils/testsuite/binutils-all/i386/compressed-1a.d +++ b/binutils/testsuite/binutils-all/i386/compressed-1a.d @@ -96,7 +96,7 @@ Raw dump of debug contents of section .[z]?debug_line: \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Advance Line by 10 to 11 \[0x.*\] Copy - \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 \(view 1\) \[0x.*\] Advance Line by -7 to 5 \[0x.*\] Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5 \[0x.*\] Special opcode 49: advance Address by 3 to 0x13 and Line by 2 to 7 diff --git a/binutils/testsuite/binutils-all/libdw2-compressedgabi.out b/binutils/testsuite/binutils-all/libdw2-compressedgabi.out index 3baa42ab4ce..ab456d5a388 100644 --- a/binutils/testsuite/binutils-all/libdw2-compressedgabi.out +++ b/binutils/testsuite/binutils-all/libdw2-compressedgabi.out @@ -70,7 +70,7 @@ Raw dump of debug contents of section .debug_line: \[0x.*\] Extended opcode 2: set Address to 0x4 \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to 0x8 \[0x.*\] Extended opcode 1: End of Sequence @@ -172,7 +172,7 @@ Raw dump of debug contents of section .debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence @@ -355,7 +355,7 @@ Raw dump of debug contents of section .debug_line: \[0x0000002d\] Extended opcode 2: set Address to 0x0 \[0x00000034\] Advance Line by 3 to 4 \[0x00000036\] Copy - \[0x00000037\] Copy + \[0x00000037\] Copy \(view 1\) \[0x00000038\] Extended opcode 2: set Address to 0x4 \[0x0000003f\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/objdump.W b/binutils/testsuite/binutils-all/objdump.W index a5379d0c561..5f977eefb13 100644 --- a/binutils/testsuite/binutils-all/objdump.W +++ b/binutils/testsuite/binutils-all/objdump.W @@ -69,7 +69,7 @@ Raw dump of debug contents of section .z?debug_line: \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Extended opcode 1: End of Sequence diff --git a/binutils/testsuite/binutils-all/objdump.WL b/binutils/testsuite/binutils-all/objdump.WL index 3846f4fce1a..7c5a591a6dd 100644 --- a/binutils/testsuite/binutils-all/objdump.WL +++ b/binutils/testsuite/binutils-all/objdump.WL @@ -4,7 +4,7 @@ Decoded dump of debug contents of section \.debug_line: CU: \./dw2-decodedline\.c: -File name Line number Starting address +File name Line number Starting address View directory/file1\.c: file1\.c 1 .* @@ -12,4 +12,5 @@ file1\.c 1 .* \./dw2-decodedline\.c:\[\+\+\] dw2-decodedline\.c 2 .* +dw2-decodedline\.c 2 .* diff --git a/binutils/testsuite/binutils-all/x86-64/compressed-1a.d b/binutils/testsuite/binutils-all/x86-64/compressed-1a.d index 574b719b79a..75b8ce597f5 100644 --- a/binutils/testsuite/binutils-all/x86-64/compressed-1a.d +++ b/binutils/testsuite/binutils-all/x86-64/compressed-1a.d @@ -96,10 +96,10 @@ Raw dump of debug contents of section .[z]?debug_line: \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Advance Line by 10 to 11 \[0x.*\] Copy - \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 12 \(view 1\) \[0x.*\] Advance Line by -7 to 5 \[0x.*\] Special opcode 229: advance Address by 16 to 0x10 and Line by 0 to 5 - \[0x.*\] Special opcode 6: advance Address by 0 to 0x10 and Line by 1 to 6 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x10 and Line by 1 to 6 \(view 1\) \[0x.*\] Advance PC by 5 to 0x15 \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/ChangeLog b/gas/ChangeLog index fe8476f9689..58f2ef4ce17 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -5,6 +5,80 @@ * doc/as.texinfo: Add z14 to CPU string list. * doc/c-s390.texi: Likewise. +2017-07-21 Alexandre Oliva + + * dwarf2dbg.c (unused): Check offset of next in struct line_entry. + (current): Initialize view. + (force_reset_view, view_assert_failed): New variables. + (reverse_line_entry_list): New function. + (set_or_check_view): Likewise. + (dwarf2_gen_line_info_1): Call it. + (dwarf2_where): Set view to NULL. + (dwarf2_emit_insn): Return early when called before first file. + (dwarf2_directive_loc): Add view support. Emit insn + immediately when view option is given. + (process_entries): Avoid set_address to reset view when a known + address change already implies the view reset. + (dwarf2dbg_final_check): New function. + * dwarf2dbg.h (struct dwarf2_line_info): Add view. + (dwarf2dbg_final_check): Declare. + * read.c (s_leb128): Parse expression as deferred. + * write.c (write_object_file): Check pending view asserts. + (cvt_frag_to_fill): Complain about undefined leb128 operand. + * doc/as.texinfo (.loc): Document view support. + * NEWS: Mention the new feature. + * testsuite/gas/all/gas.exp: Run sleb128-9. + * testsuite/gas/all/sleb128-9.d: New. + * testsuite/gas/all/sleb128-9.l: New. + * testsuite/gas/all/sleb128-9.s: New. + * testsuite/gas/elf/dwarf2-1.d: Add nonzero views. + * testsuite/gas/elf/dwarf2-2.d: Likewise. + * testsuite/gas/elf/dwarf2-5.d: New. + * testsuite/gas/elf/dwarf2-5.s: New. + * testsuite/gas/elf/dwarf2-6.d: New. + * testsuite/gas/elf/dwarf2-6.s: New. + * testsuite/gas/elf/dwarf2-7.d: New. + * testsuite/gas/elf/dwarf2-7.s: New. + * testsuite/gas/elf/dwarf2-8.d: New. + * testsuite/gas/elf/dwarf2-8.l: New. + * testsuite/gas/elf/dwarf2-8.s: New. + * testsuite/gas/elf/dwarf2-9.d: New. + * testsuite/gas/elf/dwarf2-9.l: New. + * testsuite/gas/elf/dwarf2-9.s: New. + * testsuite/gas/elf/dwarf2-10.d: New. + * testsuite/gas/elf/dwarf2-10.l: New. + * testsuite/gas/elf/dwarf2-10.s: New. + * testsuite/gas/elf/dwarf2-11.d: New. + * testsuite/gas/elf/dwarf2-11.s: New. + * testsuite/gas/elf/dwarf2-12.d: New. + * testsuite/gas/elf/dwarf2-12.s: New. + * testsuite/gas/elf/dwarf2-13.d: New. + * testsuite/gas/elf/dwarf2-13.s: New. + * testsuite/gas/elf/dwarf2-14.d: New. + * testsuite/gas/elf/dwarf2-14.s: New. + * testsuite/gas/elf/dwarf2-15.d: New. + * testsuite/gas/elf/dwarf2-15.s: New. + * testsuite/gas/elf/dwarf2-16.d: New. + * testsuite/gas/elf/dwarf2-16.s: New. + * testsuite/gas/elf/dwarf2-17.d: New. + * testsuite/gas/elf/dwarf2-17.s: New. + * testsuite/gas/elf/dwarf2-18.d: New. + * testsuite/gas/elf/dwarf2-18.s: New. + * testsuite/gas/elf/elf.exp: Run dwarf2-5..18 tests. + * testsuite/gas/i386/dw2-compress-1.d: Add nonzero views. + * testsuite/gas/i386/dw2-compressed-1.d: Likewise. + * testsuite/gas/i386/ilp32/lns/lns-duplicate.d: Likewise. + * testsuite/gas/lns/lns-big-delta.d: Likewise. + * testsuite/gas/lns/lns-duplicate.d: Likewise. + * testsuite/gas/mips/loc-swap-2.d: Likewise. + * testsuite/gas/mips/loc-swap-3.d: Likewise. + * testsuite/gas/mips/loc-swap.d: Likewise. + * testsuite/gas/mips/micromips@loc-swap-2.d: Likewise. + * testsuite/gas/mips/micromips@loc-swap.d: Likewise. + * testsuite/gas/mips/mips16@loc-swap-2.d: Likewise. + * testsuite/gas/mips/mips16@loc-swap.d: Likewise. + * testsuite/gas/mips/mips16e@loc-swap.d: Likewise. + 2017-07-19 Claudiu Zissulescu * testsuite/gas/arc/jli-1.d: New file. diff --git a/gas/NEWS b/gas/NEWS index ef44007c989..843f6c1120e 100644 --- a/gas/NEWS +++ b/gas/NEWS @@ -1,5 +1,7 @@ -*- text -*- +* Add support for loaction views in DWARF debug line information. + Changes in 2.29: * Add support for ELF SHF_GNU_MBIND. diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index b82204dfdf7..8aa83ef1eb3 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -5833,6 +5833,19 @@ state machine to @var{value}, which must be an unsigned integer. This directive will set the @code{discriminator} register in the @code{.debug_line} state machine to @var{value}, which must be an unsigned integer. +@item view @var{value} +This option causes a row to be added to @code{.debug_line} in reference to the +current address (which might not be the same as that of the following assembly +instruction), and to associate @var{value} with the @code{view} register in the +@code{.debug_line} state machine. If @var{value} is a label, both the +@code{view} register and the label are set to the number of prior @code{.loc} +directives at the same program location. If @var{value} is the literal +@code{0}, the @code{view} register is set to zero, and the assembler asserts +that there aren't any prior @code{.loc} directives at the same program +location. If @var{value} is the literal @code{-0}, the assembler arrange for +the @code{view} register to be reset in this row, even if there are prior +@code{.loc} directives at the same program location. + @end table @node Loc_mark_labels diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c index e02b6e8f020..4f703304d52 100644 --- a/gas/dwarf2dbg.c +++ b/gas/dwarf2dbg.c @@ -162,13 +162,20 @@ #define TC_PARSE_CONS_RETURN_NONE BFD_RELOC_NONE #endif -struct line_entry { +struct line_entry +{ struct line_entry *next; symbolS *label; struct dwarf2_line_info loc; }; -struct line_subseg { +/* Don't change the offset of next in line_entry. set_or_check_view + calls in dwarf2_gen_line_info_1 depend on it. */ +static char unused[offsetof(struct line_entry, next) ? -1 : 1] +ATTRIBUTE_UNUSED; + +struct line_subseg +{ struct line_subseg *next; subsegT subseg; struct line_entry *head; @@ -176,7 +183,8 @@ struct line_subseg { struct line_entry **pmove_tail; }; -struct line_seg { +struct line_seg +{ struct line_seg *next; segT seg; struct line_subseg *head; @@ -188,7 +196,8 @@ struct line_seg { static struct line_seg *all_segs; static struct line_seg **last_seg_ptr; -struct file_entry { +struct file_entry +{ const char *filename; unsigned int dir; }; @@ -212,12 +221,21 @@ bfd_boolean dwarf2_loc_directive_seen; bfd_boolean dwarf2_loc_mark_labels; /* Current location as indicated by the most recent .loc directive. */ -static struct dwarf2_line_info current = { +static struct dwarf2_line_info current = +{ 1, 1, 0, 0, DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0, - 0 + 0, NULL }; +/* This symbol is used to recognize view number forced resets in loc + lists. */ +static symbolS *force_reset_view; + +/* This symbol evaluates to an expression that, if nonzero, indicates + some view assert check failed. */ +static symbolS *view_assert_failed; + /* The size of an address on the target. */ static unsigned int sizeof_address; @@ -283,6 +301,168 @@ get_line_subseg (segT seg, subsegT subseg, bfd_boolean create_p) return lss; } +/* (Un)reverse the line_entry list starting from H. */ + +static struct line_entry * +reverse_line_entry_list (struct line_entry *h) +{ + struct line_entry *p = NULL, *e, *n; + + for (e = h; e; e = n) + { + n = e->next; + e->next = p; + p = e; + } + return p; +} + +/* Compute the view for E based on the previous entry P. If we + introduce an (undefined) view symbol for P, and H is given (P must + be the tail in this case), introduce view symbols for earlier list + entries as well, until one of them is constant. */ + +static void +set_or_check_view (struct line_entry *e, struct line_entry *p, + struct line_entry *h) +{ + expressionS viewx; + + memset (&viewx, 0, sizeof (viewx)); + viewx.X_unsigned = 1; + + /* First, compute !(E->label > P->label), to tell whether or not + we're to reset the view number. If we can't resolve it to a + constant, keep it symbolic. */ + if (!p || (e->loc.view == force_reset_view && force_reset_view)) + { + viewx.X_op = O_constant; + viewx.X_add_number = 0; + viewx.X_add_symbol = NULL; + viewx.X_op_symbol = NULL; + } + else + { + viewx.X_op = O_gt; + viewx.X_add_number = 0; + viewx.X_add_symbol = e->label; + viewx.X_op_symbol = p->label; + resolve_expression (&viewx); + if (viewx.X_op == O_constant) + viewx.X_add_number = !viewx.X_add_number; + else + { + viewx.X_add_symbol = make_expr_symbol (&viewx); + viewx.X_add_number = 0; + viewx.X_op_symbol = NULL; + viewx.X_op = O_logical_not; + } + } + + if (S_IS_DEFINED (e->loc.view) && symbol_constant_p (e->loc.view)) + { + expressionS *value = symbol_get_value_expression (e->loc.view); + /* We can't compare the view numbers at this point, because in + VIEWX we've only determined whether we're to reset it so + far. */ + if (viewx.X_op == O_constant) + { + if (!value->X_add_number != !viewx.X_add_number) + as_bad (_("view number mismatch")); + } + /* Record the expression to check it later. It is the result of + a logical not, thus 0 or 1. We just add up all such deferred + expressions, and resolve it at the end. */ + else if (!value->X_add_number) + { + symbolS *deferred = make_expr_symbol (&viewx); + if (view_assert_failed) + { + expressionS chk; + memset (&chk, 0, sizeof (chk)); + chk.X_unsigned = 1; + chk.X_op = O_add; + chk.X_add_number = 0; + chk.X_add_symbol = view_assert_failed; + chk.X_op_symbol = deferred; + deferred = make_expr_symbol (&chk); + } + view_assert_failed = deferred; + } + } + + if (viewx.X_op != O_constant || viewx.X_add_number) + { + expressionS incv; + + if (!p->loc.view) + { + p->loc.view = symbol_temp_make (); + gas_assert (!S_IS_DEFINED (p->loc.view)); + } + + memset (&incv, 0, sizeof (incv)); + incv.X_unsigned = 1; + incv.X_op = O_symbol; + incv.X_add_symbol = p->loc.view; + incv.X_add_number = 1; + + if (viewx.X_op == O_constant) + { + gas_assert (viewx.X_add_number == 1); + viewx = incv; + } + else + { + viewx.X_add_symbol = make_expr_symbol (&viewx); + viewx.X_add_number = 0; + viewx.X_op_symbol = make_expr_symbol (&incv); + viewx.X_op = O_multiply; + } + } + + if (!S_IS_DEFINED (e->loc.view)) + { + symbol_set_value_expression (e->loc.view, &viewx); + S_SET_SEGMENT (e->loc.view, absolute_section); + symbol_set_frag (e->loc.view, &zero_address_frag); + } + + /* Define and attempt to simplify any earlier views needed to + compute E's. */ + if (h && p && p->loc.view && !S_IS_DEFINED (p->loc.view)) + { + struct line_entry *h2; + /* Reverse the list to avoid quadratic behavior going backwards + in a single-linked list. */ + struct line_entry *r = reverse_line_entry_list (h); + + gas_assert (r == p); + /* Set or check views until we find a defined or absent view. */ + do + set_or_check_view (r, r->next, NULL); + while (r->next && r->next->loc.view && !S_IS_DEFINED (r->next->loc.view) + && (r = r->next)); + + /* Unreverse the list, so that we can go forward again. */ + h2 = reverse_line_entry_list (p); + gas_assert (h2 == h); + + /* Starting from the last view we just defined, attempt to + simplify the view expressions, until we do so to P. */ + do + { + gas_assert (S_IS_DEFINED (r->loc.view)); + resolve_expression (symbol_get_value_expression (r->loc.view)); + } + while (r != p && (r = r->next)); + + /* Now that we've defined and computed all earlier views that might + be needed to compute E's, attempt to simplify it. */ + resolve_expression (symbol_get_value_expression (e->loc.view)); + } +} + /* Record an entry for LOC occurring at LABEL. */ static void @@ -297,6 +477,12 @@ dwarf2_gen_line_info_1 (symbolS *label, struct dwarf2_line_info *loc) e->loc = *loc; lss = get_line_subseg (now_seg, now_subseg, TRUE); + + if (loc->view) + set_or_check_view (e, + !lss->head ? NULL : (struct line_entry *)lss->ptail, + lss->head); + *lss->ptail = e; lss->ptail = &e->next; } @@ -350,12 +536,16 @@ dwarf2_where (struct dwarf2_line_info *line) { if (debug_type == DEBUG_DWARF2) { - const char *filename = as_where (&line->line); + const char *filename; + + memset (line, 0, sizeof (*line)); + filename = as_where (&line->line); line->filenum = get_filenum (filename, 0); line->column = 0; line->flags = DWARF2_FLAG_IS_STMT; line->isa = current.isa; line->discriminator = current.discriminator; + line->view = NULL; } else *line = current; @@ -380,7 +570,9 @@ dwarf2_emit_insn (int size) { struct dwarf2_line_info loc; - if (!dwarf2_loc_directive_seen && debug_type != DEBUG_DWARF2) + if (debug_type != DEBUG_DWARF2 + ? !dwarf2_loc_directive_seen + : !seen_at_least_1_file ()) return; dwarf2_where (&loc); @@ -721,6 +913,54 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED) return; } } + else if (strcmp (p, "view") == 0) + { + symbolS *sym; + + (void) restore_line_pointer (c); + SKIP_WHITESPACE (); + + if (ISDIGIT (*input_line_pointer) + || *input_line_pointer == '-') + { + bfd_boolean force_reset = *input_line_pointer == '-'; + + value = get_absolute_expression (); + if (value != 0) + { + as_bad (_("numeric view can only be asserted to zero")); + return; + } + if (force_reset && force_reset_view) + sym = force_reset_view; + else + { + sym = symbol_temp_new (absolute_section, value, + &zero_address_frag); + if (force_reset) + force_reset_view = sym; + } + } + else + { + char *name = read_symbol_name (); + + if (!name) + return; + sym = symbol_find_or_make (name); + if (S_IS_DEFINED (sym)) + { + if (!S_CAN_BE_REDEFINED (sym)) + as_bad (_("symbol `%s' is already defined"), name); + else + sym = symbol_clone (sym, 1); + S_SET_SEGMENT (sym, undefined_section); + S_SET_VALUE (sym, 0); + symbol_set_frag (sym, &zero_address_frag); + } + } + current.view = sym; + } else { as_bad (_("unknown .loc sub-directive `%s'"), p); @@ -734,6 +974,10 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED) demand_empty_rest_of_line (); dwarf2_loc_directive_seen = TRUE; debug_type = DEBUG_NONE; + + /* If we were given a view id, emit the row right away. */ + if (current.view) + dwarf2_emit_insn (0); } void @@ -1362,7 +1606,19 @@ process_entries (segT seg, struct line_entry *e) frag = symbol_get_frag (lab); frag_ofs = S_GET_VALUE (lab); - if (last_frag == NULL) + if (last_frag == NULL + || (e->loc.view == force_reset_view && force_reset_view + /* If we're going to reset the view, but we know we're + advancing the PC, we don't have to force with + set_address. We know we do when we're at the same + address of the same frag, and we know we might when + we're in the beginning of a frag, and we were at the + end of the previous frag. */ + && (frag == last_frag + ? (last_frag_ofs == frag_ofs) + : (frag_ofs == 0 + && ((offsetT)last_frag_ofs + >= get_frag_fix (last_frag, seg)))))) { out_set_addr (lab); out_inc_line_addr (line_delta, 0); @@ -1975,3 +2231,42 @@ dwarf2_finish (void) name_sym, comp_dir_sym, producer_sym); } } + +/* Perform any deferred checks pertaining to debug information. */ + +void +dwarf2dbg_final_check (void) +{ + /* Perform reset-view checks. Don't evaluate view_assert_failed + recursively: it could be very deep. It's a chain of adds, with + each chain element pointing to the next in X_add_symbol, and + holding the check value in X_op_symbol. */ + while (view_assert_failed) + { + expressionS *expr; + symbolS *sym; + offsetT failed; + + gas_assert (!symbol_resolved_p (view_assert_failed)); + + expr = symbol_get_value_expression (view_assert_failed); + sym = view_assert_failed; + + /* If view_assert_failed looks like a compound check in the + chain, break it up. */ + if (expr->X_op == O_add && expr->X_add_number == 0 && expr->X_unsigned) + { + view_assert_failed = expr->X_add_symbol; + sym = expr->X_op_symbol; + } + else + view_assert_failed = NULL; + + failed = resolve_symbol_value (sym); + if (!symbol_resolved_p (sym) || failed) + { + as_bad (_("view number mismatch")); + break; + } + } +} diff --git a/gas/dwarf2dbg.h b/gas/dwarf2dbg.h index 9e2ceada080..60a05685ab9 100644 --- a/gas/dwarf2dbg.h +++ b/gas/dwarf2dbg.h @@ -28,19 +28,21 @@ #define DWARF2_FLAG_PROLOGUE_END (1 << 2) #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3) -struct dwarf2_line_info { +struct dwarf2_line_info +{ unsigned int filenum; unsigned int line; unsigned int column; unsigned int isa; unsigned int flags; unsigned int discriminator; + symbolS *view; }; /* Implements the .file FILENO "FILENAME" directive. FILENO can be 0 to indicate that no file number has been assigned. All real file number must be >0. */ -extern char *dwarf2_directive_file (int dummy); +extern char *dwarf2_directive_file (int); /* Implements the .loc FILENO LINENO [COLUMN] directive. FILENO is the file number, LINENO the line number and the (optional) COLUMN @@ -48,27 +50,27 @@ extern char *dwarf2_directive_file (int dummy); corresponds to. FILENO can be 0 to indicate that the filename specified by the textually most recent .file directive should be used. */ -extern void dwarf2_directive_loc (int dummy); +extern void dwarf2_directive_loc (int); /* Implements the .loc_mark_labels {0,1} directive. */ -extern void dwarf2_directive_loc_mark_labels (int dummy); +extern void dwarf2_directive_loc_mark_labels (int); /* Returns the current source information. If .file directives have been encountered, the info for the corresponding source file is returned. Otherwise, the info for the assembly source file is returned. */ -extern void dwarf2_where (struct dwarf2_line_info *l); +extern void dwarf2_where (struct dwarf2_line_info *); /* A hook to allow the target backend to inform the line number state machine of isa changes when assembler debug info is enabled. */ -extern void dwarf2_set_isa (unsigned int isa); +extern void dwarf2_set_isa (unsigned int); /* This function generates .debug_line info based on the address and source information passed in the arguments. ADDR should be the frag-relative offset of the instruction the information is for and L is the source information that should be associated with that address. */ -extern void dwarf2_gen_line_info (addressT addr, struct dwarf2_line_info *l); +extern void dwarf2_gen_line_info (addressT, struct dwarf2_line_info *); /* Must be called for each generated instruction. */ extern void dwarf2_emit_insn (int); @@ -99,9 +101,12 @@ extern int dwarf2dbg_estimate_size_before_relax (fragS *); extern int dwarf2dbg_relax_frag (fragS *); extern void dwarf2dbg_convert_frag (fragS *); +extern void dwarf2dbg_final_check (void); + /* An enumeration which describes the sizes of offsets (to DWARF sections) and the mechanism by which the size is indicated. */ -enum dwarf2_format { +enum dwarf2_format +{ /* 32-bit format: the initial length field is 4 bytes long. */ dwarf2_format_32bit, /* DWARF3 64-bit format: the representation of the initial length diff --git a/gas/read.c b/gas/read.c index a26d4fe44df..9627ef513bf 100644 --- a/gas/read.c +++ b/gas/read.c @@ -5384,7 +5384,7 @@ s_leb128 (int sign) do { - expression (&exp); + deferred_expression (&exp); emit_leb128_expr (&exp, sign); } while (*input_line_pointer++ == ','); diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp index b5b0bebbf35..e43947d42a0 100644 --- a/gas/testsuite/gas/all/gas.exp +++ b/gas/testsuite/gas/all/gas.exp @@ -394,6 +394,7 @@ if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } { run_dump_test sleb128-7 run_dump_test sleb128-8 } +run_dump_test sleb128-9 # .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x # .space is different on hppa*-hpux. diff --git a/gas/testsuite/gas/all/sleb128-9.d b/gas/testsuite/gas/all/sleb128-9.d new file mode 100644 index 00000000000..5c5997f3786 --- /dev/null +++ b/gas/testsuite/gas/all/sleb128-9.d @@ -0,0 +1,5 @@ +#name: undefined symbols in sleb128 directive +#source: sleb128-9.s +#error-output: sleb128-9.l +#not-target: riscv*-* + diff --git a/gas/testsuite/gas/all/sleb128-9.l b/gas/testsuite/gas/all/sleb128-9.l new file mode 100644 index 00000000000..19842fa2611 --- /dev/null +++ b/gas/testsuite/gas/all/sleb128-9.l @@ -0,0 +1,3 @@ +[^:]*: Assembler messages: +[^:]*:2: Error: leb128 operand is an undefined symbol: \.Lundef +[^:]*:3: Error: leb128 operand is an undefined symbol: undef diff --git a/gas/testsuite/gas/all/sleb128-9.s b/gas/testsuite/gas/all/sleb128-9.s new file mode 100644 index 00000000000..87cb9550135 --- /dev/null +++ b/gas/testsuite/gas/all/sleb128-9.s @@ -0,0 +1,3 @@ + .data + .sleb128 .Lundef + .sleb128 undef diff --git a/gas/testsuite/gas/avr/large-debug-line-table.d b/gas/testsuite/gas/avr/large-debug-line-table.d index 31ca7edd143..ecba3dfdd00 100644 --- a/gas/testsuite/gas/avr/large-debug-line-table.d +++ b/gas/testsuite/gas/avr/large-debug-line-table.d @@ -9,7 +9,7 @@ Decoded dump of debug contents of section \.debug_line: CU: large-debug-line-table\.c: -File name Line number Starting address +File name Line number Starting address.* large-debug-line-table\.c 1 0 #... diff --git a/gas/testsuite/gas/elf/dwarf2-1.d b/gas/testsuite/gas/elf/dwarf2-1.d index bae2f630ea7..d8b79effc78 100644 --- a/gas/testsuite/gas/elf/dwarf2-1.d +++ b/gas/testsuite/gas/elf/dwarf2-1.d @@ -71,7 +71,7 @@ Raw dump of debug contents of section .[z]?debug_line: \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/elf/dwarf2-10.d b/gas/testsuite/gas/elf/dwarf2-10.d new file mode 100644 index 00000000000..13c3171e5a6 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-10.d @@ -0,0 +1,6 @@ +#as: +#name: DWARF2 10 +#error-output: dwarf2-10.l +# The mep target tries to relay code sections which breaks symbolic view computations. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: mep-* tile*-* diff --git a/gas/testsuite/gas/elf/dwarf2-10.l b/gas/testsuite/gas/elf/dwarf2-10.l new file mode 100644 index 00000000000..b5f1f6549c8 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-10.l @@ -0,0 +1,2 @@ +[^:]*: Assembler messages: +[^:]*: Error: view number mismatch diff --git a/gas/testsuite/gas/elf/dwarf2-10.s b/gas/testsuite/gas/elf/dwarf2-10.s new file mode 100644 index 00000000000..d159d438b95 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-10.s @@ -0,0 +1,32 @@ +/* Test view numbering zero-assert checking with zero-sized align. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-10.c" + .text + .balign 4 + .globl _start +_start: + .file 1 "dwarf2-10.c" + .loc 1 1 view 0 + .balign 4 /* No skip needed here... */ + .loc 1 2 view 0 /* so this zero-view check fails. */ + .int 0 + .loc 1 3 view 0 + .balign 8 /* Skip 4 more bytes after .int... */ + .loc 1 4 view 0 /* so this is a zero view indeed. */ + .int 0 + .size _start, .-_start diff --git a/gas/testsuite/gas/elf/dwarf2-11.d b/gas/testsuite/gas/elf/dwarf2-11.d new file mode 100644 index 00000000000..797d50d3682 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-11.d @@ -0,0 +1,15 @@ +#as: +#readelf: -wL +#name: DWARF2 11 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* m32c-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-11\.c: +File name *Line number *Starting address *View +dwarf2-11\.c *1 *0x4 +dwarf2-11\.c *2 *0x8 +dwarf2-11\.c *2 *0x8 *1 diff --git a/gas/testsuite/gas/elf/dwarf2-11.s b/gas/testsuite/gas/elf/dwarf2-11.s new file mode 100644 index 00000000000..a1b0d0a8b94 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-11.s @@ -0,0 +1,28 @@ +/* Test view numbering zero-assert checking with nonzero-sized align. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-11.c" + .text + .balign 8 + .globl _start +_start: + .file 1 "dwarf2-11.c" + .dc.l 0 + .loc 1 1 view 0 + .balign 8 + .loc 1 2 view 0 + .size _start, .-_start diff --git a/gas/testsuite/gas/elf/dwarf2-12.d b/gas/testsuite/gas/elf/dwarf2-12.d new file mode 100644 index 00000000000..0e1bc9b0cd1 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-12.d @@ -0,0 +1,20 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 12 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + + +Hex dump of section '\.rodata': + 0x00000000 01 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-12\.c: +File name *Line number *Starting address *View +dwarf2-12\.c *1 *0 +dwarf2-12\.c *2 *0 +dwarf2-12\.c *3 *0 *1 +dwarf2-12\.c *3 *0x4 diff --git a/gas/testsuite/gas/elf/dwarf2-12.s b/gas/testsuite/gas/elf/dwarf2-12.s new file mode 100644 index 00000000000..3e3392a6185 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-12.s @@ -0,0 +1,31 @@ +/* Test view numbering forced reset in a single frag. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-12.c" + .text + .balign 4 + .globl _start +_start: + .file 1 "dwarf2-12.c" + .loc 1 1 view 0 + .loc 1 2 view -0 + .loc 1 3 view .L1 + .dc.l 0 + .size _start, .-_start + + .section .rodata + .uleb128 .L1 diff --git a/gas/testsuite/gas/elf/dwarf2-13.d b/gas/testsuite/gas/elf/dwarf2-13.d new file mode 100644 index 00000000000..6961a6b6421 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-13.d @@ -0,0 +1,19 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 13 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 01 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-13\.c: +File name *Line number *Starting address *View +dwarf2-13\.c *1 *0x4 +dwarf2-13\.c *2 *0x8 +dwarf2-13\.c *3 *0x8 *1 +dwarf2-13\.c *3 *0xc diff --git a/gas/testsuite/gas/elf/dwarf2-13.s b/gas/testsuite/gas/elf/dwarf2-13.s new file mode 100644 index 00000000000..118d692ce2b --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-13.s @@ -0,0 +1,33 @@ +/* Test view numbering forced reset after a nonzero-sized align. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-13.c" + .text + .balign 8 + .globl _start +_start: + .file 1 "dwarf2-13.c" + .dc.l 0 + .loc 1 1 view 0 + .balign 8 + .loc 1 2 view -0 + .loc 1 3 view .L1 + .dc.l 0 + .size _start, .-_start + + .section .rodata + .uleb128 .L1 diff --git a/gas/testsuite/gas/elf/dwarf2-14.d b/gas/testsuite/gas/elf/dwarf2-14.d new file mode 100644 index 00000000000..88af1452ceb --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-14.d @@ -0,0 +1,19 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 14 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 01 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-14\.c: +File name *Line number *Starting address *View +dwarf2-14\.c *1 *0 +dwarf2-14\.c *2 *0 +dwarf2-14\.c *3 *0 *1 +dwarf2-14\.c *3 *0x4 diff --git a/gas/testsuite/gas/elf/dwarf2-14.s b/gas/testsuite/gas/elf/dwarf2-14.s new file mode 100644 index 00000000000..80f91ffc634 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-14.s @@ -0,0 +1,32 @@ +/* Test view numbering forced reset after a zero-sized align. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-14.c" + .text + .balign 4 + .globl _start +_start: + .file 1 "dwarf2-14.c" + .loc 1 1 view 0 + .balign 4 + .loc 1 2 view -0 + .loc 1 3 view .L1 + .dc.l 0 + .size _start, .-_start + + .section .rodata + .uleb128 .L1 diff --git a/gas/testsuite/gas/elf/dwarf2-15.d b/gas/testsuite/gas/elf/dwarf2-15.d new file mode 100644 index 00000000000..c7280e514ef --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-15.d @@ -0,0 +1,19 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 15 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 01 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-15\.c: +File name *Line number *Starting address *View +dwarf2-15\.c *1 *0 +dwarf2-15\.c *2 *0x4 +dwarf2-15\.c *3 *0x4 *1 +dwarf2-15\.c *3 *0x8 diff --git a/gas/testsuite/gas/elf/dwarf2-15.s b/gas/testsuite/gas/elf/dwarf2-15.s new file mode 100644 index 00000000000..e41f84aba41 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-15.s @@ -0,0 +1,32 @@ +/* Test view numbering forced reset in a single frag. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-15.c" + .text + .balign 8 + .globl _start +_start: + .file 1 "dwarf2-15.c" + .loc 1 1 view 0 + .dc.l 0 + .loc 1 2 view -0 + .loc 1 3 view .L1 + .dc.l 0 + .size _start, .-_start + + .section .rodata + .uleb128 .L1 diff --git a/gas/testsuite/gas/elf/dwarf2-16.d b/gas/testsuite/gas/elf/dwarf2-16.d new file mode 100644 index 00000000000..b01292ecdb2 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-16.d @@ -0,0 +1,20 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 16 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The mep target tries to relay code sections which breaks symbolic view computations. +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mep-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 01 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-16\.c: +File name *Line number *Starting address *View +dwarf2-16\.c *1 *0 +dwarf2-16\.c *2 *0x4 +dwarf2-16\.c *3 *0x4 *1 +dwarf2-16\.c *3 *0x8 diff --git a/gas/testsuite/gas/elf/dwarf2-16.s b/gas/testsuite/gas/elf/dwarf2-16.s new file mode 100644 index 00000000000..deacf5638d0 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-16.s @@ -0,0 +1,33 @@ +/* Test view numbering after a zero-sized align. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-16.c" + .text + .balign 8 + .globl _start +_start: + .file 1 "dwarf2-16.c" + .loc 1 1 view 0 + .dc.l 0 + .loc 1 2 view 0 + .balign 4 + .loc 1 3 view .L1 + .dc.l 0 + .size _start, .-_start + + .section .rodata + .uleb128 .L1 diff --git a/gas/testsuite/gas/elf/dwarf2-17.d b/gas/testsuite/gas/elf/dwarf2-17.d new file mode 100644 index 00000000000..8c5c287a7d9 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-17.d @@ -0,0 +1,20 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 17 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The mep target tries to relay code sections which breaks symbolic view computations. +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mep-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 00 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-17\.c: +File name *Line number *Starting address *View +dwarf2-17\.c *1 *0 +dwarf2-17\.c *2 *0x4 +dwarf2-17\.c *3 *0x8 +dwarf2-17\.c *3 *0xc diff --git a/gas/testsuite/gas/elf/dwarf2-17.s b/gas/testsuite/gas/elf/dwarf2-17.s new file mode 100644 index 00000000000..4e5d91bc10c --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-17.s @@ -0,0 +1,33 @@ +/* Test view numbering after a nonzero-sized align. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-17.c" + .text + .balign 8 + .globl _start +_start: + .file 1 "dwarf2-17.c" + .loc 1 1 view 0 + .dc.l 0 + .loc 1 2 view 0 + .balign 8 + .loc 1 3 view .L1 + .dc.l 0 + .size _start, .-_start + + .section .rodata + .uleb128 .L1 diff --git a/gas/testsuite/gas/elf/dwarf2-18.d b/gas/testsuite/gas/elf/dwarf2-18.d new file mode 100644 index 00000000000..08f1af80267 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-18.d @@ -0,0 +1,19 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 18 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 0100 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-18\.c: +File name *Line number *Starting address *View +dwarf2-18\.c *1 *0 +dwarf2-18\.c *2 *0 *1 +dwarf2-18\.c *3 *0x4 +dwarf2-18\.c *3 *0x8 diff --git a/gas/testsuite/gas/elf/dwarf2-18.s b/gas/testsuite/gas/elf/dwarf2-18.s new file mode 100644 index 00000000000..9e5e210b800 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-18.s @@ -0,0 +1,33 @@ +/* Test view numbering after view-less .loc. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-18.c" + .text + .balign 8 + .globl _start +_start: + .file 1 "dwarf2-18.c" + .loc 1 1 + .loc 1 2 view .L1 + .dc.l 0 + .loc 1 3 view .L2 + .dc.l 0 + .size _start, .-_start + + .section .rodata + .uleb128 .L1 + .uleb128 .L2 diff --git a/gas/testsuite/gas/elf/dwarf2-2.d b/gas/testsuite/gas/elf/dwarf2-2.d index b42a2ec5e64..8cc1c3bb039 100644 --- a/gas/testsuite/gas/elf/dwarf2-2.d +++ b/gas/testsuite/gas/elf/dwarf2-2.d @@ -71,7 +71,7 @@ Raw dump of debug contents of section .[z]?debug_line: \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/elf/dwarf2-5.d b/gas/testsuite/gas/elf/dwarf2-5.d new file mode 100644 index 00000000000..6525c2ee14e --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-5.d @@ -0,0 +1,79 @@ +#as: +#readelf: -x.rodata -wlL +#name: DWARF2 5 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 rx and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The mep target tries to relay code sections which breaks symbolic view computations. +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mep-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* rx-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 01010201 010203 *.* + +Raw dump of debug contents of section \.debug_line: + + Offset: 0x0 + Length: [0-9]* + DWARF Version: 2 + Prologue Length: [0-9]* + Minimum Instruction Length: [0-9]* + Initial value of 'is_stmt': 1 + Line Base: [-0-9]* + Line Range: [0-9]* + Opcode Base: [0-9]* + + Opcodes: + Opcode 1 has 0 args + Opcode 2 has 1 args + Opcode 3 has 1 args + Opcode 4 has 1 args + Opcode 5 has 1 args + Opcode 6 has 0 args + Opcode 7 has 0 args + Opcode 8 has 0 args + Opcode 9 has 1 args + Opcode 10 has 0 args + Opcode 11 has 0 args + Opcode 12 has 1 args + + The Directory Table is empty. + + The File Name Table \(offset 0x1c\): + Entry Dir Time Size Name + 1 0 0 0 dwarf2-5\.c + + Line Number Statements: + \[0x.*\] Extended opcode 2: set Address to 0x0 + \[0x.*\] Copy + \[0x.*\] Special opcode [0-9]*: advance Address by 0 to 0x0 and Line by 1 to 2 \(view 1\) + \[0x.*\] Special opcode [0-9]*: advance Address by 4 to 0x4 and Line by 1 to 3 + \[0x.*\] Special opcode [0-9]*: advance Address by 0 to 0x4 and Line by 1 to 4 \(view 1\) + \[0x.*\] Special opcode [0-9]*: advance Address by 0 to 0x4 and Line by 1 to 5 \(view 2\) + \[0x.*\] Special opcode [0-9]*: advance Address by 4 to 0x8 and Line by 1 to 6 + \[0x.*\] Special opcode [0-9]*: advance Address by 4 to 0xc and Line by 1 to 7 + \[0x.*\] Special opcode [0-9]*: advance Address by 0 to 0xc and Line by 1 to 8 \(view 1\) + \[0x.*\] Special opcode [0-9]*: advance Address by 4 to 0x10 and Line by 1 to 9 + \[0x.*\] Special opcode [0-9]*: advance Address by 0 to 0x10 and Line by 1 to 10 \(view 1\) + \[0x.*\] Special opcode [0-9]*: advance Address by 0 to 0x10 and Line by 1 to 11 \(view 2\) + \[0x.*\] Special opcode [0-9]*: advance Address by 0 to 0x10 and Line by 1 to 12 \(view 3\) + \[0x.*\] Advance PC by 4 to 0x14 + \[0x.*\] Extended opcode 1: End of Sequence + + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-5\.c: +File name *Line number *Starting address *View +dwarf2-5\.c *1 *0 +dwarf2-5\.c *2 *0 *1 +dwarf2-5\.c *3 *0x4 +dwarf2-5\.c *4 *0x4 *1 +dwarf2-5\.c *5 *0x4 *2 +dwarf2-5\.c *6 *0x8 +dwarf2-5\.c *7 *0xc +dwarf2-5\.c *8 *0xc *1 +dwarf2-5\.c *9 *0x10 +dwarf2-5\.c *10 *0x10 *1 +dwarf2-5\.c *11 *0x10 *2 +dwarf2-5\.c *12 *0x10 *3 +dwarf2-5\.c *12 *0x14 diff --git a/gas/testsuite/gas/elf/dwarf2-5.s b/gas/testsuite/gas/elf/dwarf2-5.s new file mode 100644 index 00000000000..3e58239f0ab --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-5.s @@ -0,0 +1,58 @@ +/* Test view numbering. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-5.c" + .text + .balign 4 + .globl _start +_start: + .file 1 "dwarf2-5.c" + .loc 1 1 view 0 + .loc 1 2 view .L2 + .dc.l 0 + .loc 1 3 view 0 + .balign 4 + .loc 1 4 view .L4 + .loc 1 5 view .L5 + .org .+1 + .balign 4 + .loc 1 6 view 0 + .dc.l 0 + .text + .globl func + .type func, %function +func: + .loc 1 7 view 0 + .loc 1 8 view .L8 + .dc.l 0 + .loc 1 9 view 0 + .loc 1 10 view .L10 + .pushsection .text + .loc 1 11 view .L11 + .popsection + .loc 1 12 view .L12 + .dc.l 0 + .size func, .-func + + .section .rodata + .uleb128 .L2 + .uleb128 .L4 + .uleb128 .L5 + .uleb128 .L8 + .uleb128 .L10 + .uleb128 .L11 + .uleb128 .L12 diff --git a/gas/testsuite/gas/elf/dwarf2-6.d b/gas/testsuite/gas/elf/dwarf2-6.d new file mode 100644 index 00000000000..93489d6ba9d --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-6.d @@ -0,0 +1,78 @@ +#as: +#readelf: -wlL +#name: DWARF2 6 +# These targets either do not support or do not evaluate the subtraction of symbols at assembly time +#not-target: am3-* avr-* cr16-* crx-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* xtensa-* + +Raw dump of debug contents of section .debug_line: + + Offset: 0x0 + Length: 84 + DWARF Version: 2 + Prologue Length: 36 + Minimum Instruction Length: 1 + Initial value of 'is_stmt': 1 + Line Base: 1 + Line Range: 1 + Opcode Base: 16 + + Opcodes: + Opcode 1 has 0 args + Opcode 2 has 1 args + Opcode 3 has 1 args + Opcode 4 has 1 args + Opcode 5 has 1 args + Opcode 6 has 0 args + Opcode 7 has 0 args + Opcode 8 has 0 args + Opcode 9 has 1 args + Opcode 10 has 0 args + Opcode 11 has 0 args + Opcode 12 has 1 args + Opcode 13 has 0 args + Opcode 14 has 0 args + Opcode 15 has 0 args + + The Directory Table is empty. + + The File Name Table \(offset 0x1f\): + Entry Dir Time Size Name + 1 0 0 0 dwarf2-6\.c + + + Line Number Statements: + \[0x.*\] Extended opcode 2: set Address to 0x0 + \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) + \[0x.*\] Extended opcode 2: set Address to 0x1 + \[0x.*\] Copy + \[0x.*\] Advance PC by 0 to 0x1 + \[0x.*\] Copy \(view 1\) + \[0x.*\] Advance PC by 1 to 0x2 + \[0x.*\] Copy + \[0x.*\] Advance PC by fixed size amount 1 to 0x3 + \[0x.*\] Copy \(view 1\) + \[0x.*\] Special opcode 0: advance Address by 0 to 0x3 and Line by 1 to 2 \(view 2\) + \[0x.*\] Special opcode 1: advance Address by 1 to 0x4 and Line by 1 to 3 + \[0x.*\] Copy \(view 1\) + \[0x.*\] Advance PC by constant 239 to 0xf3 + \[0x.*\] Copy + \[0x.*\] Extended opcode 2: set Address to 0x100 + \[0x.*\] Extended opcode 1: End of Sequence + + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-6\.c: +File name *Line number *Starting address *View +dwarf2-6\.c *1 *0 +dwarf2-6\.c *1 *0 *1 +dwarf2-6\.c *1 *0x1 +dwarf2-6\.c *1 *0x1 *1 +dwarf2-6\.c *1 *0x2 +dwarf2-6\.c *1 *0x3 *1 +dwarf2-6\.c *2 *0x3 *2 +dwarf2-6\.c *3 *0x4 +dwarf2-6\.c *3 *0x4 *1 +dwarf2-6\.c *3 *0xf3 +dwarf2-6\.c *3 *0x100 diff --git a/gas/testsuite/gas/elf/dwarf2-6.s b/gas/testsuite/gas/elf/dwarf2-6.s new file mode 100644 index 00000000000..28b1829b9f1 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-6.s @@ -0,0 +1,101 @@ +/* Test view number decoding. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-6.c" + .text + .balign 4 + .globl _start +_start: +.L_start: + .org .+256 +.Lend_start: + + .section .debug_line,"",%progbits + .4byte .Lline_end - .Lline_start /* Initial length. */ +.Lline_start: + .2byte 2 /* Dwarf Version. */ + .4byte .Lline_lines - .Lline_hdr +.Lline_hdr: + .byte 1 /* Minimum insn length. */ + .byte 1 /* Default is_stmt. */ + .byte 1 /* Line base. */ + .byte 1 /* Line range. */ + .byte 0x10 /* Opcode base. */ + + /* Standard lengths. */ + .byte 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0 + + .byte 0 /* Include directories. */ + + /* File names. */ + .ascii "dwarf2-6.c\0" + .uleb128 0, 0, 0 + + .byte 0 + +.Lline_lines: + .byte 0 /* DW_LNS_extended_op. */ + .uleb128 5 + .byte 2 /* DW_LNE_set_address. */ + .4byte .L_start + + .byte 1 /* DW_LNS_copy view 0. */ + + .byte 1 /* DW_LNS_copy view 1. */ + + .byte 0 /* DW_LNS_extended_op. */ + .uleb128 5 + .byte 2 /* DW_LNE_set_address. */ + .4byte .L_start+1 + + .byte 1 /* DW_LNS_copy view 0. */ + + .byte 2 /* DW_LNS_advance_pc by 0. */ + .uleb128 0 + + .byte 1 /* DW_LNS_copy view 1. */ + + .byte 2 /* DW_LNS_advance_pc by 1 (reset view). */ + .uleb128 1 + + .byte 1 /* DW_LNS_copy view 0. */ + + .byte 9 /* DW_LNS_fixed_advance_pc by 1. */ + .2byte 1 /* This opcode does NOT reset view. */ + + .byte 1 /* DW_LNS_copy view 1. */ + + .byte 16 /* Special opcode 0, PC+=0, Line+=1, view 2. */ + + .byte 17 /* Special opcode 1, PC+=1 (reset view), Line+=1. */ + + .byte 1 /* DW_LNS_copy view 1. */ + + .byte 8 /* DW_LNS_const_add_pc by 239 (reset view). */ + + .byte 1 /* DW_LNS_copy view 0. */ + + .byte 0 /* DW_LNS_extended_op. */ + .uleb128 5 + .byte 2 /* DW_LNE_set_address. */ + .4byte .Lend_start + + .byte 0 /* DW_LNS_extended_op. */ + .uleb128 1 + .byte 1 /* DW_LEN_end_of_sequence. */ + +.Lline_end: diff --git a/gas/testsuite/gas/elf/dwarf2-7.d b/gas/testsuite/gas/elf/dwarf2-7.d new file mode 100644 index 00000000000..8782d6bc442 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-7.d @@ -0,0 +1,19 @@ +#as: +#readelf: -x.rodata -wL +#name: DWARF2 7 +# The am3 avr cr16 crx mn10 msp430 nds32 pru rl78 and xtensa targets do not evaluate the subtraction of symbols at assembly time +# The riscv targets do not support the subtraction of symbols. +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: am3-* avr-* cr16-* crx-* mn10*-* msp430-* nds32*-* pru-* riscv*-* rl78-* tile*-* xtensa-* + +Hex dump of section '\.rodata': + 0x00000000 01 *.* + +Decoded dump of debug contents of section \.debug_line: + +CU: dwarf2-7\.c: +File name *Line number *Starting address *View +dwarf2-7\.c *1 *0 +dwarf2-7\.c *2 *0 +dwarf2-7\.c *3 *0 *1 +dwarf2-7\.c *3 *0x. diff --git a/gas/testsuite/gas/elf/dwarf2-7.s b/gas/testsuite/gas/elf/dwarf2-7.s new file mode 100644 index 00000000000..e96e64e7fb9 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-7.s @@ -0,0 +1,36 @@ +/* Test view numbering forced reset. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-7.c" + .text + .balign 4 + .globl _start +_start: + .file 1 "dwarf2-7.c" + .loc 1 1 view 0 + + .section .rodata + .uleb128 .L1 + + .text + .globl func + .type func, %function +func: + .loc 1 2 view -0 + .loc 1 3 view .L1 + .dc.l 0 + .size func, .-func diff --git a/gas/testsuite/gas/elf/dwarf2-8.d b/gas/testsuite/gas/elf/dwarf2-8.d new file mode 100644 index 00000000000..455079d9512 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-8.d @@ -0,0 +1,5 @@ +#as: +#name: DWARF2 8 +#error-output: dwarf2-8.l +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: tile*-* diff --git a/gas/testsuite/gas/elf/dwarf2-8.l b/gas/testsuite/gas/elf/dwarf2-8.l new file mode 100644 index 00000000000..60c73e5a0a8 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-8.l @@ -0,0 +1,2 @@ +[^:]*: Assembler messages: +[^:]*:25: Error: view number mismatch diff --git a/gas/testsuite/gas/elf/dwarf2-8.s b/gas/testsuite/gas/elf/dwarf2-8.s new file mode 100644 index 00000000000..228063c6fd4 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-8.s @@ -0,0 +1,27 @@ +/* Test view numbering zero-assert checking, same frag. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-8.c" + .text + .balign 4 + .globl _start +_start: + .file 1 "dwarf2-8.c" + .loc 1 1 view 0 + .loc 1 2 view 0 + .int 0 + .size _start, .-_start diff --git a/gas/testsuite/gas/elf/dwarf2-9.d b/gas/testsuite/gas/elf/dwarf2-9.d new file mode 100644 index 00000000000..ebf11cbb329 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-9.d @@ -0,0 +1,5 @@ +#as: +#name: DWARF2 9 +#error-output: dwarf2-9.l +# The tile targets require 8-byte instructions, but the test only simulates 4-byte instructions. +#not-target: tile*-* diff --git a/gas/testsuite/gas/elf/dwarf2-9.l b/gas/testsuite/gas/elf/dwarf2-9.l new file mode 100644 index 00000000000..fb447740f28 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-9.l @@ -0,0 +1,2 @@ +[^:]*: Assembler messages: +[^:]*.* Error: view number mismatch diff --git a/gas/testsuite/gas/elf/dwarf2-9.s b/gas/testsuite/gas/elf/dwarf2-9.s new file mode 100644 index 00000000000..afc2019bcc4 --- /dev/null +++ b/gas/testsuite/gas/elf/dwarf2-9.s @@ -0,0 +1,32 @@ +/* Test view numbering zero-assert checking, different frag. + + Copyright (C) 2017 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + .file "dwarf2-9.c" + .text + .balign 4 + .globl _start +_start: + .file 1 "dwarf2-9.c" + .loc 1 1 view 0 + + .section .rodata + .uleb128 0 + + .text + .loc 1 2 view 0 + .int 0 + .size _start, .-_start diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 6b2b31a04ef..c04c74b958a 100644 --- a/gas/testsuite/gas/elf/elf.exp +++ b/gas/testsuite/gas/elf/elf.exp @@ -220,6 +220,20 @@ if { [is_elf_format] } then { run_dump_test "dwarf2-2" run_dump_test "dwarf2-3" run_dump_test "dwarf2-4" + run_dump_test "dwarf2-5" + run_dump_test "dwarf2-6" + run_dump_test "dwarf2-7" + run_dump_test "dwarf2-8" + run_dump_test "dwarf2-9" + run_dump_test "dwarf2-10" + run_dump_test "dwarf2-11" + run_dump_test "dwarf2-12" + run_dump_test "dwarf2-13" + run_dump_test "dwarf2-14" + run_dump_test "dwarf2-15" + run_dump_test "dwarf2-16" + run_dump_test "dwarf2-17" + run_dump_test "dwarf2-18" run_dump_test "bss" run_dump_test "bad-bss" run_dump_test "bad-section-flag" diff --git a/gas/testsuite/gas/i386/dw2-compress-1.d b/gas/testsuite/gas/i386/dw2-compress-1.d index ceebb3f108a..bfd4837422d 100644 --- a/gas/testsuite/gas/i386/dw2-compress-1.d +++ b/gas/testsuite/gas/i386/dw2-compress-1.d @@ -97,7 +97,7 @@ Raw dump of debug contents of section .z?debug_line: \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to 0x4 \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/i386/dw2-compressed-1.d b/gas/testsuite/gas/i386/dw2-compressed-1.d index f4c110d52f0..0a2a092e0df 100644 --- a/gas/testsuite/gas/i386/dw2-compressed-1.d +++ b/gas/testsuite/gas/i386/dw2-compressed-1.d @@ -98,7 +98,7 @@ Raw dump of debug contents of section .debug_line: \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Advance Line by 3 to 4 \[0x.*\] Copy - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Extended opcode 2: set Address to 0x4 \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/i386/ilp32/lns/lns-duplicate.d b/gas/testsuite/gas/i386/ilp32/lns/lns-duplicate.d index c4e5c6f4881..fc0f861eb74 100644 --- a/gas/testsuite/gas/i386/ilp32/lns/lns-duplicate.d +++ b/gas/testsuite/gas/i386/ilp32/lns/lns-duplicate.d @@ -7,5 +7,5 @@ Raw dump of debug contents of section \.z?debug_line: \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Copy \[0x.*\] Set basic block - \[0x.*\] .* by 1 to 2 + \[0x.*\] .* by 1 to 2 \(view 1\) #pass diff --git a/gas/testsuite/gas/lns/lns-big-delta.d b/gas/testsuite/gas/lns/lns-big-delta.d index d86f434fdd4..65e0ce174fe 100644 --- a/gas/testsuite/gas/lns/lns-big-delta.d +++ b/gas/testsuite/gas/lns/lns-big-delta.d @@ -8,7 +8,7 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Copy \[0x.*\] Advance Line by 1 to 2 \[0x.*\] Advance PC by fixed size amount 0 to 0x0 - \[0x.*\] Copy + \[0x.*\] Copy \(view 1\) \[0x.*\] Advance Line by 1 to 3 \[0x.*\] Extended opcode 2: set Address to 0x.* \[0x.*\] Copy diff --git a/gas/testsuite/gas/lns/lns-common-1-alt.d b/gas/testsuite/gas/lns/lns-common-1-alt.d index e762b831664..8aa8c7356c3 100644 --- a/gas/testsuite/gas/lns/lns-common-1-alt.d +++ b/gas/testsuite/gas/lns/lns-common-1-alt.d @@ -7,37 +7,37 @@ Raw dump of debug contents of section \.debug_line: #... Line Number Statements: \[0x.*\] Extended opcode 2: set Address to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 1\)|) \[0x.*\] Set column to 3 \[0x.*\] Advance Line by 1 to 2 \[0x.*\] Advance PC by fixed size amount .* to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 1\)|) \[0x.*\] Set prologue_end to true \[0x.*\] Advance Line by 1 to 3 \[0x.*\] Advance PC by fixed size amount .* to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 2\)|) \[0x.*\] Set column to 0 \[0x.*\] Set epilogue_begin to true \[0x.*\] Advance Line by 1 to 4 \[0x.*\] Advance PC by fixed size amount .* to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 3\)|) \[0x.*\] Set ISA to 1 \[0x.*\] Set basic block \[0x.*\] Advance Line by 1 to 5 \[0x.*\] Advance PC by fixed size amount .* to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 4\)|) \[0x.*\] Set is_stmt to 0 \[0x.*\] Advance Line by 1 to 6 \[0x.*\] Advance PC by fixed size amount .* to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 5\)|) \[0x.*\] Set is_stmt to 1 \[0x.*\] Advance Line by 1 to 7 \[0x.*\] Advance PC by fixed size amount .* to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 6\)|) \[0x.*\] Extended opcode 4: set Discriminator to 1 \[0x.*\] Advance Line by 0 to 7 \[0x.*\] Advance PC by fixed size amount .* to .* - \[0x.*\] Copy + \[0x.*\] Copy( \(view 7\)|) \[0x.*\] Advance PC by fixed size amount .* to .* \[0x.*\] Extended opcode 1: End of Sequence #... diff --git a/gas/testsuite/gas/lns/lns-duplicate.d b/gas/testsuite/gas/lns/lns-duplicate.d index 9fe28ab5a77..6aed5e75b9d 100644 --- a/gas/testsuite/gas/lns/lns-duplicate.d +++ b/gas/testsuite/gas/lns/lns-duplicate.d @@ -6,5 +6,5 @@ Raw dump of debug contents of section \.z?debug_line: \[0x.*\] Extended opcode 2: set Address to .* \[0x.*\] Copy \[0x.*\] Set basic block - \[0x.*\] .* by 1 to 2 + \[0x.*\] .* by 1 to 2( \(view 1\)|) #pass diff --git a/gas/testsuite/gas/mips/loc-swap-2.d b/gas/testsuite/gas/mips/loc-swap-2.d index ed280a8dfea..6176614b1e3 100644 --- a/gas/testsuite/gas/mips/loc-swap-2.d +++ b/gas/testsuite/gas/mips/loc-swap-2.d @@ -39,11 +39,11 @@ Raw dump of debug contents of section .debug_line: Line Number Statements: \[0x.*\] Extended opcode 2: set Address to 0x0 \[0x.*\] Special opcode 11: advance Address by 0 to 0x0 and Line by 6 to 7 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x0 and Line by 2 to 9 - \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 10 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x0 and Line by 2 to 9 \(view 1\) + \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 10 \(view 2\) \[0x.*\] Special opcode 120: advance Address by 8 to 0x8 and Line by 3 to 13 \[0x.*\] Special opcode 62: advance Address by 4 to 0xc and Line by 1 to 14 - \[0x.*\] Special opcode 6: advance Address by 0 to 0xc and Line by 1 to 15 + \[0x.*\] Special opcode 6: advance Address by 0 to 0xc and Line by 1 to 15 \(view 1\) \[0x.*\] Special opcode 119: advance Address by 8 to 0x14 and Line by 2 to 17 \[0x.*\] Advance PC by 4 to 0x18 \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/mips/loc-swap-3.d b/gas/testsuite/gas/mips/loc-swap-3.d index 2e46e0456d8..0610a443f7d 100644 --- a/gas/testsuite/gas/mips/loc-swap-3.d +++ b/gas/testsuite/gas/mips/loc-swap-3.d @@ -12,6 +12,6 @@ # Set prologue_end to true # here #------------------------------------------------------------------------ -.* Special opcode 6: advance Address by 0 to 0x[01] and Line by 1 to 2 +.* Special opcode 6: advance Address by 0 to 0x[01] and Line by 1 to 2 \(view 1\) .* Advance PC by .* .* Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/mips/loc-swap.d b/gas/testsuite/gas/mips/loc-swap.d index 4e11106a186..94fe7cd0987 100644 --- a/gas/testsuite/gas/mips/loc-swap.d +++ b/gas/testsuite/gas/mips/loc-swap.d @@ -44,9 +44,9 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Special opcode 11: advance Address by 0 to 0x0 and Line by 6 to 7 \[0x.*\] Special opcode 63: advance Address by 4 to 0x4 and Line by 2 to 9 \[0x.*\] Special opcode 120: advance Address by 8 to 0xc and Line by 3 to 12 - \[0x.*\] Special opcode 7: advance Address by 0 to 0xc and Line by 2 to 14 + \[0x.*\] Special opcode 7: advance Address by 0 to 0xc and Line by 2 to 14 \(view 1\) \[0x.*\] Special opcode 120: advance Address by 8 to 0x14 and Line by 3 to 17 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x14 and Line by 2 to 19 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x14 and Line by 2 to 19 \(view 1\) \[0x.*\] Special opcode 120: advance Address by 8 to 0x1c and Line by 3 to 22 \[0x.*\] Special opcode 63: advance Address by 4 to 0x20 and Line by 2 to 24 \[0x.*\] Special opcode 120: advance Address by 8 to 0x28 and Line by 3 to 27 @@ -54,7 +54,7 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Special opcode 120: advance Address by 8 to 0x34 and Line by 3 to 32 \[0x.*\] Special opcode 63: advance Address by 4 to 0x38 and Line by 2 to 34 \[0x.*\] Special opcode 120: advance Address by 8 to 0x40 and Line by 3 to 37 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x40 and Line by 2 to 39 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x40 and Line by 2 to 39 \(view 1\) \[0x.*\] Special opcode 120: advance Address by 8 to 0x48 and Line by 3 to 42 \[0x.*\] Special opcode 63: advance Address by 4 to 0x4c and Line by 2 to 44 \[0x.*\] Advance PC by 36 to 0x70 diff --git a/gas/testsuite/gas/mips/micromips@loc-swap-2.d b/gas/testsuite/gas/mips/micromips@loc-swap-2.d index e148f25d9b7..9504be7c30c 100644 --- a/gas/testsuite/gas/mips/micromips@loc-swap-2.d +++ b/gas/testsuite/gas/mips/micromips@loc-swap-2.d @@ -39,11 +39,11 @@ Raw dump of debug contents of section .debug_line: Line Number Statements: \[0x.*\] Extended opcode 2: set Address to 0x1 \[0x.*\] Special opcode 11: advance Address by 0 to 0x1 and Line by 6 to 7 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x1 and Line by 2 to 9 - \[0x.*\] Special opcode 6: advance Address by 0 to 0x1 and Line by 1 to 10 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x1 and Line by 2 to 9 \(view 1\) + \[0x.*\] Special opcode 6: advance Address by 0 to 0x1 and Line by 1 to 10 \(view 2\) \[0x.*\] Special opcode 64: advance Address by 4 to 0x5 and Line by 3 to 13 \[0x.*\] Special opcode 34: advance Address by 2 to 0x7 and Line by 1 to 14 - \[0x.*\] Special opcode 6: advance Address by 0 to 0x7 and Line by 1 to 15 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x7 and Line by 1 to 15 \(view 1\) \[0x.*\] Special opcode 63: advance Address by 4 to 0xb and Line by 2 to 17 \[0x.*\] Advance PC by 1 to 0xc \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/mips/micromips@loc-swap.d b/gas/testsuite/gas/mips/micromips@loc-swap.d index 23aedae972d..1427feea1be 100644 --- a/gas/testsuite/gas/mips/micromips@loc-swap.d +++ b/gas/testsuite/gas/mips/micromips@loc-swap.d @@ -45,9 +45,9 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Special opcode 11: advance Address by 0 to 0x1 and Line by 6 to 7 \[0x.*\] Special opcode 35: advance Address by 2 to 0x3 and Line by 2 to 9 \[0x.*\] Special opcode 36: advance Address by 2 to 0x5 and Line by 3 to 12 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x5 and Line by 2 to 14 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x5 and Line by 2 to 14 \(view 1\) \[0x.*\] Special opcode 64: advance Address by 4 to 0x9 and Line by 3 to 17 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x9 and Line by 2 to 19 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x9 and Line by 2 to 19 \(view 1\) \[0x.*\] Special opcode 64: advance Address by 4 to 0xd and Line by 3 to 22 \[0x.*\] Special opcode 35: advance Address by 2 to 0xf and Line by 2 to 24 \[0x.*\] Special opcode 36: advance Address by 2 to 0x11 and Line by 3 to 27 diff --git a/gas/testsuite/gas/mips/mips16@loc-swap-2.d b/gas/testsuite/gas/mips/mips16@loc-swap-2.d index 95b9e9c10b7..a4cc0005ad3 100644 --- a/gas/testsuite/gas/mips/mips16@loc-swap-2.d +++ b/gas/testsuite/gas/mips/mips16@loc-swap-2.d @@ -39,11 +39,11 @@ Raw dump of debug contents of section .debug_line: Line Number Statements: \[0x.*\] Extended opcode 2: set Address to 0x1 \[0x.*\] Special opcode 11: advance Address by 0 to 0x1 and Line by 6 to 7 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x1 and Line by 2 to 9 - \[0x.*\] Special opcode 6: advance Address by 0 to 0x1 and Line by 1 to 10 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x1 and Line by 2 to 9 \(view 1\) + \[0x.*\] Special opcode 6: advance Address by 0 to 0x1 and Line by 1 to 10 \(view 2\) \[0x.*\] Special opcode 64: advance Address by 4 to 0x5 and Line by 3 to 13 \[0x.*\] Special opcode 34: advance Address by 2 to 0x7 and Line by 1 to 14 - \[0x.*\] Special opcode 6: advance Address by 0 to 0x7 and Line by 1 to 15 + \[0x.*\] Special opcode 6: advance Address by 0 to 0x7 and Line by 1 to 15 \(view 1\) \[0x.*\] Special opcode 35: advance Address by 2 to 0x9 and Line by 2 to 17 \[0x.*\] Advance PC by 1 to 0xa \[0x.*\] Extended opcode 1: End of Sequence diff --git a/gas/testsuite/gas/mips/mips16@loc-swap.d b/gas/testsuite/gas/mips/mips16@loc-swap.d index 4d0c781f57c..9b023461d71 100644 --- a/gas/testsuite/gas/mips/mips16@loc-swap.d +++ b/gas/testsuite/gas/mips/mips16@loc-swap.d @@ -44,9 +44,9 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Special opcode 11: advance Address by 0 to 0x1 and Line by 6 to 7 \[0x.*\] Special opcode 35: advance Address by 2 to 0x3 and Line by 2 to 9 \[0x.*\] Special opcode 64: advance Address by 4 to 0x7 and Line by 3 to 12 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x7 and Line by 2 to 14 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x7 and Line by 2 to 14 \(view 1\) \[0x.*\] Special opcode 64: advance Address by 4 to 0xb and Line by 3 to 17 - \[0x.*\] Special opcode 7: advance Address by 0 to 0xb and Line by 2 to 19 + \[0x.*\] Special opcode 7: advance Address by 0 to 0xb and Line by 2 to 19 \(view 1\) \[0x.*\] Special opcode 64: advance Address by 4 to 0xf and Line by 3 to 22 \[0x.*\] Special opcode 35: advance Address by 2 to 0x11 and Line by 2 to 24 \[0x.*\] Special opcode 64: advance Address by 4 to 0x15 and Line by 3 to 27 @@ -54,7 +54,7 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Special opcode 64: advance Address by 4 to 0x1b and Line by 3 to 32 \[0x.*\] Special opcode 35: advance Address by 2 to 0x1d and Line by 2 to 34 \[0x.*\] Special opcode 64: advance Address by 4 to 0x21 and Line by 3 to 37 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x21 and Line by 2 to 39 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x21 and Line by 2 to 39 \(view 1\) \[0x.*\] Special opcode 92: advance Address by 6 to 0x27 and Line by 3 to 42 \[0x.*\] Special opcode 35: advance Address by 2 to 0x29 and Line by 2 to 44 \[0x.*\] Advance PC by 23 to 0x40 diff --git a/gas/testsuite/gas/mips/mips16e@loc-swap.d b/gas/testsuite/gas/mips/mips16e@loc-swap.d index 412e45bb7c3..7356e3f90fc 100644 --- a/gas/testsuite/gas/mips/mips16e@loc-swap.d +++ b/gas/testsuite/gas/mips/mips16e@loc-swap.d @@ -44,9 +44,9 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Special opcode 11: advance Address by 0 to 0x1 and Line by 6 to 7 \[0x.*\] Special opcode 35: advance Address by 2 to 0x3 and Line by 2 to 9 \[0x.*\] Special opcode 36: advance Address by 2 to 0x5 and Line by 3 to 12 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x5 and Line by 2 to 14 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x5 and Line by 2 to 14 \(view 1\) \[0x.*\] Special opcode 64: advance Address by 4 to 0x9 and Line by 3 to 17 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x9 and Line by 2 to 19 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x9 and Line by 2 to 19 \(view 1\) \[0x.*\] Special opcode 64: advance Address by 4 to 0xd and Line by 3 to 22 \[0x.*\] Special opcode 35: advance Address by 2 to 0xf and Line by 2 to 24 \[0x.*\] Special opcode 36: advance Address by 2 to 0x11 and Line by 3 to 27 @@ -54,7 +54,7 @@ Raw dump of debug contents of section \.debug_line: \[0x.*\] Special opcode 36: advance Address by 2 to 0x15 and Line by 3 to 32 \[0x.*\] Special opcode 35: advance Address by 2 to 0x17 and Line by 2 to 34 \[0x.*\] Special opcode 36: advance Address by 2 to 0x19 and Line by 3 to 37 - \[0x.*\] Special opcode 7: advance Address by 0 to 0x19 and Line by 2 to 39 + \[0x.*\] Special opcode 7: advance Address by 0 to 0x19 and Line by 2 to 39 \(view 1\) \[0x.*\] Special opcode 92: advance Address by 6 to 0x1f and Line by 3 to 42 \[0x.*\] Special opcode 35: advance Address by 2 to 0x21 and Line by 2 to 44 \[0x.*\] Advance PC by 31 to 0x40 diff --git a/gas/write.c b/gas/write.c index 1242cbf9985..8efdbc506f4 100644 --- a/gas/write.c +++ b/gas/write.c @@ -465,6 +465,13 @@ cvt_frag_to_fill (segT sec ATTRIBUTE_UNUSED, fragS *fragP) valueT value = S_GET_VALUE (fragP->fr_symbol); int size; + if (!S_IS_DEFINED (fragP->fr_symbol)) + { + as_bad_where (fragP->fr_file, fragP->fr_line, + _("leb128 operand is an undefined symbol: %s"), + S_GET_NAME (fragP->fr_symbol)); + } + size = output_leb128 (fragP->fr_literal + fragP->fr_fix, value, fragP->fr_subtype); @@ -1904,6 +1911,8 @@ write_object_file (void) /* Relaxation has completed. Freeze all syms. */ finalize_syms = 1; + dwarf2dbg_final_check (); + #ifdef md_post_relax_hook md_post_relax_hook; #endif diff --git a/ld/testsuite/ld-avr/gc-section-debugline.d b/ld/testsuite/ld-avr/gc-section-debugline.d index f8c07de6a4a..4c155a90d18 100644 --- a/ld/testsuite/ld-avr/gc-section-debugline.d +++ b/ld/testsuite/ld-avr/gc-section-debugline.d @@ -10,61 +10,60 @@ Decoded dump of debug contents of section .debug_line: .*: -File name Line number Starting address +File name Line number Starting address View per-function-debugline.s 39 0 -per-function-debugline.s 40 0x2 +per-function-debugline.s 40 0x2 1 -per-function-debugline.s 41 0x4 +per-function-debugline.s 41 0x4 2 -per-function-debugline.s 42 0x6 +per-function-debugline.s 42 0x6 3 -per-function-debugline.s 47 0x8 +per-function-debugline.s 47 0x8 4 -per-function-debugline.s 48 0xc +per-function-debugline.s 48 0xc 5 -per-function-debugline.s 49 0x10 +per-function-debugline.s 49 0x10 6 -per-function-debugline.s 50 0x12 +per-function-debugline.s 50 0x12 7 -per-function-debugline.s 51 0x16 +per-function-debugline.s 51 0x16 8 -per-function-debugline.s 52 0x1a +per-function-debugline.s 52 0x1a 9 -per-function-debugline.s 54 0x1c +per-function-debugline.s 54 0x1c 10 -per-function-debugline.s 55 0x1e +per-function-debugline.s 55 0x1e 11 -per-function-debugline.s 56 0x20 +per-function-debugline.s 56 0x20 12 -per-function-debugline.s 62 0x22 - -per-function-debugline.s 63 0x24 +per-function-debugline.s 56 0x22 13 -per-function-debugline.s 64 0x26 - -per-function-debugline.s 65 0x28 +per-function-debugline.s 62 0x22 -per-function-debugline.s 70 0x2a +per-function-debugline.s 63 0x24 1 -per-function-debugline.s 71 0x2e +per-function-debugline.s 64 0x26 2 -per-function-debugline.s 72 0x32 +per-function-debugline.s 65 0x28 3 -per-function-debugline.s 73 0x36 +per-function-debugline.s 70 0x2a 4 -per-function-debugline.s 74 0x38 +per-function-debugline.s 71 0x2e 5 -per-function-debugline.s 75 0x3c +per-function-debugline.s 72 0x32 6 -per-function-debugline.s 76 0x40 +per-function-debugline.s 73 0x36 7 -per-function-debugline.s 77 0x44 +per-function-debugline.s 74 0x38 8 -per-function-debugline.s 79 0x48 +per-function-debugline.s 75 0x3c 9 -per-function-debugline.s 80 0x4a +per-function-debugline.s 76 0x40 10 -per-function-debugline.s 81 0x4c +per-function-debugline.s 77 0x44 11 +per-function-debugline.s 79 0x48 12 +per-function-debugline.s 80 0x4a 13 +#pass