Skip to content

Commit 1586c50

Browse files
committed
PR27218, memory access violation in dwarf2dbg.c
PR 27218 * dwarf2dbg.c (dwarf2_gen_line_info): Correct setting of dwarf_level. (dwarf2_directive_filename, dwarf2_directive_loc): Likewise, and error for negative file numbers. (cherry picked from commit 498ff03)
1 parent 37f3ab9 commit 1586c50

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

gas/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2021-01-21 Alan Modra <amodra@gmail.com>
2+
3+
PR 27218
4+
* dwarf2dbg.c (dwarf2_gen_line_info): Correct setting of dwarf_level.
5+
(dwarf2_directive_filename, dwarf2_directive_loc): Likewise, and
6+
error for negative file numbers.
7+
18
2021-01-18 H.J. Lu <hongjiu.lu@intel.com>
29

310
PR gas/27195

gas/dwarf2dbg.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -550,9 +550,10 @@ dwarf2_gen_line_info (addressT ofs, struct dwarf2_line_info *loc)
550550
/* Early out for as-yet incomplete location information. */
551551
if (loc->line == 0)
552552
return;
553-
if (loc->filenum == 0 && DWARF2_LINE_VERSION < 5)
553+
if (loc->filenum == 0)
554554
{
555-
dwarf_level = 5;
555+
if (dwarf_level < 5)
556+
dwarf_level = 5;
556557
if (DWARF2_LINE_VERSION < 5)
557558
return;
558559
}
@@ -1046,10 +1047,11 @@ dwarf2_directive_filename (void)
10461047

10471048
num = get_absolute_expression ();
10481049

1049-
if ((offsetT) num < 1 && DWARF2_LINE_VERSION < 5)
1050+
if ((offsetT) num < 1)
10501051
{
1051-
dwarf_level = 5;
1052-
if (DWARF2_LINE_VERSION < 5)
1052+
if (num == 0 && dwarf_level < 5)
1053+
dwarf_level = 5;
1054+
if ((offsetT) num < 0 || DWARF2_LINE_VERSION < 5)
10531055
{
10541056
as_bad (_("file number less than one"));
10551057
ignore_rest_of_line ();
@@ -1149,18 +1151,16 @@ dwarf2_directive_loc (int dummy ATTRIBUTE_UNUSED)
11491151

11501152
if (filenum < 1)
11511153
{
1152-
if (filenum != 0 || DWARF2_LINE_VERSION < 5)
1154+
if (filenum == 0 && dwarf_level < 5)
1155+
dwarf_level = 5;
1156+
if (filenum < 0 || DWARF2_LINE_VERSION < 5)
11531157
{
1154-
dwarf_level = 5;
1155-
if (DWARF2_LINE_VERSION < 5)
1156-
{
1157-
as_bad (_("file number less than one"));
1158-
return;
1159-
}
1158+
as_bad (_("file number less than one"));
1159+
return;
11601160
}
11611161
}
11621162

1163-
if (filenum >= (int) files_in_use || files[filenum].filename == NULL)
1163+
if ((valueT) filenum >= files_in_use || files[filenum].filename == NULL)
11641164
{
11651165
as_bad (_("unassigned file number %ld"), (long) filenum);
11661166
return;

0 commit comments

Comments
 (0)