mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 04:00:07 +08:00
gas: Make sure .debug_line file table contains a zero filename and dir
For DWARF5 the zero file list entry in the .debug_line table represents the compile unit main file. It can be set with .file 0 when -gdwarf-5 is given. But since this directive is illegal for older versions, this is almost never set. To make sure it is always set (so DW_AT_name of the compile unit can be set) use file (and dir) 1 if that is defined (otherwise fall back to pwd, to match DW_AT_comp_dir). gas/ChangeLog: * gas/dwarf2dbg.c (out_dir_and_file_list): For DWARF5 emit at least one directory if there is at least one file. Use dirs[1] if dirs[0] is not set, or if there is no dirs[1] the current working directory. Use files[1] filename, when files[0] filename isn't set.
This commit is contained in:
@ -1,3 +1,11 @@
|
|||||||
|
2020-08-02 Mark Wielaard <mark@klomp.org>
|
||||||
|
|
||||||
|
* gas/dwarf2dbg.c (out_dir_and_file_list): For DWARF5 emit at
|
||||||
|
least one directory if there is at least one file. Use dirs[1]
|
||||||
|
if dirs[0] is not set, or if there is no dirs[1] the current
|
||||||
|
working directory. Use files[1] filename, when files[0] filename
|
||||||
|
isn't set.
|
||||||
|
|
||||||
2020-08-02 Mark Wielaard <mark@klomp.org>
|
2020-08-02 Mark Wielaard <mark@klomp.org>
|
||||||
|
|
||||||
* dwarf2dbg.c (out_debug_info): Emit unit type and abbrev offset
|
* dwarf2dbg.c (out_debug_info): Emit unit type and abbrev offset
|
||||||
|
@ -1992,17 +1992,28 @@ out_dir_and_file_list (void)
|
|||||||
the .debug_line_str section and reference them here. */
|
the .debug_line_str section and reference them here. */
|
||||||
out_uleb128 (DW_FORM_string);
|
out_uleb128 (DW_FORM_string);
|
||||||
|
|
||||||
/* Now state how many rows there are in the table. */
|
/* Now state how many rows there are in the table. We need at
|
||||||
|
least 1 if there is one or more file names to store the
|
||||||
|
"working directory". */
|
||||||
|
if (dirs_in_use == 0 && files_in_use > 0)
|
||||||
|
out_uleb128 (1);
|
||||||
|
else
|
||||||
out_uleb128 (dirs_in_use);
|
out_uleb128 (dirs_in_use);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Emit directory list. */
|
/* Emit directory list. */
|
||||||
if (DWARF2_LINE_VERSION >= 5 && dirs_in_use > 0)
|
if (DWARF2_LINE_VERSION >= 5 && (dirs_in_use > 0 || files_in_use > 0))
|
||||||
{
|
{
|
||||||
if (dirs == NULL || dirs[0] == NULL)
|
/* DWARF5 uses slot zero, but that is only set explicitly
|
||||||
dir = remap_debug_filename (".");
|
using a .file 0 directive. If that isn't used, but dir
|
||||||
else
|
one is used, then use that as main file directory.
|
||||||
|
Otherwise use pwd as main file directory. */
|
||||||
|
if (dirs_in_use > 0 && dirs != NULL && dirs[0] != NULL)
|
||||||
dir = remap_debug_filename (dirs[0]);
|
dir = remap_debug_filename (dirs[0]);
|
||||||
|
else if (dirs_in_use > 1 && dirs != NULL && dirs[1] != NULL)
|
||||||
|
dir = remap_debug_filename (dirs[1]);
|
||||||
|
else
|
||||||
|
dir = remap_debug_filename (getpwd ());
|
||||||
|
|
||||||
size = strlen (dir) + 1;
|
size = strlen (dir) + 1;
|
||||||
cp = frag_more (size);
|
cp = frag_more (size);
|
||||||
@ -2089,7 +2100,13 @@ out_dir_and_file_list (void)
|
|||||||
|
|
||||||
if (files[i].filename == NULL)
|
if (files[i].filename == NULL)
|
||||||
{
|
{
|
||||||
/* Prevent a crash later, particularly for file 1. */
|
/* Prevent a crash later, particularly for file 1. DWARF5
|
||||||
|
uses slot zero, but that is only set explicitly using a
|
||||||
|
.file 0 directive. If that isn't used, but file 1 is,
|
||||||
|
then use that as main file name. */
|
||||||
|
if (DWARF2_LINE_VERSION >= 5 && i == 0 && files_in_use >= 1)
|
||||||
|
files[0].filename = files[1].filename;
|
||||||
|
else
|
||||||
files[i].filename = "";
|
files[i].filename = "";
|
||||||
if (DWARF2_LINE_VERSION < 5 || i != 0)
|
if (DWARF2_LINE_VERSION < 5 || i != 0)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user