aboutsummaryrefslogtreecommitdiff
path: root/gas/dwarf2dbg.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2020-11-12 11:43:20 +0000
committerNick Clifton <nickc@redhat.com>2020-11-12 11:43:20 +0000
commitbcb78b47614ed252226da1a688558a17d8a99ce8 (patch)
tree18d3480d3cb634ae6c431ef27e1b338ccecfbe84 /gas/dwarf2dbg.c
parentab33b15255460ac45a001c8ebf69ef73f6f1fba4 (diff)
downloadgdb-bcb78b47614ed252226da1a688558a17d8a99ce8.zip
gdb-bcb78b47614ed252226da1a688558a17d8a99ce8.tar.gz
gdb-bcb78b47614ed252226da1a688558a17d8a99ce8.tar.bz2
Stop Gas from generating line info or address ranges for sections that do not contain code or are not loaded.
PR 26850 * dwarf2dbg.c (dwarf2_gen_line_info_1): Do not record lines in sections that are not executable or not loadable. (out_debug_line): Move warning message into dwarf2_gen_line_info_1. * testsuite/gas/elf/dwarf2-20.s: New test. * testsuite/gas/elf/dwarf2-20.d: New test driver. * testsuite/gas/elf/elf.exp: Run the new test. * testsuite/gas/elf/warn-2.s: Use the .nop directive.
Diffstat (limited to 'gas/dwarf2dbg.c')
-rw-r--r--gas/dwarf2dbg.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/gas/dwarf2dbg.c b/gas/dwarf2dbg.c
index 4e03c63..25ebc94 100644
--- a/gas/dwarf2dbg.c
+++ b/gas/dwarf2dbg.c
@@ -504,6 +504,18 @@ dwarf2_gen_line_info_1 (symbolS *label, struct dwarf2_line_info *loc)
{
struct line_subseg *lss;
struct line_entry *e;
+ flagword need_flags = SEC_ALLOC | SEC_LOAD | SEC_CODE;
+
+ /* PR 26850: Do not record LOCs in non-executable, non-allocated,
+ or non-loaded sections. */
+ if ((now_seg->flags & need_flags) != need_flags)
+ {
+ if (! SEG_NORMAL (now_seg))
+ /* FIXME: Add code to suppress multiple warnings ? */
+ as_warn ("dwarf line number information for %s ignored",
+ segment_name (now_seg));
+ return;
+ }
e = XNEW (struct line_entry);
e->next = NULL;
@@ -2341,11 +2353,10 @@ out_debug_line (segT line_seg)
/* For each section, emit a statement program. */
for (s = all_segs; s; s = s->next)
+ /* Paranoia - this check should have already have
+ been handled in dwarf2_gen_line_info_1(). */
if (SEG_NORMAL (s->seg))
process_entries (s->seg, s->head->head);
- else
- as_warn ("dwarf line number information for %s ignored",
- segment_name (s->seg));
if (flag_dwarf_sections)
/* We have to switch to the special .debug_line_end section
@@ -2740,7 +2751,6 @@ dwarf2_init (void)
flag_dwarf_cie_version = 1;
}
-
/* Finish the dwarf2 debug sections. We emit .debug.line if there
were any .file/.loc directives, or --gdwarf2 was given, and if the
file has a non-empty .debug_info section and an empty .debug_line