]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gas: Don't error when .debug_line already exists, unless .loc was used
authorMark Wielaard <mark@klomp.org>
Mon, 7 Sep 2020 12:25:25 +0000 (14:25 +0200)
committerMark Wielaard <mark@klomp.org>
Fri, 11 Sep 2020 17:18:44 +0000 (19:18 +0200)
commitedc7a80a9c04667dfa74f90f74bd39827bc372b7
tree7b3047fb76bf8068810aaed3ee31e2f30bb5d0a4
parent548f5275787a2328b5c1ea041e13a53e67d4accb
gas: Don't error when .debug_line already exists, unless .loc was used

When -g was used to generate DWARF gas would error out when a .debug_line
already exists. But when a .debug_info section already exists it would
simply skip generating one without warning or error. Do the same for
.debug_line. It is only an error when the user explicitly uses .loc
directives and also generates the .debug_line table itself.

The tests are unfortunately arch specific because the line table is only
generated when actual instructions have been emitted. Use i386 because
that is probably the most used architecture. Before this patch the new
dwarf-line-2 testcase would fail, with this patch it succeeds (and doesn't
try to add its own line table).

gas/ChangeLog:

    * as.texi (-g): Explicitly mention when .debug_info and .debug_line
    are generated for the DWARF format.
    (Loc): Add that it is an error to both use a .loc directive and
    generate a .debug_line yourself.
    * dwarf2dbg.c (dwarf2_any_loc_directive_seen): New static variable.
    (dwarf2_directive_loc): Set dwarf2_any_loc_directive_seen to TRUE.
    (dwarf2_finish): Check dwarf2_any_loc_directive_seen before emitting
    an error. Only create .debug_line if it is empty (or doesn't exist).
    * testsuite/gas/i386/i386.exp: Add dwarf2-line-{1,2,3,4} when testing
    an elf target.
    * testsuite/gas/i386/dwarf2-line-{1,2,3,4}.{s,d,l}: New test files.
13 files changed:
gas/ChangeLog
gas/doc/as.texi
gas/dwarf2dbg.c
gas/testsuite/gas/i386/dwarf2-line-1.d [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-1.s [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-2.d [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-2.s [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-3.d [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-3.l [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-3.s [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-4.d [new file with mode: 0644]
gas/testsuite/gas/i386/dwarf2-line-4.s [new file with mode: 0644]
gas/testsuite/gas/i386/i386.exp