Skip to content

Commit 639601f

Browse files
committed
bfd/dwarf2.c: allow use of DWARF5 directory entry 0
I think the test for table->files[file].dir being non-zero is wrong for DWARF5 where index zero is allowed and is the current directory of the compilation. Most times this will be covered by the use of table->comp_dir (from DW_AT_comp_dir) in concat_filename but the point of putting the current dir in .debug_line was so the section could stand alone without .debug_info. Also, there is no need to check for table->dirs non-NULL, the table->num_dirs test is sufficient. * dwarf2.c (concat_filename): Correct and simplify tests of directory index.
1 parent aac7ae5 commit 639601f

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

bfd/dwarf2.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2044,19 +2044,16 @@ concat_filename (struct line_info_table *table, unsigned int file)
20442044
char *subdir_name = NULL;
20452045
char *name;
20462046
size_t len;
2047-
2048-
if (table->files[file].dir
2049-
/* PR 17512: file: 0317e960. */
2050-
&& table->files[file].dir
2051-
<= (table->use_dir_and_file_0 ? table->num_dirs - 1 : table->num_dirs)
2052-
/* PR 17512: file: 7f3d2e4b. */
2053-
&& table->dirs != NULL)
2054-
{
2055-
if (table->use_dir_and_file_0)
2056-
subdir_name = table->dirs[table->files[file].dir];
2057-
else
2058-
subdir_name = table->dirs[table->files[file].dir - 1];
2059-
}
2047+
unsigned int dir = table->files[file].dir;
2048+
2049+
if (!table->use_dir_and_file_0)
2050+
--dir;
2051+
/* Wrapping from 0 to -1u above gives the intended result with
2052+
the test below of leaving subdir_name NULL for pre-DWARF5 dir
2053+
of 0. */
2054+
/* PR 17512: file: 0317e960, file: 7f3d2e4b. */
2055+
if (dir < table->num_dirs)
2056+
subdir_name = table->dirs[dir];
20602057

20612058
if (!subdir_name || !IS_ABSOLUTE_PATH (subdir_name))
20622059
dir_name = table->comp_dir;

0 commit comments

Comments
 (0)