Discussion:
Introduce support for location views
(too old to reply)
Alexandre Oliva
2017-07-06 04:02:33 UTC
Permalink
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. Three forms are supported:

.loc ... view -0 ; (e.g. at a function start) force view to zero
.loc ... view 0 ; (after a PC change) assert view is zero
.loc ... view .Lvu ; (at the Nth view at PC) set .Lvu to N-1

As in https://people.redhat.com/aoliva/papers/sfn/dwarf6-sfn-lvu.txt
view numbers are NOT encoded explicitly in line number programs;
they're rather inferred from the program. So, instead of having the
compiler supply the assembler with view numbers, we let the assembler
compute them according to the line number program implicit rules, and
allow the compiler to refer to the computed numbers by storing the
numbers in label-like view numbers. Since the compiler can in many
cases know about PC changes, we allow the compiler to assert that the
view is reset at such points, so that it can safely assume the view
number is zero at them: the assembler will error out if the assumption
is incorrect.

View labels are meant to be used in location lists, as proposed for
DWARF6, or in view lists and augment location lists, a
backward-compatible extension. We do NOT have code to dump either
list yet. In either case, the view numbers are encoded as uleb128
sequences, which required the possibility of deferring the resolution
of uleb128 operands (we'd previously emit undefined or
not-yet-computed symbols as if they were zero). Nothing prevents
other uses of the view counters stored in view label symbols.

I've added code to dump (nonzero) view numbers in raw line number
programs and in decoded line number tables, and adjusted all tests
that, under the implicit view computation rules, had nonzero views in
them, so that their expected dumps would match the modified outputs.

I've added plenty of tests for view numbering, testing cases involving
alignment pseudo_ops that either change or don't change PC. I found
several cases in which I had to emit pending line number directives
before the pseudo_op takes effect, otherwise the view number would end
up being computed at the wrong PC, or even at the wrong section.

GCC has been modified to use the assembler to emit view-aware line
number programs, when it supports .loc views, and that compiler has
successfully bootstrapped using an assembler with this patch.


This was regression-tested on x86_64-linux-gnu. Ok to install?


for binutils/ChangeLog

* 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.

for gas/ChangeLog

