}
break;
default:
- complaint (_("mangled .debug_line section"));
- return;
+ complaint (_("unrecognized line number program opcode %d"), op_code);
+ /* Unknown extended opcode, ignore it. */
+ line_ptr = extended_end;
+ break;
+ case 0:
+ /* This is also an unknown opcode, but this one is used by
+ the Zig compiler (perhaps others too?) specifically as a
+ "padding" instruction. Also, although it is technically
+ available, future DWARF revisions are very unlikely to use
+ opcode 0. Therefore, it's better to elide the warning in
+ this case, and ignore the instruction silently. */
+ line_ptr = extended_end;
+ break;
}
/* Make sure that we parsed the extended op correctly. If e.g.
we expected a different address size than the producer used,
--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2026 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/>. */
+
+void
+foo (void)
+{
+
+}
+
+int
+main()
+{
+ asm ("main_label: .globl main_label");
+ foo ();
+
+ asm ("main_label_2: .globl main_label_2");
+ return 0;
+}
--- /dev/null
+# Copyright 2026 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/>.
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+require dwarf2_support
+
+# The .c files use __attribute__.
+require is_c_compiler_gcc
+
+standard_testfile .c -dw.S
+
+set asm_file [standard_output_file $srcfile2]
+set f [open $asm_file "w"]
+Dwarf::assemble { file_id $f } {
+ declare_labels Llines
+ global srcdir subdir srcfile
+
+ get_func_info main
+
+ cu {} {
+ compile_unit {
+ DW_AT_language @DW_LANG_C
+ DW_AT_name dw2-line-unknown-extended-opcode.exp
+ DW_AT_stmt_list $Llines DW_FORM_sec_offset
+ } {
+ subprogram {
+ DW_AT_external 1 flag
+ MACRO_AT_func {main}
+ }
+ }
+ }
+
+ lines {version 2 default_is_stmt 1} Llines {
+ include_dir "${srcdir}/${subdir}"
+ file_name "$srcfile" 1
+
+ program {
+ global f
+
+ DW_LNE_set_address $main_start
+ line 26
+ DW_LNS_copy
+
+ # Emit non-standard (but not in the vendor-specific range) extended
+ # opcode 0 with 15 dummy operand bytes which GDB should ignore.
+ puts $f " .byte 0"
+ puts $f " .uleb128 16"
+ puts $f " .byte 0"
+ puts $f " .fill 15, 1, 42"
+
+ DW_LNE_set_address main_label
+ line 28
+ DW_LNS_copy
+
+ DW_LNE_set_address main_label_2
+ line 31
+ DW_LNS_copy
+
+ DW_LNE_set_address $main_end
+ DW_LNE_end_sequence
+ }
+ }
+}
+close $f
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return
+}
+
+if {![runto_main]} {
+ return
+}
+
+gdb_breakpoint "$srcfile:31"
+gdb_continue_to_breakpoint "return from main" "\[^\r\n\]*:31\r\n.*"