mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-24 20:28:28 +08:00
GAS: DWARF-5: Ensure that the 0'th entry in the directory table contains the current working directory.
* dwarf2dbg.c (get_directory_table_entry): Ensure that dir[0] contains current working directory. (out_dir_and_file_list): Likewise. * testsuite/gas/elf/dwarf-5-dir0.s: New test source file. * testsuite/gas/elf/dwarf-5-dir0.d: New test driver. * testsuite/gas/elf/elf.exp: Run the new test. * testsuite/gas/elf/dwarf-5-file0.d: Adjust expected output. * testsuite/gas/i386/dwarf5-line-1.d: Likewise. * testsuite/gas/i386/dwarf5-line-2.d: Likewise.
This commit is contained in:
@ -1,3 +1,15 @@
|
|||||||
|
2021-08-09 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* dwarf2dbg.c (get_directory_table_entry): Ensure that dir[0]
|
||||||
|
contains current working directory.
|
||||||
|
(out_dir_and_file_list): Likewise.
|
||||||
|
* testsuite/gas/elf/dwarf-5-dir0.s: New test source file.
|
||||||
|
* testsuite/gas/elf/dwarf-5-dir0.d: New test driver.
|
||||||
|
* testsuite/gas/elf/elf.exp: Run the new test.
|
||||||
|
* testsuite/gas/elf/dwarf-5-file0.d: Adjust expected output.
|
||||||
|
* testsuite/gas/i386/dwarf5-line-1.d: Likewise.
|
||||||
|
* testsuite/gas/i386/dwarf5-line-2.d: Likewise.
|
||||||
|
|
||||||
2021-07-14 Alan Modra <amodra@gmail.com>
|
2021-07-14 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* write.c (TC_VALIDATE_FIX_SUB): Default to 0.
|
* write.c (TC_VALIDATE_FIX_SUB): Default to 0.
|
||||||
|
@ -620,16 +620,31 @@ get_directory_table_entry (const char *dirname,
|
|||||||
if (can_use_zero)
|
if (can_use_zero)
|
||||||
{
|
{
|
||||||
if (dirs == NULL || dirs[0] == NULL)
|
if (dirs == NULL || dirs[0] == NULL)
|
||||||
|
{
|
||||||
|
const char * pwd = getpwd ();
|
||||||
|
|
||||||
|
if (dwarf_level >= 5 && strcmp (dirname, pwd) != 0)
|
||||||
|
{
|
||||||
|
/* In DWARF-5 the 0 entry in the directory table is expected to be
|
||||||
|
the same as the DW_AT_comp_dir (which is set to the current build
|
||||||
|
directory). Since we are about to create a directory entry that
|
||||||
|
is not the same, allocate the current directory first.
|
||||||
|
FIXME: Alternatively we could generate an error message here. */
|
||||||
|
(void) get_directory_table_entry (pwd, strlen (pwd), true);
|
||||||
|
d = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
d = 0;
|
d = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (d == 0)
|
else if (d == 0)
|
||||||
d = 1;
|
d = 1;
|
||||||
|
|
||||||
if (d >= dirs_allocated)
|
if (d >= dirs_allocated)
|
||||||
{
|
{
|
||||||
unsigned int old = dirs_allocated;
|
unsigned int old = dirs_allocated;
|
||||||
|
#define DIR_TABLE_INCREMENT 32
|
||||||
dirs_allocated = d + 32;
|
dirs_allocated = d + DIR_TABLE_INCREMENT;
|
||||||
dirs = XRESIZEVEC (char *, dirs, dirs_allocated);
|
dirs = XRESIZEVEC (char *, dirs, dirs_allocated);
|
||||||
memset (dirs + old, 0, (dirs_allocated - old) * sizeof (char *));
|
memset (dirs + old, 0, (dirs_allocated - old) * sizeof (char *));
|
||||||
}
|
}
|
||||||
@ -779,7 +794,7 @@ allocate_filename_to_slot (const char *dirname,
|
|||||||
{
|
{
|
||||||
if (dirs == NULL)
|
if (dirs == NULL)
|
||||||
{
|
{
|
||||||
dirs_allocated = files[num].dir + 32;
|
dirs_allocated = files[num].dir + DIR_TABLE_INCREMENT;
|
||||||
dirs = XCNEWVEC (char *, dirs_allocated);
|
dirs = XCNEWVEC (char *, dirs_allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -807,7 +822,7 @@ allocate_filename_to_slot (const char *dirname,
|
|||||||
{
|
{
|
||||||
if (dirs == NULL)
|
if (dirs == NULL)
|
||||||
{
|
{
|
||||||
dirs_allocated = files[num].dir + 32;
|
dirs_allocated = files[num].dir + DIR_TABLE_INCREMENT;
|
||||||
dirs = XCNEWVEC (char *, dirs_allocated);
|
dirs = XCNEWVEC (char *, dirs_allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2082,7 +2097,12 @@ out_dir_and_file_list (segT line_seg, int sizeof_offset)
|
|||||||
Otherwise use pwd as main file directory. */
|
Otherwise use pwd as main file directory. */
|
||||||
if (dirs_in_use > 0 && dirs != NULL && dirs[0] != NULL)
|
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)
|
else if (dirs_in_use > 1
|
||||||
|
&& dirs != NULL
|
||||||
|
&& dirs[1] != NULL
|
||||||
|
/* DWARF-5 directory tables expect dir[0] to be the same as
|
||||||
|
DW_AT_comp_dir, which is the same as pwd. */
|
||||||
|
&& dwarf_level < 5)
|
||||||
dir = remap_debug_filename (dirs[1]);
|
dir = remap_debug_filename (dirs[1]);
|
||||||
else
|
else
|
||||||
dir = remap_debug_filename (getpwd ());
|
dir = remap_debug_filename (getpwd ());
|
||||||
@ -2185,7 +2205,7 @@ out_dir_and_file_list (segT line_seg, int sizeof_offset)
|
|||||||
uses slot zero, but that is only set explicitly using a
|
uses slot zero, but that is only set explicitly using a
|
||||||
.file 0 directive. If that isn't used, but file 1 is,
|
.file 0 directive. If that isn't used, but file 1 is,
|
||||||
then use that as main file name. */
|
then use that as main file name. */
|
||||||
if (DWARF2_LINE_VERSION >= 5 && i == 0 && files_in_use >= 1)
|
if (DWARF2_LINE_VERSION >= 5 && i == 0 && files_in_use >= 1 && files[0].filename == NULL)
|
||||||
files[0].filename = files[1].filename;
|
files[0].filename = files[1].filename;
|
||||||
else
|
else
|
||||||
files[i].filename = "";
|
files[i].filename = "";
|
||||||
|
20
gas/testsuite/gas/elf/dwarf-5-dir0.d
Normal file
20
gas/testsuite/gas/elf/dwarf-5-dir0.d
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#as: --gdwarf-5
|
||||||
|
#name: DWARF5 dir[0]
|
||||||
|
#readelf: -wl
|
||||||
|
|
||||||
|
#...
|
||||||
|
The Directory Table \(offset 0x.*, lines 4, columns 1\):
|
||||||
|
Entry Name
|
||||||
|
0 \(indirect line string, offset: 0x0\): .*/gas/testsuite
|
||||||
|
1 \(indirect line string, offset: 0x.*\): ../not-the-build-directory
|
||||||
|
2 \(indirect line string, offset: 0x.*\): secondary directory
|
||||||
|
3 \(indirect line string, offset: 0x.*\): /tmp
|
||||||
|
|
||||||
|
The File Name Table \(offset 0x.*, lines 3, columns 3\):
|
||||||
|
Entry Dir MD5 Name
|
||||||
|
0 1 0x0 \(indirect line string, offset: 0x.*\): master-source-file.c
|
||||||
|
1 2 0x0 \(indirect line string, offset: 0x.*\): secondary source file
|
||||||
|
2 3 0x95828e8bc4f7404dbf7526fb7bd0f192 \(indirect line string, offset: 0x.*\): foo.c
|
||||||
|
#pass
|
||||||
|
|
||||||
|
|
19
gas/testsuite/gas/elf/dwarf-5-dir0.s
Normal file
19
gas/testsuite/gas/elf/dwarf-5-dir0.s
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
.section .debug_info,"",%progbits
|
||||||
|
.4byte 0x8a
|
||||||
|
.2byte 0x2
|
||||||
|
.4byte .Ldebug_abbrev0
|
||||||
|
.byte 0x4
|
||||||
|
.uleb128 0x1
|
||||||
|
|
||||||
|
.file 0 "../not-the-build-directory/master-source-file.c"
|
||||||
|
.line 1
|
||||||
|
.text
|
||||||
|
.octa 0x12345678901234567890123456789012
|
||||||
|
|
||||||
|
.file 1 "secondary directory/secondary source file"
|
||||||
|
.line 2
|
||||||
|
.word 2
|
||||||
|
|
||||||
|
.file 2 "/tmp" "foo.c" md5 0x95828e8bc4f7404dbf7526fb7bd0f192
|
||||||
|
.line 5
|
||||||
|
.word 6
|
@ -3,17 +3,18 @@
|
|||||||
#readelf: -wl
|
#readelf: -wl
|
||||||
|
|
||||||
#...
|
#...
|
||||||
The Directory Table \(offset 0x.*, lines 3, columns 1\):
|
The Directory Table \(offset 0x.*, lines 4, columns 1\):
|
||||||
Entry Name
|
Entry Name
|
||||||
0 \(indirect line string, offset: 0x.*\): master directory
|
#...
|
||||||
1 \(indirect line string, offset: 0x.*\): secondary directory
|
1 \(indirect line string, offset: 0x.*\): master directory
|
||||||
2 \(indirect line string, offset: 0x.*\): /tmp
|
2 \(indirect line string, offset: 0x.*\): secondary directory
|
||||||
|
3 \(indirect line string, offset: 0x.*\): /tmp
|
||||||
|
|
||||||
The File Name Table \(offset 0x.*, lines 3, columns 3\):
|
The File Name Table \(offset 0x.*, lines 3, columns 3\):
|
||||||
Entry Dir MD5 Name
|
Entry Dir MD5 Name
|
||||||
0 0 0x0 \(indirect line string, offset: 0x.*\): master source file
|
0 1 0x0 \(indirect line string, offset: 0x.*\): master source file
|
||||||
1 1 0x0 \(indirect line string, offset: 0x.*\): secondary source file
|
1 2 0x0 \(indirect line string, offset: 0x.*\): secondary source file
|
||||||
2 2 0x95828e8bc4f7404dbf7526fb7bd0f192 \(indirect line string, offset: 0x.*\): foo.c
|
2 3 0x95828e8bc4f7404dbf7526fb7bd0f192 \(indirect line string, offset: 0x.*\): foo.c
|
||||||
#pass
|
#pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -297,6 +297,7 @@ if { [is_elf_format] } then {
|
|||||||
run_dump_test "dwarf2-19" $dump_opts
|
run_dump_test "dwarf2-19" $dump_opts
|
||||||
run_dump_test "dwarf2-20" $dump_opts
|
run_dump_test "dwarf2-20" $dump_opts
|
||||||
run_dump_test "dwarf-5-file0" $dump_opts
|
run_dump_test "dwarf-5-file0" $dump_opts
|
||||||
|
run_dump_test "dwarf-5-dir0" $dump_opts
|
||||||
run_dump_test "dwarf-4-cu" $dump_opts
|
run_dump_test "dwarf-4-cu" $dump_opts
|
||||||
run_dump_test "dwarf-5-cu" $dump_opts
|
run_dump_test "dwarf-5-cu" $dump_opts
|
||||||
run_dump_test "dwarf-5-nop-for-line-table" $dump_opts
|
run_dump_test "dwarf-5-nop-for-line-table" $dump_opts
|
||||||
|
@ -33,7 +33,7 @@ Raw dump of debug contents of section \.z?debug_line:
|
|||||||
|
|
||||||
The Directory Table \(offset 0x.*, lines 2, columns 1\):
|
The Directory Table \(offset 0x.*, lines 2, columns 1\):
|
||||||
Entry Name
|
Entry Name
|
||||||
0 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
|
0 \(indirect line string, offset: 0x.*\): .*/gas/testsuite
|
||||||
1 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
|
1 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
|
||||||
|
|
||||||
The File Name Table \(offset 0x.*, lines 2, columns 3\):
|
The File Name Table \(offset 0x.*, lines 2, columns 3\):
|
||||||
|
@ -33,7 +33,7 @@ Raw dump of debug contents of section \.z?debug_line:
|
|||||||
|
|
||||||
The Directory Table \(offset 0x.*, lines 2, columns 1\):
|
The Directory Table \(offset 0x.*, lines 2, columns 1\):
|
||||||
Entry Name
|
Entry Name
|
||||||
0 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
|
0 \(indirect line string, offset: 0x.*\): .*/gas/testsuite
|
||||||
1 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
|
1 \(indirect line string, offset: 0x.*\): .*/gas/testsuite/gas/i386
|
||||||
|
|
||||||
The File Name Table \(offset 0x.*, lines 1, columns 3\):
|
The File Name Table \(offset 0x.*, lines 1, columns 3\):
|
||||||
|
Reference in New Issue
Block a user