summaryrefslogtreecommitdiff
path: root/gas/dwarf2dbg.c
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2020-08-03 02:04:17 +0200
committerMark Wielaard <mark@klomp.org>2020-08-04 11:28:39 +0200
commita3b3e8586d80204660e203d05edfe88418c394a2 (patch)
tree2315042dfb3ee4f7a37a24aee4821712c31466cc /gas/dwarf2dbg.c
parent25b1f10d9b55de5dee002500a51e8fc1cd543d30 (diff)
downloadbinutils-gdb-a3b3e8586d80204660e203d05edfe88418c394a2.tar.gz
gas: Fix .debug_info CU header for --gdwarf-5
DWARF5 CU headers have a new unit type field and move the abbrev offset to the end of the header. gas/ChangeLog: * 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.
Diffstat (limited to 'gas/dwarf2dbg.c')
-rw-r--r--gas/dwarf2dbg.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 69955fea5bf..b19e057c762 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -2464,12 +2464,26 @@ out_debug_info (segT info_seg, segT abbrev_seg, segT line_seg, segT ranges_seg,
/* 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);