* 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.
(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 (do_align): Emit pending loc insn first.
(s_fill, s_org, s_space, cons_worker): Likewise.
(float_cons, stringer, s_incbin): Likewise.
(s_leb128): Likewise. Parse expression as deferred.
* subsegs.c (subseg_set_rest): Emit pending loc insn first.
* 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.d: Likewise.
* testsuite/gas/mips/***@loc-swap-2.d: Likewise.
* testsuite/gas/mips/***@loc-swap.d: Likewise.
* testsuite/gas/mips/***@loc-swap-2.d: Likewise.
* testsuite/gas/mips/***@loc-swap.d: Likewise.
* testsuite/gas/mips/***@loc-swap.d: Likewise.
* write.c (write_object_file): Check pending view asserts.
(relax_segment): Complain about undefined leb128 operand.
---
binutils/dwarf.c | 162 +++++++++---
binutils/testsuite/binutils-all/dw2-1.W | 2
binutils/testsuite/binutils-all/dw2-3.W | 2
binutils/testsuite/binutils-all/dw2-3gabi.W | 2
binutils/testsuite/binutils-all/dw5.W | 4
.../testsuite/binutils-all/i386/compressed-1a.d | 2
.../binutils-all/libdw2-compressedgabi.out | 6
binutils/testsuite/binutils-all/objdump.W | 2
binutils/testsuite/binutils-all/objdump.WL | 3
.../testsuite/binutils-all/x86-64/compressed-1a.d | 4
gas/doc/as.texinfo | 14 +
gas/dwarf2dbg.c | 276 ++++++++++++++++++++
gas/dwarf2dbg.h | 3
gas/read.c | 20 +
gas/subsegs.c | 5
gas/testsuite/gas/all/gas.exp | 1
gas/testsuite/gas/all/sleb128-9.d | 4
gas/testsuite/gas/all/sleb128-9.l | 3
gas/testsuite/gas/all/sleb128-9.s | 3
gas/testsuite/gas/elf/dwarf2-1.d | 2
gas/testsuite/gas/elf/dwarf2-10.d | 3
gas/testsuite/gas/elf/dwarf2-10.l | 2
gas/testsuite/gas/elf/dwarf2-10.s | 32 ++
gas/testsuite/gas/elf/dwarf2-11.d | 11 +
gas/testsuite/gas/elf/dwarf2-11.s | 28 ++
gas/testsuite/gas/elf/dwarf2-12.d | 15 +
gas/testsuite/gas/elf/dwarf2-12.s | 31 ++
gas/testsuite/gas/elf/dwarf2-13.d | 15 +
gas/testsuite/gas/elf/dwarf2-13.s | 33 ++
gas/testsuite/gas/elf/dwarf2-14.d | 15 +
gas/testsuite/gas/elf/dwarf2-14.s | 32 ++
gas/testsuite/gas/elf/dwarf2-15.d | 15 +
gas/testsuite/gas/elf/dwarf2-15.s | 32 ++
gas/testsuite/gas/elf/dwarf2-16.d | 15 +
gas/testsuite/gas/elf/dwarf2-16.s | 33 ++
gas/testsuite/gas/elf/dwarf2-17.d | 15 +
gas/testsuite/gas/elf/dwarf2-17.s | 33 ++
gas/testsuite/gas/elf/dwarf2-18.d | 15 +
gas/testsuite/gas/elf/dwarf2-18.s | 33 ++
gas/testsuite/gas/elf/dwarf2-2.d | 2
gas/testsuite/gas/elf/dwarf2-5.d | 74 +++++
gas/testsuite/gas/elf/dwarf2-5.s | 58 ++++
gas/testsuite/gas/elf/dwarf2-6.d | 76 ++++++
gas/testsuite/gas/elf/dwarf2-6.s | 101 +++++++
gas/testsuite/gas/elf/dwarf2-7.d | 15 +
gas/testsuite/gas/elf/dwarf2-7.s | 36 +++
gas/testsuite/gas/elf/dwarf2-8.d | 3
gas/testsuite/gas/elf/dwarf2-8.l | 2
gas/testsuite/gas/elf/dwarf2-8.s | 27 ++
gas/testsuite/gas/elf/dwarf2-9.d | 3
gas/testsuite/gas/elf/dwarf2-9.l | 2
gas/testsuite/gas/elf/dwarf2-9.s | 32 ++
gas/testsuite/gas/elf/elf.exp | 14 +
gas/testsuite/gas/i386/dw2-compress-1.d | 2
gas/testsuite/gas/i386/dw2-compressed-1.d | 2
gas/testsuite/gas/i386/ilp32/lns/lns-duplicate.d | 2
gas/testsuite/gas/lns/lns-big-delta.d | 2
gas/testsuite/gas/lns/lns-duplicate.d | 2
gas/testsuite/gas/mips/loc-swap-2.d | 8 -
gas/testsuite/gas/mips/loc-swap.d | 6
gas/testsuite/gas/mips/***@loc-swap-2.d | 6
gas/testsuite/gas/mips/***@loc-swap.d | 4
gas/testsuite/gas/mips/***@loc-swap-2.d | 6
gas/testsuite/gas/mips/***@loc-swap.d | 6
gas/testsuite/gas/mips/***@loc-swap.d | 6
gas/write.c | 9 +
66 files changed, 1348 insertions(+), 86 deletions(-)
create mode 100644 gas/testsuite/gas/all/sleb128-9.d
create mode 100644 gas/testsuite/gas/all/sleb128-9.l
create mode 100644 gas/testsuite/gas/all/sleb128-9.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-10.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-10.l
create mode 100644 gas/testsuite/gas/elf/dwarf2-10.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-11.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-11.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-12.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-12.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-13.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-13.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-14.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-14.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-15.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-15.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-16.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-16.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-17.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-17.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-18.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-18.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-5.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-5.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-6.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-6.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-7.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-7.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-8.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-8.l
create mode 100644 gas/testsuite/gas/elf/dwarf2-8.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-9.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-9.l
create mode 100644 gas/testsuite/gas/elf/dwarf2-9.s

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 5cada37..4e96b32 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -423,6 +423,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;
@@ -441,6 +442,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;
@@ -499,6 +501,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;

@@ -3187,6 +3190,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);
@@ -3378,30 +3382,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)
{
@@ -3410,7 +3429,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:
@@ -3420,23 +3444,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;

@@ -3483,23 +3517,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;

@@ -3510,6 +3554,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:
@@ -3922,7 +3967,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;
}

@@ -3930,12 +3975,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)
{
@@ -3945,21 +3992,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)
{
@@ -3980,11 +4034,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,
@@ -3992,6 +4048,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:
{
@@ -4034,6 +4091,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:
@@ -4043,16 +4101,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;

@@ -4121,16 +4185,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;

@@ -4138,6 +4208,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:
@@ -4169,8 +4240,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;
@@ -4211,11 +4282,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);
@@ -4223,18 +4294,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 d70581b..fb9c798 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 08a7f35..af77f87 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 0d0fe6a..4a79260 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 6f3f8ef..1fa0d5d 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 5f02def..a45c6b8 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 3baa42a..ab456d5 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 a5379d0..5f977ee 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 3846f4f..7c5a591 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 574b719..75b8ce5 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/doc/as.texinfo b/gas/doc/as.texinfo
index e0637c7..a6ddc7c 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -5833,6 +5833,20 @@ 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 directive will verify that the @code{view} register in the
+@code{.debug_line} state machine matches @var{value}. In general, the
+@code{view} register counts how many prior @code{.loc} directives are at the
+same program location, but there are a few exceptions, such as that view
+numbers may be forced reset e.g. at function entry points, or they may not be
+reset even when the location changes. The assembler will determine the view
+number for that @code{.loc}. Then, if @var{value} is a label, it will set the
+label to the @var{value}. Otherwise, @var{value} may be either @code{0}, in
+which case the assembler will error out if the computed view number is not
+zero, or @code{-0}, that will cause the assembler to arrange for the
+@code{view} register to be reset for this @code{.loc} even if for @code{0} it
+would have issued an error.
+
@end table

@node Loc_mark_labels
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index e02b6e8..04d7ef9 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -168,6 +168,11 @@ struct line_entry {
struct dwarf2_line_info loc;
};

+/* 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;
@@ -215,9 +220,17 @@ bfd_boolean dwarf2_loc_mark_labels;
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 +296,162 @@ 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)
+ {
+ if (!p->loc.view)
+ {
+ p->loc.view = symbol_temp_make ();
+ gas_assert (!S_IS_DEFINED (p->loc.view));
+ }
+
+ expressionS incv;
+ 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))
+ {
+ /* 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. */
+ struct line_entry *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 +466,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 +525,14 @@ dwarf2_where (struct dwarf2_line_info *line)
{
if (debug_type == DEBUG_DWARF2)
{
+ memset (line, 0, sizeof (*line));
const char *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 +557,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 +900,50 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
return;
}
}
+ else if (strcmp (p, "view") == 0)
+ {
+ (void) restore_line_pointer (c);
+ symbolS *sym;
+ 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);
@@ -1362,7 +1585,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 to reset the view, but we know we're
+ advancing 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 +2210,38 @@ 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)
+ {
+ gas_assert (!symbol_resolved_p (view_assert_failed));
+
+ expressionS *expr = symbol_get_value_expression (view_assert_failed);
+ symbolS *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;
+
+ offsetT 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 9e2cead..49826fd 100644
--- a/gas/dwarf2dbg.h
+++ b/gas/dwarf2dbg.h
@@ -35,6 +35,7 @@ struct dwarf2_line_info {
unsigned int isa;
unsigned int flags;
unsigned int discriminator;
+ symbolS *view;
};

/* Implements the .file FILENO "FILENAME" directive. FILENO can be 0
@@ -99,6 +100,8 @@ 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 {
diff --git a/gas/read.c b/gas/read.c
index a26d4fe..37a03a6 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -778,6 +778,8 @@ do_align (unsigned int n, char *fill, unsigned int len, unsigned int max)
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
#ifdef md_do_align
md_do_align (n, fill, len, max, just_record_alignment);
#endif
@@ -2198,6 +2200,8 @@ s_fill (int ignore ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -2848,6 +2852,8 @@ s_org (int ignore ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
/* The m68k MRI assembler has a different meaning for .org. It
means to create an absolute section at a given address. We can't
support that--use a linker script instead. */
@@ -3318,6 +3324,8 @@ s_space (int mult)
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -3967,6 +3975,8 @@ cons_worker (int nbytes, /* 1=.byte, 2=.word, 4=.long. */
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
if (flag_mri)
stop = mri_comment_field (&stopc);

@@ -4959,6 +4969,8 @@ float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -5382,9 +5394,11 @@ s_leb128 (int sign)
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
do
{
- expression (&exp);
+ deferred_expression (&exp);
emit_leb128_expr (&exp, sign);
}
while (*input_line_pointer++ == ',');
@@ -5451,6 +5465,8 @@ stringer (int bits_appendzero)
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -5845,6 +5861,8 @@ s_incbin (int x ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif

+ dwarf2_emit_insn (0);
+
#ifdef md_cons_align
md_cons_align (1);
#endif
diff --git a/gas/subsegs.c b/gas/subsegs.c
index 73bc349..bb96142 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -80,7 +80,10 @@ subseg_set_rest (segT seg, subsegT subseg)
mri_common_symbol = NULL;

if (frag_now && frchain_now)
- frchain_now->frch_frag_now = frag_now;
+ {
+ frchain_now->frch_frag_now = frag_now;
+ dwarf2_emit_insn (0);
+ }

gas_assert (frchain_now == 0
|| frchain_now->frch_last == frag_now);
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp
index b5b0beb..e43947d4 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 0000000..7c88451
--- /dev/null
+++ b/gas/testsuite/gas/all/sleb128-9.d
@@ -0,0 +1,4 @@
+#name: undefined symbols un sleb128 directive
+#source: sleb128-9.s
+#error-output: sleb128-9.l
+#target: *-*-*
diff --git a/gas/testsuite/gas/all/sleb128-9.l b/gas/testsuite/gas/all/sleb128-9.l
new file mode 100644
index 0000000..19842fa
--- /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 0000000..87cb955
--- /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/elf/dwarf2-1.d b/gas/testsuite/gas/elf/dwarf2-1.d
index bae2f63..d8b79ef 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 0000000..4a4ef2c
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-10.d
@@ -0,0 +1,3 @@
+#as:
+#name: DWARF2 10
+#error-output: dwarf2-10.l
diff --git a/gas/testsuite/gas/elf/dwarf2-10.l b/gas/testsuite/gas/elf/dwarf2-10.l
new file mode 100644
index 0000000..b5f1f65
--- /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 0000000..c4052f1
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-10.c"
+ .text
+ .align 4
+ .globl _start
+_start:
+ .file 1 "dwarf2-10.c"
+ .loc 1 1 view 0
+ .align 4 /* No skip needed here... */
+ .loc 1 2 view 0 /* so this zero-view check fails. */
+ .int 0
+ .loc 1 3 view 0
+ .align 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 0000000..04d4473
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-11.d
@@ -0,0 +1,11 @@
+#as:
+#readelf: -wL
+#name: DWARF2 11
+
+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 0000000..7ec49ae
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-11.c"
+ .text
+ .align 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-11.c"
+ .int 0
+ .loc 1 1 view 0
+ .align 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 0000000..a58e374
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-12.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 12
+
+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 0000000..610eeff
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-12.c"
+ .text
+ .align 4
+ .globl _start
+_start:
+ .file 1 "dwarf2-12.c"
+ .loc 1 1 view 0
+ .loc 1 2 view -0
+ .loc 1 3 view .L1
+ .int 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 0000000..d8b6aba
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-13.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 13
+
+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 0000000..5635b96
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-13.c"
+ .text
+ .align 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-13.c"
+ .int 0
+ .loc 1 1 view 0
+ .align 8
+ .loc 1 2 view -0
+ .loc 1 3 view .L1
+ .int 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 0000000..dfb3c3b
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-14.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 14
+
+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 0000000..115d124
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-14.c"
+ .text
+ .align 4
+ .globl _start
+_start:
+ .file 1 "dwarf2-14.c"
+ .loc 1 1 view 0
+ .align 4
+ .loc 1 2 view -0
+ .loc 1 3 view .L1
+ .int 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 0000000..eaf50c4
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-15.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 15
+
+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 0000000..b1b5a58
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-15.c"
+ .text
+ .align 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-15.c"
+ .loc 1 1 view 0
+ .int 0
+ .loc 1 2 view -0
+ .loc 1 3 view .L1
+ .int 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 0000000..44301a7
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-16.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 16
+
+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 0000000..54283e8
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-16.c"
+ .text
+ .align 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-16.c"
+ .loc 1 1 view 0
+ .int 0
+ .loc 1 2 view 0
+ .align 4
+ .loc 1 3 view .L1
+ .int 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 0000000..5e7ccdc
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-17.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 17
+
+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 0000000..ef6c9fd
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-17.c"
+ .text
+ .align 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-17.c"
+ .loc 1 1 view 0
+ .int 0
+ .loc 1 2 view 0
+ .align 8
+ .loc 1 3 view .L1
+ .int 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 0000000..d695072
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-18.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 18
+
+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 0000000..643c006
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-18.c"
+ .text
+ .align 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-18.c"
+ .loc 1 1
+ .loc 1 2 view .L1
+ .int 0
+ .loc 1 3 view .L2
+ .int 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 b42a2ec..8cc1c3bb 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 0000000..a4598ba
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-5.d
@@ -0,0 +1,74 @@
+#as:
+#readelf: -x.rodata -wlL
+#name: DWARF2 5
+
+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 0000000..9483b82
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-5.c"
+ .text
+ .align 4
+ .globl _start
+_start:
+ .file 1 "dwarf2-5.c"
+ .loc 1 1 view 0
+ .loc 1 2 view .L2
+ .int 0
+ .loc 1 3 view 0
+ .align 4
+ .loc 1 4 view .L4
+ .loc 1 5 view .L5
+ .org .+1
+ .align 4
+ .loc 1 6 view 0
+ .int 0
+ .text
+ .globl func
+ .type func, %function
+func:
+ .loc 1 7 view 0
+ .loc 1 8 view .L8
+ .int 0
+ .loc 1 9 view 0
+ .loc 1 10 view .L10
+ .pushsection .text
+ .loc 1 11 view .L11
+ .popsection
+ .loc 1 12 view .L12
+ .int 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 0000000..39557e1
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-6.d
@@ -0,0 +1,76 @@
+#as:
+#readelf: -wlL
+#name: DWARF2 6
+
+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 0000000..678d8a1
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-6.c"
+ .text
+ .align 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 0000000..d78d91e
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-7.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 7
+
+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 *0x4
diff --git a/gas/testsuite/gas/elf/dwarf2-7.s b/gas/testsuite/gas/elf/dwarf2-7.s
new file mode 100644
index 0000000..9673cf0
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-7.c"
+ .text
+ .align 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
+ .int 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 0000000..a28d613
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-8.d
@@ -0,0 +1,3 @@
+#as:
+#name: DWARF2 8
+#error-output: dwarf2-8.l
diff --git a/gas/testsuite/gas/elf/dwarf2-8.l b/gas/testsuite/gas/elf/dwarf2-8.l
new file mode 100644
index 0000000..457f648
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-8.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:26: 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 0000000..dec0d33
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-8.c"
+ .text
+ .align 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 0000000..7e40858
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-9.d
@@ -0,0 +1,3 @@
+#as:
+#name: DWARF2 9
+#error-output: dwarf2-9.l
diff --git a/gas/testsuite/gas/elf/dwarf2-9.l b/gas/testsuite/gas/elf/dwarf2-9.l
new file mode 100644
index 0000000..43eb606
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-9.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:31: 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 0000000..c48b942
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-9.c"
+ .text
+ .align 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 6b2b31a0..c04c74b 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 ceebb3f..bfd4837 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 f4c110d5..0a2a092 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 c4e5c6f..fc0f861 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 d86f434..65e0ce1 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-duplicate.d b/gas/testsuite/gas/lns/lns-duplicate.d
index 9fe28ab..4bf44e0 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 ed280a8..df64ccd 100644
--- a/gas/testsuite/gas/mips/loc-swap-2.d
+++ b/gas/testsuite/gas/mips/loc-swap-2.d
@@ -38,12 +38,12 @@ 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 11: advance Address by 0 to 0x0 and Line by 6 to 7 \(view 1\)
+ \[0x.*\] Special opcode 7: advance Address by 0 to 0x0 and Line by 2 to 9 \(view 2\)
+ \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 10 \(view 3\)
\[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.d b/gas/testsuite/gas/mips/loc-swap.d
index 4e11106..94fe7cd 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/***@loc-swap-2.d b/gas/testsuite/gas/mips/***@loc-swap-2.d
index e148f25..9504be7 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 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/***@loc-swap.d b/gas/testsuite/gas/mips/***@loc-swap.d
index 23aedae..1427fee 100644
--- a/gas/testsuite/gas/mips/***@loc-swap.d
+++ b/gas/testsuite/gas/mips/***@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/***@loc-swap-2.d b/gas/testsuite/gas/mips/***@loc-swap-2.d
index 95b9e9c..a4cc000 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 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/***@loc-swap.d b/gas/testsuite/gas/mips/***@loc-swap.d
index 4d0c781..9b02346 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 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/***@loc-swap.d b/gas/testsuite/gas/mips/***@loc-swap.d
index 412e45b..7356e3f 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 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 1242cbf..b551afc 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1904,6 +1904,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
@@ -2449,6 +2451,13 @@ relax_segment (struct frag *segment_frag_root, segT segment, int pass)
#endif

case rs_leb128:
+ if (pass == 0 && !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));
+ }
+
/* Initial guess is always 1; doing otherwise can result in
stable solutions that are larger than the minimum. */
address += fragP->fr_offset = 1;
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Nick Clifton
2017-07-12 13:24:27 UTC
Permalink
Hi Alex,
Post by Alexandre Oliva
This patch introduces support for specifing views in .loc directives,
I just started testing this patch, but it fails to compile. The error
is:

gas/read.c: In function 'do_align':
gas/read.c:781:3: error: implicit declaration of function 'dwarf2_emit_insn'

It looks like you are not including dwarf2dbg.h in read.c. It also looks
like you are calling dwarf2_emit_insn() unconditionally, even for targets
which do not use/support the DWARF format...

Cheers
Nick
Alexandre Oliva
2017-07-13 08:01:22 UTC
Permalink
Post by Nick Clifton
Hi Alex,
Hey, Nick!
Post by Nick Clifton
Post by Alexandre Oliva
This patch introduces support for specifing views in .loc directives,
I just started testing this patch, but it fails to compile. The error
gas/read.c:781:3: error: implicit declaration of function 'dwarf2_emit_insn'
It looks like you are not including dwarf2dbg.h in read.c.
Yeah, config/obj-elf.h was taking care of that in my x86_64-linux-gnu
native builds. I suppose you tested with some other non-ELF-supporting
target, eh?
Post by Nick Clifton
It also looks like you are calling dwarf2_emit_insn() unconditionally,
even for targets which do not use/support the DWARF format...
*nod*

Thanks, I somehow didn't realize that would be a problem, and imagined
it would somehow sort itself out. Doh. Will fix.


Meanwhile, I've recently published a blog post that gives a little more
context about this project, that you guys might find interesting.
https://developers.redhat.com/blog/2017/07/11/statement-frontier-notes-and-location-views/#more-437095


Another issue I wanted to discuss is whether there's any interest in
retaining development history of this patches. I've been working on it
in a branch, users/aoliva/SFN, and I was thinking it might make sense
for the patch that eventually gets committed to the master branch to be
a merge from the branch, that adds the consolidated ChangeLog entries,
rather than a single stand-alone commit that drops the development
history.

My reasoning is that, although we have comments and ChangeLogs and
commit messages and email archives and whatnot, some of the development
history behind certain changes will certainly be in the development
commits only, and if we don't bring those into our commit history, they
will likely be lost forever.

I can see the benefit of them when bisecting patches for the kernel
linux, for example, since a GIT pull request will bring some (possibly
revised/consolidated/rewritten/polished/cleaned-up, but still...)
development history that might shed light on issues that arise later.

We currently throw that on the floor, but there's no reason for us to do
so. Since we use GIT for the revision history, it would be trivial to
install the consolidated patch as a merge that pulls in the development
history from the branch, along with the intended changes, if we choose
to do so.

Just to be clear, what I'm suggesting is that, when development history
for a patch is available, its commit be a pull/merge, so that the
development history becomes part of the project history even if the branch
was never published or was but gets removed later. It would in no way
affect the checked-out tree, so the patch would add the same bits,
including ChangeLogs and whatnot, and would carry the same commit
messages that a regular commit would.

Thoughts?
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Nick Clifton
2017-07-17 12:36:59 UTC
Permalink
Hi Alex,
Post by Alexandre Oliva
Another issue I wanted to discuss is whether there's any interest in
retaining development history of this patches. I've been working on it
in a branch, users/aoliva/SFN, and I was thinking it might make sense
for the patch that eventually gets committed to the master branch to be
a merge from the branch, that adds the consolidated ChangeLog entries,
rather than a single stand-alone commit that drops the development
history.
My reasoning is that, although we have comments and ChangeLogs and
commit messages and email archives and whatnot, some of the development
history behind certain changes will certainly be in the development
commits only, and if we don't bring those into our commit history, they
will likely be lost forever.
I can see the benefit of them when bisecting patches for the kernel
linux, for example, since a GIT pull request will bring some (possibly
revised/consolidated/rewritten/polished/cleaned-up, but still...)
development history that might shed light on issues that arise later.
We currently throw that on the floor, but there's no reason for us to do
so. Since we use GIT for the revision history, it would be trivial to
install the consolidated patch as a merge that pulls in the development
history from the branch, along with the intended changes, if we choose
to do so.
Just to be clear, what I'm suggesting is that, when development history
for a patch is available, its commit be a pull/merge, so that the
development history becomes part of the project history even if the branch
was never published or was but gets removed later. It would in no way
affect the checked-out tree, so the patch would add the same bits,
including ChangeLogs and whatnot, and would carry the same commit
messages that a regular commit would.
Thoughts?
I like it. I am all in favour of providing future users/coders with as
much (useful) information as is possible.

Cheers
Nick
Alexandre Oliva
2017-07-13 12:51:09 UTC
Permalink
Post by Nick Clifton
It looks like you are not including dwarf2dbg.h in read.c.
Fixed with the incremental patch below.
Post by Nick Clifton
It also looks like you are calling dwarf2_emit_insn() unconditionally,
even for targets which do not use/support the DWARF format...
dwarf2_emit_insn starts with a test that should make that ok (I
successfully tested sparc-aout and sh-pe):

if (debug_type != DEBUG_DWARF2
? !dwarf2_loc_directive_seen
: !seen_at_least_1_file ())
return;

If we're not emitting dwarf2 line info from assembly sources, then we
will test dwarf2_loc_directive_seen, and that won't be set if we're not
handling .loc directives for dwarf2 line table output, so we will
return. Since dwarf2dbg is linked in unconditionally, the only thing we
were missing was function declarations.


diff --git a/gas/read.c b/gas/read.c
index 37a03a6..629e1a0 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -37,6 +37,7 @@
#include "macro.h"
#include "obstack.h"
#include "ecoff.h"
+#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "wchar.h"

diff --git a/gas/subsegs.c b/gas/subsegs.c
index bb96142..76e3c6b 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -25,6 +25,8 @@
#include "subsegs.h"
#include "obstack.h"

+#include "dwarf2dbg.h"
+
frchainS *frchain_now;

static struct obstack frchains;
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Nick Clifton
2017-07-17 14:12:11 UTC
Permalink
Hi Alex,
Post by Alexandre Oliva
Fixed with the incremental patch below.
Thanks - with that applied I was able to build the patched sources. Unfortunately
this revealed the next problem - new gas testsuite failures:

Lots of targets (eg: arm-eabi, powerpc64-linux-gnu) are showing:

GAS REGRESSION: DWARF2 5
GAS REGRESSION: DWARF2 11
GAS REGRESSION: DWARF2 13
GAS REGRESSION: DWARF2 16
GAS REGRESSION: DWARF2 17

MIPS targets are also showing:

GAS REGRESSION: DWARF2 8
GAS REGRESSION: DWARF2 9
GAS REGRESSION: MIPS DWARF-2 location information with

The riscv64-elf target also has:

GAS REGRESSION: undefined symbols un sleb128 directive
GAS REGRESSION: DWARF2 6
GAS REGRESSION: DWARF2 7
GAS REGRESSION: DWARF2 10
GAS REGRESSION: DWARF2 12
GAS REGRESSION: DWARF2 13
GAS REGRESSION: DWARF2 15
GAS REGRESSION: DWARF2 18

And the SH target is showing:

GAS REGRESSION: DWARF2 7
GAS REGRESSION: DWARF2 8
GAS REGRESSION: DWARF2 9
GAS REGRESSION: DWARF2 10
GAS REGRESSION: DWARF2 12
GAS REGRESSION: DWARF2 14
GAS REGRESSION: DWARF2 15
GAS REGRESSION: DWARF2 18


I have not looked closely at all of the failures, but I think that they are just
a case of needing some regular expressions to be updated.

Would you mind having a look and fixing them please. Feel free to ping me if you
want to have a look at the full logs of the failures.

Cheers
Nick
Alexandre Oliva
2017-07-19 01:20:27 UTC
Permalink
Post by Nick Clifton
Hi Alex,
Post by Alexandre Oliva
Fixed with the incremental patch below.
Thanks - with that applied I was able to build the patched sources. Unfortunately
Thanks, many fixed, but with a caveat. See below.
I was using .align, but that's p2align rather than balign on these
ports.
Post by Nick Clifton
GAS REGRESSION: DWARF2 8
GAS REGRESSION: DWARF2 9
mips_align was missing a loc insn flush.
Post by Nick Clifton
GAS REGRESSION: MIPS DWARF-2 location information with
I had miscomputed view numbers in my head for some of these.
Post by Nick Clifton
GAS REGRESSION: undefined symbols un sleb128 directive
Fixed a typo. The problem remains, I'm still looking into what can be
done about it.
Besides the .p2/.balign issue, this required a loc insn flush in s_cons.


I was growing uncomfortable with the growing number of loc insn flushes
I had to add, and how many others I might have missed, but a new
regression in the MIPS tests (mips16-dwarf2) after I added a flush to
mips_align caught me by surprise: that test has .loc before align,
space, labels and whatnot, and expects the .loc to bind to the
subsequent asm insn, just as specified in the manual!

I figured I'd restore the original behavior of .loc, and arrange for it
to emit a row for the current address (which is what my plans and the
GCC implementation expects), rather than for the subsequent asm insn
(which is what GAS used to do), only when a "view" option is given. So
you'll get the new behavior only when you ask for views. I'm still
working on that, reverting all the new calls to dwarf2_emit_insn, so
I'll post that big change as a follow up. For now, here's the
incremental patch for the other fixes mentioned above.


for gas/ChangeLog

* config/tc-mips.c (mips_align): Emit pending loc insn first.
* config/tc-sh.c (sh_elf_cons): Likewise.
[...]
* testsuite/gas/mips/loc-swap-3.d: Likewise.

diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index cb5fb24..8baae26 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -831,6 +831,8 @@ sh_elf_cons (int nbytes)
return;
}

+ dwarf2_emit_insn (0);
+
#ifdef md_cons_align
md_cons_align (nbytes);
#endif
diff --git a/gas/testsuite/gas/all/sleb128-9.d b/gas/testsuite/gas/all/sleb128-9.d
index 7c88451..16f81ca 100644
--- a/gas/testsuite/gas/all/sleb128-9.d
+++ b/gas/testsuite/gas/all/sleb128-9.d
@@ -1,4 +1,4 @@
-#name: undefined symbols un sleb128 directive
+#name: undefined symbols in sleb128 directive
#source: sleb128-9.s
#error-output: sleb128-9.l
#target: *-*-*
diff --git a/gas/testsuite/gas/elf/dwarf2-10.s b/gas/testsuite/gas/elf/dwarf2-10.s
index c4052f1..d159d43 100644
--- a/gas/testsuite/gas/elf/dwarf2-10.s
+++ b/gas/testsuite/gas/elf/dwarf2-10.s
@@ -17,16 +17,16 @@

.file "dwarf2-10.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.file 1 "dwarf2-10.c"
.loc 1 1 view 0
- .align 4 /* No skip needed here... */
+ .balign 4 /* No skip needed here... */
.loc 1 2 view 0 /* so this zero-view check fails. */
.int 0
.loc 1 3 view 0
- .align 8 /* Skip 4 more bytes after .int... */
+ .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.s b/gas/testsuite/gas/elf/dwarf2-11.s
index 7ec49ae..187def5 100644
--- a/gas/testsuite/gas/elf/dwarf2-11.s
+++ b/gas/testsuite/gas/elf/dwarf2-11.s
@@ -17,12 +17,12 @@

.file "dwarf2-11.c"
.text
- .align 8
+ .balign 8
.globl _start
_start:
.file 1 "dwarf2-11.c"
.int 0
.loc 1 1 view 0
- .align 8
+ .balign 8
.loc 1 2 view 0
.size _start, .-_start
diff --git a/gas/testsuite/gas/elf/dwarf2-12.s b/gas/testsuite/gas/elf/dwarf2-12.s
index 610eeff..1a851d6 100644
--- a/gas/testsuite/gas/elf/dwarf2-12.s
+++ b/gas/testsuite/gas/elf/dwarf2-12.s
@@ -17,7 +17,7 @@

.file "dwarf2-12.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.file 1 "dwarf2-12.c"
diff --git a/gas/testsuite/gas/elf/dwarf2-13.s b/gas/testsuite/gas/elf/dwarf2-13.s
index 5635b96..c13f9d4 100644
--- a/gas/testsuite/gas/elf/dwarf2-13.s
+++ b/gas/testsuite/gas/elf/dwarf2-13.s
@@ -17,13 +17,13 @@

.file "dwarf2-13.c"
.text
- .align 8
+ .balign 8
.globl _start
_start:
.file 1 "dwarf2-13.c"
.int 0
.loc 1 1 view 0
- .align 8
+ .balign 8
.loc 1 2 view -0
.loc 1 3 view .L1
.int 0
diff --git a/gas/testsuite/gas/elf/dwarf2-14.s b/gas/testsuite/gas/elf/dwarf2-14.s
index 115d124..4dde965 100644
--- a/gas/testsuite/gas/elf/dwarf2-14.s
+++ b/gas/testsuite/gas/elf/dwarf2-14.s
@@ -17,12 +17,12 @@

.file "dwarf2-14.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.file 1 "dwarf2-14.c"
.loc 1 1 view 0
- .align 4
+ .balign 4
.loc 1 2 view -0
.loc 1 3 view .L1
.int 0
diff --git a/gas/testsuite/gas/elf/dwarf2-15.s b/gas/testsuite/gas/elf/dwarf2-15.s
index b1b5a58..1fbd594 100644
--- a/gas/testsuite/gas/elf/dwarf2-15.s
+++ b/gas/testsuite/gas/elf/dwarf2-15.s
@@ -17,7 +17,7 @@

.file "dwarf2-15.c"
.text
- .align 8
+ .balign 8
.globl _start
_start:
.file 1 "dwarf2-15.c"
diff --git a/gas/testsuite/gas/elf/dwarf2-16.s b/gas/testsuite/gas/elf/dwarf2-16.s
index 54283e8..7976614 100644
--- a/gas/testsuite/gas/elf/dwarf2-16.s
+++ b/gas/testsuite/gas/elf/dwarf2-16.s
@@ -17,14 +17,14 @@

.file "dwarf2-16.c"
.text
- .align 8
+ .balign 8
.globl _start
_start:
.file 1 "dwarf2-16.c"
.loc 1 1 view 0
.int 0
.loc 1 2 view 0
- .align 4
+ .balign 4
.loc 1 3 view .L1
.int 0
.size _start, .-_start
diff --git a/gas/testsuite/gas/elf/dwarf2-17.s b/gas/testsuite/gas/elf/dwarf2-17.s
index ef6c9fd..26c24cb 100644
--- a/gas/testsuite/gas/elf/dwarf2-17.s
+++ b/gas/testsuite/gas/elf/dwarf2-17.s
@@ -17,14 +17,14 @@

.file "dwarf2-17.c"
.text
- .align 8
+ .balign 8
.globl _start
_start:
.file 1 "dwarf2-17.c"
.loc 1 1 view 0
.int 0
.loc 1 2 view 0
- .align 8
+ .balign 8
.loc 1 3 view .L1
.int 0
.size _start, .-_start
diff --git a/gas/testsuite/gas/elf/dwarf2-18.s b/gas/testsuite/gas/elf/dwarf2-18.s
index 643c006..f32b3b3 100644
--- a/gas/testsuite/gas/elf/dwarf2-18.s
+++ b/gas/testsuite/gas/elf/dwarf2-18.s
@@ -17,7 +17,7 @@

.file "dwarf2-18.c"
.text
- .align 8
+ .balign 8
.globl _start
_start:
.file 1 "dwarf2-18.c"
diff --git a/gas/testsuite/gas/elf/dwarf2-5.s b/gas/testsuite/gas/elf/dwarf2-5.s
index 9483b82..91b9f95 100644
--- a/gas/testsuite/gas/elf/dwarf2-5.s
+++ b/gas/testsuite/gas/elf/dwarf2-5.s
@@ -17,7 +17,7 @@

.file "dwarf2-5.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.file 1 "dwarf2-5.c"
@@ -25,11 +25,11 @@ _start:
.loc 1 2 view .L2
.int 0
.loc 1 3 view 0
- .align 4
+ .balign 4
.loc 1 4 view .L4
.loc 1 5 view .L5
.org .+1
- .align 4
+ .balign 4
.loc 1 6 view 0
.int 0
.text
diff --git a/gas/testsuite/gas/elf/dwarf2-6.s b/gas/testsuite/gas/elf/dwarf2-6.s
index 678d8a1..28b1829 100644
--- a/gas/testsuite/gas/elf/dwarf2-6.s
+++ b/gas/testsuite/gas/elf/dwarf2-6.s
@@ -17,7 +17,7 @@

.file "dwarf2-6.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.L_start:
diff --git a/gas/testsuite/gas/elf/dwarf2-7.s b/gas/testsuite/gas/elf/dwarf2-7.s
index 9673cf0..d8fd007 100644
--- a/gas/testsuite/gas/elf/dwarf2-7.s
+++ b/gas/testsuite/gas/elf/dwarf2-7.s
@@ -17,7 +17,7 @@

.file "dwarf2-7.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.file 1 "dwarf2-7.c"
diff --git a/gas/testsuite/gas/elf/dwarf2-8.s b/gas/testsuite/gas/elf/dwarf2-8.s
index dec0d33..228063c 100644
--- a/gas/testsuite/gas/elf/dwarf2-8.s
+++ b/gas/testsuite/gas/elf/dwarf2-8.s
@@ -17,7 +17,7 @@

.file "dwarf2-8.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.file 1 "dwarf2-8.c"
diff --git a/gas/testsuite/gas/elf/dwarf2-9.s b/gas/testsuite/gas/elf/dwarf2-9.s
index c48b942..afc2019 100644
--- a/gas/testsuite/gas/elf/dwarf2-9.s
+++ b/gas/testsuite/gas/elf/dwarf2-9.s
@@ -17,7 +17,7 @@

.file "dwarf2-9.c"
.text
- .align 4
+ .balign 4
.globl _start
_start:
.file 1 "dwarf2-9.c"
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 4eeb5ee..176d635 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -15865,6 +15865,7 @@ mips_align (int to, int *fill, struct insn_label_list *labels)
{
mips_emit_delays ();
mips_record_compressed_mode ();
+ dwarf2_emit_insn (0);
if (fill == NULL && subseg_text_p (now_seg))
frag_align_code (to, 0);
else
diff --git a/gas/testsuite/gas/mips/loc-swap-2.d b/gas/testsuite/gas/mips/loc-swap-2.d
index df64ccd..6176614 100644
--- a/gas/testsuite/gas/mips/loc-swap-2.d
+++ b/gas/testsuite/gas/mips/loc-swap-2.d
@@ -38,9 +38,9 @@ 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 \(view 1\)
- \[0x.*\] Special opcode 7: advance Address by 0 to 0x0 and Line by 2 to 9 \(view 2\)
- \[0x.*\] Special opcode 6: advance Address by 0 to 0x0 and Line by 1 to 10 \(view 3\)
+ \[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 \(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 \(view 1\)
diff --git a/gas/testsuite/gas/mips/loc-swap-3.d b/gas/testsuite/gas/mips/loc-swap-3.d
index 2e46e04..0610a44 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
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Alexandre Oliva
2017-07-19 03:30:43 UTC
Permalink
Post by Alexandre Oliva
I figured I'd restore the original behavior of .loc, and arrange for it
to emit a row for the current address (which is what my plans and the
GCC implementation expects), rather than for the subsequent asm insn
(which is what GAS used to do), only when a "view" option is given. So
you'll get the new behavior only when you ask for views. I'm still
working on that, reverting all the new calls to dwarf2_emit_insn, so
I'll post that big change as a follow up.
Much reverting... dwarf2_directive_loc() is where the new change is.


diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 176d635..4eeb5ee 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -15865,7 +15865,6 @@ mips_align (int to, int *fill, struct insn_label_list *labels)
{
mips_emit_delays ();
mips_record_compressed_mode ();
- dwarf2_emit_insn (0);
if (fill == NULL && subseg_text_p (now_seg))
frag_align_code (to, 0);
else
diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index 8baae26..cb5fb24 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -831,8 +831,6 @@ sh_elf_cons (int nbytes)
return;
}

- dwarf2_emit_insn (0);
-
#ifdef md_cons_align
md_cons_align (nbytes);
#endif
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo
index a6ddc7c..65b14a4 100644
--- a/gas/doc/as.texinfo
+++ b/gas/doc/as.texinfo
@@ -5834,18 +5834,17 @@ This directive will set the @code{discriminator} register in the @code{.debug_li
state machine to @var{value}, which must be an unsigned integer.

@item view @var{value}
-This directive will verify that the @code{view} register in the
-@code{.debug_line} state machine matches @var{value}. In general, the
-@code{view} register counts how many prior @code{.loc} directives are at the
-same program location, but there are a few exceptions, such as that view
-numbers may be forced reset e.g. at function entry points, or they may not be
-reset even when the location changes. The assembler will determine the view
-number for that @code{.loc}. Then, if @var{value} is a label, it will set the
-label to the @var{value}. Otherwise, @var{value} may be either @code{0}, in
-which case the assembler will error out if the computed view number is not
-zero, or @code{-0}, that will cause the assembler to arrange for the
-@code{view} register to be reset for this @code{.loc} even if for @code{0} it
-would have issued an error.
+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

diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 04d7ef9..c3d6043 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -957,6 +957,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
diff --git a/gas/read.c b/gas/read.c
index 629e1a0..9627ef5 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -37,7 +37,6 @@
#include "macro.h"
#include "obstack.h"
#include "ecoff.h"
-#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "wchar.h"

@@ -779,8 +778,6 @@ do_align (unsigned int n, char *fill, unsigned int len, unsigned int max)
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
#ifdef md_do_align
md_do_align (n, fill, len, max, just_record_alignment);
#endif
@@ -2201,8 +2198,6 @@ s_fill (int ignore ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -2853,8 +2848,6 @@ s_org (int ignore ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
/* The m68k MRI assembler has a different meaning for .org. It
means to create an absolute section at a given address. We can't
support that--use a linker script instead. */
@@ -3325,8 +3318,6 @@ s_space (int mult)
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -3976,8 +3967,6 @@ cons_worker (int nbytes, /* 1=.byte, 2=.word, 4=.long. */
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
if (flag_mri)
stop = mri_comment_field (&stopc);

@@ -4970,8 +4959,6 @@ float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -5395,8 +5382,6 @@ s_leb128 (int sign)
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
do
{
deferred_expression (&exp);
@@ -5466,8 +5451,6 @@ stringer (int bits_appendzero)
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
#ifdef md_cons_align
md_cons_align (1);
#endif
@@ -5862,8 +5845,6 @@ s_incbin (int x ATTRIBUTE_UNUSED)
md_flush_pending_output ();
#endif

- dwarf2_emit_insn (0);
-
#ifdef md_cons_align
md_cons_align (1);
#endif
diff --git a/gas/subsegs.c b/gas/subsegs.c
index 76e3c6b..73bc349 100644
--- a/gas/subsegs.c
+++ b/gas/subsegs.c
@@ -25,8 +25,6 @@
#include "subsegs.h"
#include "obstack.h"

-#include "dwarf2dbg.h"
-
frchainS *frchain_now;

static struct obstack frchains;
@@ -82,10 +80,7 @@ subseg_set_rest (segT seg, subsegT subseg)
mri_common_symbol = NULL;

if (frag_now && frchain_now)
- {
- frchain_now->frch_frag_now = frag_now;
- dwarf2_emit_insn (0);
- }
+ frchain_now->frch_frag_now = frag_now;

gas_assert (frchain_now == 0
|| frchain_now->frch_last == frag_now);
diff --git a/gas/testsuite/gas/elf/dwarf2-8.l b/gas/testsuite/gas/elf/dwarf2-8.l
index 457f648..60c73e5 100644
--- a/gas/testsuite/gas/elf/dwarf2-8.l
+++ b/gas/testsuite/gas/elf/dwarf2-8.l
@@ -1,2 +1,2 @@
[^:]*: Assembler messages:
-[^:]*:26: Error: view number mismatch
+[^:]*:25: Error: view number mismatch
diff --git a/gas/testsuite/gas/elf/dwarf2-9.l b/gas/testsuite/gas/elf/dwarf2-9.l
index 43eb606..7f107fa 100644
--- a/gas/testsuite/gas/elf/dwarf2-9.l
+++ b/gas/testsuite/gas/elf/dwarf2-9.l
@@ -1,2 +1,2 @@
[^:]*: Assembler messages:
-[^:]*:31: Error: view number mismatch
+[^:]*:30: Error: view number mismatch
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Alexandre Oliva
2017-07-19 04:51:24 UTC
Permalink
Post by Nick Clifton
GAS REGRESSION: undefined symbols un sleb128 directive
This is caused by riscv's rejection of non-constant sleb128 operands, in
s_riscv_leb128. The comments above that function suggest relaxation
problems would arise, but configuring riscv to use the regular s_leb128
instead fixed this and a number of other test failures. Is the
rationaled behind this rejection of non-constant operands to leb128
still applicable?

FWIW, changes in the LVU patch (or in the patchset in branch
users/aoliva/SFN) require leb128 operands to be defined and resolved,
but parses the operands as deferred expressions, and only checks for
definedness/resolvedness at write-out time.

Parsing deferred expressions in s_leb128 operands is a very important
requirement for location views, since in some cases involving alignment
between .loc directives, view numbers can only be determined after
relaxation, and they may very well appear in view-augmented location
lists, given the SFN+LVU patches for GCC to emit them.
Post by Nick Clifton
GAS REGRESSION: DWARF2 6
GAS REGRESSION: DWARF2 7
GAS REGRESSION: DWARF2 10
GAS REGRESSION: DWARF2 12
GAS REGRESSION: DWARF2 13
GAS REGRESSION: DWARF2 15
GAS REGRESSION: DWARF2 18
Most of these have to do with the assembler's failure to resolve local
symbol differences to constants (by design, to make room for linker
relaxations), resolving them to ADD16/SUB16 relocation pairs, and
readelf's failure to support these relocation types. There are
preexisting tests that fail for the same reasons.

Once I changed readelf to silently ignore these relocations, a few of
these new tests pass, but most still fail just because without computing
and applying the relocations, the offsets in debug sections don't match
the expectations. A few cases I checked by hand would actually yield
the expected value.


FTR, here's the patch I used for testing, that might serve as a starting
point for readelf improvements, and for the removal of the special
requirement on leb128 operands in the assembler.


diff --git a/binutils/readelf.c b/binutils/readelf.c
index b2f75c0..efb4c62 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -11938,6 +11938,21 @@ target_specific_reloc_handling (Elf_Internal_Rela * reloc,
break;
}

+ case EM_RISCV:
+ {
+ if (reloc == NULL)
+ return TRUE;
+
+ switch (reloc_type)
+ {
+ case 34: /* R_RISCV_ADD16 */
+ case 38: /* R_RISCV_SUB16 */
+ /* FIXME: just silence the error for now. */
+ return TRUE;
+ }
+ break;
+ }
+
case EM_RL78:
{
static bfd_vma saved_sym1 = 0;
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 55c41c5..d3c2b38e 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -2543,24 +2543,6 @@ riscv_elf_final_processing (void)
elf_elfheader (stdoutput)->e_flags |= elf_flags;
}

-/* Parse the .sleb128 and .uleb128 pseudos. Only allow constant expressions,
- since these directives break relaxation when used with symbol deltas. */
-
-static void
-s_riscv_leb128 (int sign)
-{
- expressionS exp;
- char *save_in = input_line_pointer;
-
- expression (&exp);
- if (exp.X_op != O_constant)
- as_bad (_("non-constant .%cleb128 is not supported"), sign ? 's' : 'u');
- demand_empty_rest_of_line ();
-
- input_line_pointer = save_in;
- return s_leb128 (sign);
-}
-
/* Pseudo-op table. */

static const pseudo_typeS riscv_pseudo_table[] =
@@ -2573,8 +2555,6 @@ static const pseudo_typeS riscv_pseudo_table[] =
{"dtprelword", s_dtprel, 4},
{"dtpreldword", s_dtprel, 8},
{"bss", s_bss, 0},
- {"uleb128", s_riscv_leb128, 0},
- {"sleb128", s_riscv_leb128, 1},

{ NULL, NULL, 0 },
};
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Andrew Waterman
2017-07-19 05:12:39 UTC
Permalink
Post by Alexandre Oliva
Post by Nick Clifton
GAS REGRESSION: undefined symbols un sleb128 directive
This is caused by riscv's rejection of non-constant sleb128 operands, in
s_riscv_leb128. The comments above that function suggest relaxation
problems would arise, but configuring riscv to use the regular s_leb128
instead fixed this and a number of other test failures. Is the
rationaled behind this rejection of non-constant operands to leb128
still applicable?
In general, the RISC-V target does not support subtraction of code
labels at assembly time, as the delta may be adjusted by the linker.
In principle, this restriction could be lifted in the future by adding
additional relocations to inform the linker that it must adjust a
sleb128 or uleb128. However, the change you've proposed will at this
time break the RISC-V GCC port. GCC checks at configure time whether
uleb128 supports label subtraction, and avoids it if not. If it
erroneously believes label subtraction works, it will generate DWARF
that will not work on RISC-V.
Post by Alexandre Oliva
FWIW, changes in the LVU patch (or in the patchset in branch
users/aoliva/SFN) require leb128 operands to be defined and resolved,
but parses the operands as deferred expressions, and only checks for
definedness/resolvedness at write-out time.
Parsing deferred expressions in s_leb128 operands is a very important
requirement for location views, since in some cases involving alignment
between .loc directives, view numbers can only be determined after
relaxation, and they may very well appear in view-augmented location
lists, given the SFN+LVU patches for GCC to emit them.
Post by Nick Clifton
GAS REGRESSION: DWARF2 6
GAS REGRESSION: DWARF2 7
GAS REGRESSION: DWARF2 10
GAS REGRESSION: DWARF2 12
GAS REGRESSION: DWARF2 13
GAS REGRESSION: DWARF2 15
GAS REGRESSION: DWARF2 18
Most of these have to do with the assembler's failure to resolve local
symbol differences to constants (by design, to make room for linker
relaxations), resolving them to ADD16/SUB16 relocation pairs, and
readelf's failure to support these relocation types. There are
preexisting tests that fail for the same reasons.
Once I changed readelf to silently ignore these relocations, a few of
these new tests pass, but most still fail just because without computing
and applying the relocations, the offsets in debug sections don't match
the expectations. A few cases I checked by hand would actually yield
the expected value.
FTR, here's the patch I used for testing, that might serve as a starting
point for readelf improvements, and for the removal of the special
requirement on leb128 operands in the assembler.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b2f75c0..efb4c62 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -11938,6 +11938,21 @@ target_specific_reloc_handling (Elf_Internal_Rela * reloc,
break;
}
+ {
+ if (reloc == NULL)
+ return TRUE;
+
+ switch (reloc_type)
+ {
+ case 34: /* R_RISCV_ADD16 */
+ case 38: /* R_RISCV_SUB16 */
+ /* FIXME: just silence the error for now. */
+ return TRUE;
+ }
+ break;
+ }
+
{
static bfd_vma saved_sym1 = 0;
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c
index 55c41c5..d3c2b38e 100644
--- a/gas/config/tc-riscv.c
+++ b/gas/config/tc-riscv.c
@@ -2543,24 +2543,6 @@ riscv_elf_final_processing (void)
elf_elfheader (stdoutput)->e_flags |= elf_flags;
}
-/* Parse the .sleb128 and .uleb128 pseudos. Only allow constant expressions,
- since these directives break relaxation when used with symbol deltas. */
-
-static void
-s_riscv_leb128 (int sign)
-{
- expressionS exp;
- char *save_in = input_line_pointer;
-
- expression (&exp);
- if (exp.X_op != O_constant)
- as_bad (_("non-constant .%cleb128 is not supported"), sign ? 's' : 'u');
- demand_empty_rest_of_line ();
-
- input_line_pointer = save_in;
- return s_leb128 (sign);
-}
-
/* Pseudo-op table. */
static const pseudo_typeS riscv_pseudo_table[] =
@@ -2573,8 +2555,6 @@ static const pseudo_typeS riscv_pseudo_table[] =
{"dtprelword", s_dtprel, 4},
{"dtpreldword", s_dtprel, 8},
{"bss", s_bss, 0},
- {"uleb128", s_riscv_leb128, 0},
- {"sleb128", s_riscv_leb128, 1},
{ NULL, NULL, 0 },
};
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Alexandre Oliva
2017-07-20 08:02:08 UTC
Permalink
Post by Andrew Waterman
In general, the RISC-V target does not support subtraction of code
labels at assembly time, as the delta may be adjusted by the linker.
*nod*

LVU doesn't quite need subtraction of code labels, though. The
label-lookalikes that are used as .uleb128 operands in view expressions
are just constants, but they aren't necessarily computed yet at their
point of use. They didn't have to be rejected by the RISC-V assembler,
but they are.

Now, admittedly, the assembler-generated expressions used to compute
view numbers do compare code labels, to test whether there's an address
change between them. This is even simpler than other address compares
that take place in the generation of line number programs, and it didn't
look like the assembler refrained from resolving to constants the code
label differences that appear in address offsets in them, e.g. in cases
it was expected to use special opcodes, so I now, besides the
supportability of location views on RISC-V, I have two concerns: whether
we can/should even use such special opcodes in debug info line number
programs on RISC-V, considering that offsets might change due to linker
relaxations, and how usable the line number programs generated right now
are, if linker relaxations can change offsets in ways that might not be
reflected in the debug information.
Post by Andrew Waterman
However, the change you've proposed will at this
time break the RISC-V GCC port.
I think there's a misunderstanding, the patchlet I included in my
earlier message was nothing but a record of the changes I made to verify
that the new failures Nick saw on RISC-V were no different from
preexisting failures, because they might serve as a starting point for
future fixes.
Post by Andrew Waterman
GCC checks at configure time whether
uleb128 supports label subtraction, and avoids it if not. If it
erroneously believes label subtraction works, it will generate DWARF
that will not work on RISC-V.
I still think checking whether the [su]leb128 operand is a constant, at
the point of use, is too strong a requirement. We already require it to
resolve to a constant, and in the LVU patch I propose we check that it's
defined (we didn't), so I'd think this ought to be enough, as long as
you stop the assembler from resolving differences between label offsets
to constants uniformly. Now, maybe the [su]leb128 check I'm adding
there is still too weak, and it should check whether the operand is
actually resolved to a constant, besides testing whether it's defined
and taking its value, but these would all likely be machine-independent
desirable features; what makes RISC-V special is that it can't resolve
label offsets to constants, and making sure it doesn't, along with the
additional care in [su]leb128 output I propose, would suffice to get you
guys what you need without a machine-dependent [su]leb128 pseudo-op
handler.

I hope this helps,
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Andrew Waterman
2017-07-21 09:27:45 UTC
Permalink
Thanks Alex, we'll look into it.
Post by Alexandre Oliva
Post by Andrew Waterman
In general, the RISC-V target does not support subtraction of code
labels at assembly time, as the delta may be adjusted by the linker.
*nod*
LVU doesn't quite need subtraction of code labels, though. The
label-lookalikes that are used as .uleb128 operands in view expressions
are just constants, but they aren't necessarily computed yet at their
point of use. They didn't have to be rejected by the RISC-V assembler,
but they are.
Now, admittedly, the assembler-generated expressions used to compute
view numbers do compare code labels, to test whether there's an address
change between them. This is even simpler than other address compares
that take place in the generation of line number programs, and it didn't
look like the assembler refrained from resolving to constants the code
label differences that appear in address offsets in them, e.g. in cases
it was expected to use special opcodes, so I now, besides the
supportability of location views on RISC-V, I have two concerns: whether
we can/should even use such special opcodes in debug info line number
programs on RISC-V, considering that offsets might change due to linker
relaxations, and how usable the line number programs generated right now
are, if linker relaxations can change offsets in ways that might not be
reflected in the debug information.
Post by Andrew Waterman
However, the change you've proposed will at this
time break the RISC-V GCC port.
I think there's a misunderstanding, the patchlet I included in my
earlier message was nothing but a record of the changes I made to verify
that the new failures Nick saw on RISC-V were no different from
preexisting failures, because they might serve as a starting point for
future fixes.
Post by Andrew Waterman
GCC checks at configure time whether
uleb128 supports label subtraction, and avoids it if not. If it
erroneously believes label subtraction works, it will generate DWARF
that will not work on RISC-V.
I still think checking whether the [su]leb128 operand is a constant, at
the point of use, is too strong a requirement. We already require it to
resolve to a constant, and in the LVU patch I propose we check that it's
defined (we didn't), so I'd think this ought to be enough, as long as
you stop the assembler from resolving differences between label offsets
to constants uniformly. Now, maybe the [su]leb128 check I'm adding
there is still too weak, and it should check whether the operand is
actually resolved to a constant, besides testing whether it's defined
and taking its value, but these would all likely be machine-independent
desirable features; what makes RISC-V special is that it can't resolve
label offsets to constants, and making sure it doesn't, along with the
additional care in [su]leb128 output I propose, would suffice to get you
guys what you need without a machine-dependent [su]leb128 pseudo-op
handler.
I hope this helps,
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Alexandre Oliva
2017-07-19 04:58:05 UTC
Permalink
Post by Nick Clifton
Hi Alex,
Post by Alexandre Oliva
Fixed with the incremental patch below.
Would you mind having a look and fixing them please. Feel free to ping me if you
want to have a look at the full logs of the failures.
Here's a consolidated patch that combines the original patch with all of
the incremental changes posted so far (minus the riscv patchlets), and
one extra patch that moves the leb128 operand-is-defined check to a IMHO
more suitable place.



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. Three forms are supported:

.loc ... view -0 ; (e.g. at a function start) force view to zero
.loc ... view 0 ; (after a PC change) assert view is zero
.loc ... view .Lvu ; (at the Nth view at PC) set .Lvu to N-1

As in https://people.redhat.com/aoliva/papers/sfn/dwarf6-sfn-lvu.txt
view numbers are NOT encoded explicitly in line number programs;
they're rather inferred from the program. So, instead of having the
compiler supply the assembler with view numbers, we let the assembler
compute them according to the line number program implicit rules, and
allow the compiler to refer to the computed numbers by storing the
numbers in label-like view numbers. Since the compiler can in many
cases know about PC changes, we allow the compiler to assert that the
view is reset at such points, so that it can safely assume the view
number is zero at them: the assembler will error out if the assumption
is incorrect.

View labels are meant to be used in location lists, as proposed for
DWARF6, or in view lists and augment location lists, a
backward-compatible extension. We do NOT have code to dump either
list yet. In either case, the view numbers are encoded as uleb128
sequences, which required the possibility of deferring the resolution
of uleb128 operands (we'd previously emit undefined or
not-yet-computed symbols as if they were zero). Nothing prevents
other uses of the view counters stored in view label symbols.

I've added code to dump (nonzero) view numbers in raw line number
programs and in decoded line number tables, and adjusted all tests
that, under the implicit view computation rules, had nonzero views in
them, so that their expected dumps would match the modified outputs.

I've added plenty of tests for view numbering, testing cases involving
alignment pseudo_ops that either change or don't change PC. I found
several cases in which I had to emit pending line number directives
before the pseudo_op takes effect, otherwise the view number would end
up being computed at the wrong PC, or even at the wrong section.

GCC has been modified to use the assembler to emit view-aware line
number programs, when it supports .loc views, and that compiler has
successfully bootstrapped using an assembler with this patch.


for binutils/ChangeLog

* 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.

for gas/ChangeLog

* 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/***@loc-swap-2.d: Likewise.
* testsuite/gas/mips/***@loc-swap.d: Likewise.
* testsuite/gas/mips/***@loc-swap-2.d: Likewise.
* testsuite/gas/mips/***@loc-swap.d: Likewise.
* testsuite/gas/mips/***@loc-swap.d: Likewise.
* write.c (write_object_file): Check pending view asserts.
(cvt_frag_to_fill): Complain about undefined leb128 operand.
---
binutils/dwarf.c | 162 +++++++++---
binutils/testsuite/binutils-all/dw2-1.W | 2
binutils/testsuite/binutils-all/dw2-3.W | 2
binutils/testsuite/binutils-all/dw2-3gabi.W | 2
binutils/testsuite/binutils-all/dw5.W | 4
.../testsuite/binutils-all/i386/compressed-1a.d | 2
.../binutils-all/libdw2-compressedgabi.out | 6
binutils/testsuite/binutils-all/objdump.W | 2
binutils/testsuite/binutils-all/objdump.WL | 3
.../testsuite/binutils-all/x86-64/compressed-1a.d | 4
gas/doc/as.texinfo | 13 +
gas/dwarf2dbg.c | 280 ++++++++++++++++++++
gas/dwarf2dbg.h | 3
gas/read.c | 2
gas/testsuite/gas/all/gas.exp | 1
gas/testsuite/gas/all/sleb128-9.d | 4
gas/testsuite/gas/all/sleb128-9.l | 3
gas/testsuite/gas/all/sleb128-9.s | 3
gas/testsuite/gas/elf/dwarf2-1.d | 2
gas/testsuite/gas/elf/dwarf2-10.d | 3
gas/testsuite/gas/elf/dwarf2-10.l | 2
gas/testsuite/gas/elf/dwarf2-10.s | 32 ++
gas/testsuite/gas/elf/dwarf2-11.d | 11 +
gas/testsuite/gas/elf/dwarf2-11.s | 28 ++
gas/testsuite/gas/elf/dwarf2-12.d | 15 +
gas/testsuite/gas/elf/dwarf2-12.s | 31 ++
gas/testsuite/gas/elf/dwarf2-13.d | 15 +
gas/testsuite/gas/elf/dwarf2-13.s | 33 ++
gas/testsuite/gas/elf/dwarf2-14.d | 15 +
gas/testsuite/gas/elf/dwarf2-14.s | 32 ++
gas/testsuite/gas/elf/dwarf2-15.d | 15 +
gas/testsuite/gas/elf/dwarf2-15.s | 32 ++
gas/testsuite/gas/elf/dwarf2-16.d | 15 +
gas/testsuite/gas/elf/dwarf2-16.s | 33 ++
gas/testsuite/gas/elf/dwarf2-17.d | 15 +
gas/testsuite/gas/elf/dwarf2-17.s | 33 ++
gas/testsuite/gas/elf/dwarf2-18.d | 15 +
gas/testsuite/gas/elf/dwarf2-18.s | 33 ++
gas/testsuite/gas/elf/dwarf2-2.d | 2
gas/testsuite/gas/elf/dwarf2-5.d | 74 +++++
gas/testsuite/gas/elf/dwarf2-5.s | 58 ++++
gas/testsuite/gas/elf/dwarf2-6.d | 76 +++++
gas/testsuite/gas/elf/dwarf2-6.s | 101 +++++++
gas/testsuite/gas/elf/dwarf2-7.d | 15 +
gas/testsuite/gas/elf/dwarf2-7.s | 36 +++
gas/testsuite/gas/elf/dwarf2-8.d | 3
gas/testsuite/gas/elf/dwarf2-8.l | 2
gas/testsuite/gas/elf/dwarf2-8.s | 27 ++
gas/testsuite/gas/elf/dwarf2-9.d | 3
gas/testsuite/gas/elf/dwarf2-9.l | 2
gas/testsuite/gas/elf/dwarf2-9.s | 32 ++
gas/testsuite/gas/elf/elf.exp | 14 +
gas/testsuite/gas/i386/dw2-compress-1.d | 2
gas/testsuite/gas/i386/dw2-compressed-1.d | 2
gas/testsuite/gas/i386/ilp32/lns/lns-duplicate.d | 2
gas/testsuite/gas/lns/lns-big-delta.d | 2
gas/testsuite/gas/lns/lns-duplicate.d | 2
gas/testsuite/gas/mips/loc-swap-2.d | 6
gas/testsuite/gas/mips/loc-swap-3.d | 2
gas/testsuite/gas/mips/loc-swap.d | 6
gas/testsuite/gas/mips/***@loc-swap-2.d | 6
gas/testsuite/gas/mips/***@loc-swap.d | 4
gas/testsuite/gas/mips/***@loc-swap-2.d | 6
gas/testsuite/gas/mips/***@loc-swap.d | 6
gas/testsuite/gas/mips/***@loc-swap.d | 6
gas/write.c | 9 +
66 files changed, 1329 insertions(+), 85 deletions(-)
create mode 100644 gas/testsuite/gas/all/sleb128-9.d
create mode 100644 gas/testsuite/gas/all/sleb128-9.l
create mode 100644 gas/testsuite/gas/all/sleb128-9.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-10.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-10.l
create mode 100644 gas/testsuite/gas/elf/dwarf2-10.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-11.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-11.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-12.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-12.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-13.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-13.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-14.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-14.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-15.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-15.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-16.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-16.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-17.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-17.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-18.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-18.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-5.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-5.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-6.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-6.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-7.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-7.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-8.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-8.l
create mode 100644 gas/testsuite/gas/elf/dwarf2-8.s
create mode 100644 gas/testsuite/gas/elf/dwarf2-9.d
create mode 100644 gas/testsuite/gas/elf/dwarf2-9.l
create mode 100644 gas/testsuite/gas/elf/dwarf2-9.s

diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 5cada37..4e96b32 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -423,6 +423,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;
@@ -441,6 +442,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;
@@ -499,6 +501,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;

@@ -3187,6 +3190,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);
@@ -3378,30 +3382,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)
{
@@ -3410,7 +3429,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:
@@ -3420,23 +3444,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;

@@ -3483,23 +3517,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;

@@ -3510,6 +3554,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:
@@ -3922,7 +3967,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;
}

@@ -3930,12 +3975,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)
{
@@ -3945,21 +3992,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)
{
@@ -3980,11 +4034,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,
@@ -3992,6 +4048,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:
{
@@ -4034,6 +4091,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:
@@ -4043,16 +4101,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;

@@ -4121,16 +4185,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;

@@ -4138,6 +4208,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:
@@ -4169,8 +4240,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;
@@ -4211,11 +4282,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);
@@ -4223,18 +4294,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 d70581b..fb9c798 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 08a7f35..af77f87 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 0d0fe6a..4a79260 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 6f3f8ef..1fa0d5d 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 5f02def..a45c6b8 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 3baa42a..ab456d5 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 a5379d0..5f977ee 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 3846f4f..7c5a591 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 574b719..75b8ce5 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/doc/as.texinfo b/gas/doc/as.texinfo
index e0637c7..65b14a4 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 e02b6e8..c3d6043 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -168,6 +168,11 @@ struct line_entry {
struct dwarf2_line_info loc;
};

+/* 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;
@@ -215,9 +220,17 @@ bfd_boolean dwarf2_loc_mark_labels;
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 +296,162 @@ 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)
+ {
+ if (!p->loc.view)
+ {
+ p->loc.view = symbol_temp_make ();
+ gas_assert (!S_IS_DEFINED (p->loc.view));
+ }
+
+ expressionS incv;
+ 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))
+ {
+ /* 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. */
+ struct line_entry *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 +466,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 +525,14 @@ dwarf2_where (struct dwarf2_line_info *line)
{
if (debug_type == DEBUG_DWARF2)
{
+ memset (line, 0, sizeof (*line));
const char *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 +557,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 +900,50 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
return;
}
}
+ else if (strcmp (p, "view") == 0)
+ {
+ (void) restore_line_pointer (c);
+ symbolS *sym;
+ 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 +957,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 +1589,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 to reset the view, but we know we're
+ advancing 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 +2214,38 @@ 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)
+ {
+ gas_assert (!symbol_resolved_p (view_assert_failed));
+
+ expressionS *expr = symbol_get_value_expression (view_assert_failed);
+ symbolS *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;
+
+ offsetT 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 9e2cead..49826fd 100644
--- a/gas/dwarf2dbg.h
+++ b/gas/dwarf2dbg.h
@@ -35,6 +35,7 @@ struct dwarf2_line_info {
unsigned int isa;
unsigned int flags;
unsigned int discriminator;
+ symbolS *view;
};

/* Implements the .file FILENO "FILENAME" directive. FILENO can be 0
@@ -99,6 +100,8 @@ 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 {
diff --git a/gas/read.c b/gas/read.c
index a26d4fe..9627ef5 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 b5b0beb..e43947d4 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 0000000..16f81ca
--- /dev/null
+++ b/gas/testsuite/gas/all/sleb128-9.d
@@ -0,0 +1,4 @@
+#name: undefined symbols in sleb128 directive
+#source: sleb128-9.s
+#error-output: sleb128-9.l
+#target: *-*-*
diff --git a/gas/testsuite/gas/all/sleb128-9.l b/gas/testsuite/gas/all/sleb128-9.l
new file mode 100644
index 0000000..19842fa
--- /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 0000000..87cb955
--- /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/elf/dwarf2-1.d b/gas/testsuite/gas/elf/dwarf2-1.d
index bae2f63..d8b79ef 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 0000000..4a4ef2c
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-10.d
@@ -0,0 +1,3 @@
+#as:
+#name: DWARF2 10
+#error-output: dwarf2-10.l
diff --git a/gas/testsuite/gas/elf/dwarf2-10.l b/gas/testsuite/gas/elf/dwarf2-10.l
new file mode 100644
index 0000000..b5f1f65
--- /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 0000000..d159d43
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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 0000000..04d4473
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-11.d
@@ -0,0 +1,11 @@
+#as:
+#readelf: -wL
+#name: DWARF2 11
+
+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 0000000..187def5
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-11.c"
+ .text
+ .balign 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-11.c"
+ .int 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 0000000..a58e374
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-12.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 12
+
+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 0000000..1a851d6
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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
+ .int 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 0000000..d8b6aba
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-13.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 13
+
+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 0000000..c13f9d4
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-13.c"
+ .text
+ .balign 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-13.c"
+ .int 0
+ .loc 1 1 view 0
+ .balign 8
+ .loc 1 2 view -0
+ .loc 1 3 view .L1
+ .int 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 0000000..dfb3c3b
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-14.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 14
+
+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 0000000..4dde965
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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
+ .int 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 0000000..eaf50c4
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-15.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 15
+
+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 0000000..1fbd594
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-15.c"
+ .text
+ .balign 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-15.c"
+ .loc 1 1 view 0
+ .int 0
+ .loc 1 2 view -0
+ .loc 1 3 view .L1
+ .int 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 0000000..44301a7
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-16.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 16
+
+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 0000000..7976614
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-16.c"
+ .text
+ .balign 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-16.c"
+ .loc 1 1 view 0
+ .int 0
+ .loc 1 2 view 0
+ .balign 4
+ .loc 1 3 view .L1
+ .int 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 0000000..5e7ccdc
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-17.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 17
+
+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 0000000..26c24cb
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-17.c"
+ .text
+ .balign 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-17.c"
+ .loc 1 1 view 0
+ .int 0
+ .loc 1 2 view 0
+ .balign 8
+ .loc 1 3 view .L1
+ .int 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 0000000..d695072
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-18.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 18
+
+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 0000000..f32b3b3
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .file "dwarf2-18.c"
+ .text
+ .balign 8
+ .globl _start
+_start:
+ .file 1 "dwarf2-18.c"
+ .loc 1 1
+ .loc 1 2 view .L1
+ .int 0
+ .loc 1 3 view .L2
+ .int 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 b42a2ec..8cc1c3bb 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 0000000..a4598ba
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-5.d
@@ -0,0 +1,74 @@
+#as:
+#readelf: -x.rodata -wlL
+#name: DWARF2 5
+
+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 0000000..91b9f95
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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
+ .int 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
+ .int 0
+ .text
+ .globl func
+ .type func, %function
+func:
+ .loc 1 7 view 0
+ .loc 1 8 view .L8
+ .int 0
+ .loc 1 9 view 0
+ .loc 1 10 view .L10
+ .pushsection .text
+ .loc 1 11 view .L11
+ .popsection
+ .loc 1 12 view .L12
+ .int 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 0000000..39557e1
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-6.d
@@ -0,0 +1,76 @@
+#as:
+#readelf: -wlL
+#name: DWARF2 6
+
+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 0000000..28b1829
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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 0000000..d78d91e
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-7.d
@@ -0,0 +1,15 @@
+#as:
+#readelf: -x.rodata -wL
+#name: DWARF2 7
+
+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 *0x4
diff --git a/gas/testsuite/gas/elf/dwarf2-7.s b/gas/testsuite/gas/elf/dwarf2-7.s
new file mode 100644
index 0000000..d8fd007
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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
+ .int 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 0000000..a28d613
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-8.d
@@ -0,0 +1,3 @@
+#as:
+#name: DWARF2 8
+#error-output: dwarf2-8.l
diff --git a/gas/testsuite/gas/elf/dwarf2-8.l b/gas/testsuite/gas/elf/dwarf2-8.l
new file mode 100644
index 0000000..60c73e5
--- /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 0000000..228063c
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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 0000000..7e40858
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-9.d
@@ -0,0 +1,3 @@
+#as:
+#name: DWARF2 9
+#error-output: dwarf2-9.l
diff --git a/gas/testsuite/gas/elf/dwarf2-9.l b/gas/testsuite/gas/elf/dwarf2-9.l
new file mode 100644
index 0000000..7f107fa
--- /dev/null
+++ b/gas/testsuite/gas/elf/dwarf2-9.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:30: 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 0000000..afc2019
--- /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 <http://www.gnu.org/licenses/>. */
+
+ .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 6b2b31a0..c04c74b 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 ceebb3f..bfd4837 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 f4c110d5..0a2a092 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 c4e5c6f..fc0f861 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 d86f434..65e0ce1 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-duplicate.d b/gas/testsuite/gas/lns/lns-duplicate.d
index 9fe28ab..4bf44e0 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 ed280a8..6176614 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 2e46e04..0610a44 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 4e11106..94fe7cd 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/***@loc-swap-2.d b/gas/testsuite/gas/mips/***@loc-swap-2.d
index e148f25..9504be7 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 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/***@loc-swap.d b/gas/testsuite/gas/mips/***@loc-swap.d
index 23aedae..1427fee 100644
--- a/gas/testsuite/gas/mips/***@loc-swap.d
+++ b/gas/testsuite/gas/mips/***@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/***@loc-swap-2.d b/gas/testsuite/gas/mips/***@loc-swap-2.d
index 95b9e9c..a4cc000 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 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/***@loc-swap.d b/gas/testsuite/gas/mips/***@loc-swap.d
index 4d0c781..9b02346 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 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/***@loc-swap.d b/gas/testsuite/gas/mips/***@loc-swap.d
index 412e45b..7356e3f 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 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 1242cbf..8efdbc5 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
--
Alexandre Oliva, freedom fighter http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/ FSF Latin America board member
Free Software Evangelist|Red Hat Brasil GNU Toolchain Engineer
Nick Clifton
2017-07-21 09:21:50 UTC
Permalink
Hi Alex,
Post by Alexandre Oliva
Here's a consolidated patch that combines the original patch with all of
the incremental changes posted so far (minus the riscv patchlets), and
one extra patch that moves the leb128 operand-is-defined check to a IMHO
more suitable place.
Thanks - I have applied your patch.

I made a couple of small changes:

* There were a few places in some the new gas tests where you were using
the .int pseudo-op and expecting it to insert 4-bytes. This is not true
of all targets, as some have 2-byte or even 8-byte integers. I replaced
the .int occurences with .dc.l instead which achieves the desired purpose.

* I add a line to the gas/NEWS file mentioning this new feature.

* I added target specific skip directives to the new tests, along with
comments explaining why each target was skipped.


Cheers
Nick
Continue reading on narkive:
Loading...