summaryrefslogtreecommitdiff
path: root/gas/dwarf2dbg.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2010-07-05 15:07:17 +0000
committerH.J. Lu <hjl.tools@gmail.com>2010-07-05 15:07:17 +0000
commita30691ab5d1406cbad298b3a3f543efd8c07717a (patch)
tree2408c60dc9d648f6011df6465412f586ca2a3210 /gas/dwarf2dbg.c
parentc4d6024061b21445dbc34596115a001069023aa4 (diff)
downloadbinutils-redhat-a30691ab5d1406cbad298b3a3f543efd8c07717a.tar.gz
Don't generate .debug_line section if it isn't empty.
binutils/testsuite/ 2010-07-05 H.J. Lu <hongjiu.lu@intel.com> PR gas/10531 PR gas/11789 * binutils-all/objdump.W: Remove bogus line debug info. gas/ 2010-07-05 Jim Wilson <wilson@codesourcery.com> PR gas/10531 PR gas/11789 * dwarf2dbg.c (dwarf2_finish): Don't generate .debug_line section if it isn't empty. gas/testsuite/ 2010-07-05 H.J. Lu <hongjiu.lu@intel.com> PR gas/10531 PR gas/11789 * gas/i386/dw2-compress-1.d: Remove bogus line debug info. * gas/elf/dwarf2-1.d: New. * gas/elf/dwarf2-1.s: Likewise. * gas/elf/dwarf2-2.d: Likewise. * gas/elf/dwarf2-2.s: Likewise. * gas/elf/dwarf2-3.d: Likewise. * gas/elf/dwarf2-3.s: Likewise. * gas/i386/debug1.d: Likewise. * gas/i386/debug1.s: Likewise. * gas/elf/elf.exp: Run dwarf2-1, dwarf2-2 and dwarf2-3. * gas/i386/i386.exp: Run debug1 for both 32bit and 64bit.
Diffstat (limited to 'gas/dwarf2dbg.c')
-rw-r--r--gas/dwarf2dbg.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 4061c72893..85c1f30e89 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -1718,11 +1718,12 @@ dwarf2_init (void)
/* Finish the dwarf2 debug sections. We emit .debug.line if there
were any .file/.loc directives, or --gdwarf2 was given, or if the
- file has a non-empty .debug_info section. If we emit .debug_line,
- and the .debug_info section is empty, we also emit .debug_info,
- .debug_aranges and .debug_abbrev. ALL_SEGS will be non-null if
- there were any .file/.loc directives, or --gdwarf2 was given and
- there were any located instructions emitted. */
+ file has a non-empty .debug_info section and an empty .debug_line
+ section. If we emit .debug_line, and the .debug_info section is
+ empty, we also emit .debug_info, .debug_aranges and .debug_abbrev.
+ ALL_SEGS will be non-null if there were any .file/.loc directives,
+ or --gdwarf2 was given and there were any located instructions
+ emitted. */
void
dwarf2_finish (void)
@@ -1731,13 +1732,24 @@ dwarf2_finish (void)
struct line_seg *s;
segT info_seg;
int emit_other_sections = 0;
+ int empty_debug_line = 0;
info_seg = bfd_get_section_by_name (stdoutput, ".debug_info");
emit_other_sections = info_seg == NULL || !seg_not_empty_p (info_seg);
- if (!all_segs && emit_other_sections)
- /* There is no line information and no non-empty .debug_info
- section. */
+ line_seg = bfd_get_section_by_name (stdoutput, ".debug_line");
+ empty_debug_line = line_seg == NULL || !seg_not_empty_p (line_seg);
+
+ /* We can't construct a new debug_line section if we already have one.
+ Give an error. */
+ if (all_segs && !empty_debug_line)
+ as_fatal ("duplicate .debug_line sections");
+
+ if ((!all_segs && emit_other_sections)
+ || (!emit_other_sections && !empty_debug_line))
+ /* If there is no line information and no non-empty .debug_info
+ section, or if there is both a non-empty .debug_info and a non-empty
+ .debug_line, then we do nothing. */
return;
/* Calculate the size of an address for the target machine. */