+2020-08-02 Mark Wielaard <mark@klomp.org>
+
+ * dwarf2dbg.c (out_debug_info): Emit unit type and abbrev offset
+ for DWARF5.
+ * gas/testsuite/gas/elf/dwarf-4-cu.d: New file.
+ * gas/testsuite/gas/elf/dwarf-4-cu.s: Likewise.
+ * gas/testsuite/gas/elf/dwarf-5-cu.d: Likewise.
+ * gas/testsuite/gas/elf/dwarf-5-cu.s: Likewise.
+ * testsuite/gas/elf/elf.exp: Run dwarf-4-cu and dwarf-5-cu.
+
2020-08-02 Mark Wielaard <mark@klomp.org>
* doc/as.texi (--gdwarf-[345]): Fix typo.
/* DWARF version. */
out_two (DWARF2_VERSION);
- /* .debug_abbrev offset */
- TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg), sizeof_offset);
+ if (DWARF2_VERSION < 5)
+ {
+ /* .debug_abbrev offset */
+ TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg), sizeof_offset);
+ }
+ else
+ {
+ /* unit (header) type */
+ out_byte (DW_UT_compile);
+ }
/* Target address size. */
out_byte (sizeof_address);
+ if (DWARF2_VERSION >= 5)
+ {
+ /* .debug_abbrev offset */
+ TC_DWARF2_EMIT_OFFSET (section_symbol (abbrev_seg), sizeof_offset);
+ }
+
/* DW_TAG_compile_unit DIE abbrev */
out_uleb128 (1);
--- /dev/null
+#as: --gdwarf-4
+#name: DWARF4 CU
+#readelf: -wi
+
+#...
+ Compilation Unit @ offset 0x0:
+ Length: 0x.*
+ Version: 4
+ Abbrev Offset: 0x0
+ Pointer Size: .
+#pass
--- /dev/null
+ .text
+ .file 1 "foo/bar.s"
+ .loc_mark_labels 1
+ .globl foobar
+ .type foobar, %function
+foobar:
+ .quad 0x1
+ .size foobar, .-foobar
+
+ .globl baz
+ .type baz, %function
+baz:
+ .quad 0x1
+ .size baz, .-baz
--- /dev/null
+#as: --gdwarf-5
+#name: DWARF5 CU
+#readelf: -wi
+
+#...
+ Compilation Unit @ offset 0x0:
+ Length: 0x.*
+ Version: 5
+ Abbrev Offset: 0x0
+ Pointer Size: .
+#pass
--- /dev/null
+ .text
+ .file 1 "foo/bar.s"
+ .loc_mark_labels 1
+ .globl foobar
+ .type foobar, %function
+foobar:
+ .quad 0x1
+ .size foobar, .-foobar
+
+ .globl baz
+ .type baz, %function
+baz:
+ .quad 0x1
+ .size baz, .-baz
run_dump_test "dwarf2-18" $dump_opts
run_dump_test "dwarf2-19" $dump_opts
run_dump_test "dwarf-5-file0" $dump_opts
+ run_dump_test "dwarf-4-cu" $dump_opts
+ run_dump_test "dwarf-5-cu" $dump_opts
run_dump_test "pr25917"
run_dump_test "bss"
run_dump_test "bad-bss"