|
|
a76379 |
diff --git a/gas/testsuite/gas/elf/dwarf-5-file0-2.d b/gas/testsuite/gas/elf/dwarf-5-file0-2.d
|
|
|
a76379 |
new file mode 100644
|
|
|
a76379 |
index 00000000000..4b3ed29f4c9
|
|
|
a76379 |
--- /dev/null
|
|
|
a76379 |
+++ b/gas/testsuite/gas/elf/dwarf-5-file0-2.d
|
|
|
a76379 |
@@ -0,0 +1,15 @@
|
|
|
a76379 |
+#as: --gdwarf-5
|
|
|
a76379 |
+#name: DWARF5 .file 0 dir file
|
|
|
a76379 |
+#readelf: -wl
|
|
|
a76379 |
+
|
|
|
a76379 |
+#...
|
|
|
a76379 |
+ The Directory Table \(offset 0x.*, lines 1, columns 1\):
|
|
|
a76379 |
+ Entry Name
|
|
|
a76379 |
+#...
|
|
|
a76379 |
+ 0 \(indirect line string, offset: 0x.*\): /example
|
|
|
a76379 |
+
|
|
|
a76379 |
+ The File Name Table \(offset 0x.*, lines 2, columns 2\):
|
|
|
a76379 |
+ Entry Dir Name
|
|
|
a76379 |
+ 0 0 \(indirect line string, offset: 0x.*\): test.c
|
|
|
a76379 |
+ 1 0 \(indirect line string, offset: 0x.*\): test.c
|
|
|
a76379 |
+#pass
|
|
|
a76379 |
diff --git a/gas/testsuite/gas/elf/dwarf-5-file0-2.s b/gas/testsuite/gas/elf/dwarf-5-file0-2.s
|
|
|
a76379 |
new file mode 100644
|
|
|
a76379 |
index 00000000000..135a03bf493
|
|
|
a76379 |
--- /dev/null
|
|
|
a76379 |
+++ b/gas/testsuite/gas/elf/dwarf-5-file0-2.s
|
|
|
a76379 |
@@ -0,0 +1,111 @@
|
|
|
a76379 |
+ .file "test.c"
|
|
|
a76379 |
+ .text
|
|
|
a76379 |
+.Ltext0:
|
|
|
a76379 |
+ .file 0 "/example" "test.c"
|
|
|
a76379 |
+ .globl x
|
|
|
a76379 |
+ .section .bss
|
|
|
a76379 |
+ .balign 4
|
|
|
a76379 |
+ .type x, @object
|
|
|
a76379 |
+ .size x, 4
|
|
|
a76379 |
+x:
|
|
|
a76379 |
+ .zero 4
|
|
|
a76379 |
+ .text
|
|
|
a76379 |
+.Letext0:
|
|
|
a76379 |
+ .file 1 "test.c"
|
|
|
a76379 |
+ .section .debug_info,"",%progbits
|
|
|
a76379 |
+.Ldebug_info0:
|
|
|
a76379 |
+ .long 0x32
|
|
|
a76379 |
+ .2byte 0x5
|
|
|
a76379 |
+ .byte 0x1
|
|
|
a76379 |
+ .byte 0x4
|
|
|
a76379 |
+ .long .Ldebug_abbrev0
|
|
|
a76379 |
+ .uleb128 0x1
|
|
|
a76379 |
+ .long .LASF2
|
|
|
a76379 |
+ .byte 0x1d
|
|
|
a76379 |
+ .long .LASF0
|
|
|
a76379 |
+ .long .LASF1
|
|
|
a76379 |
+ .long .Ldebug_line0
|
|
|
a76379 |
+ .uleb128 0x2
|
|
|
a76379 |
+ .string "x"
|
|
|
a76379 |
+ .byte 0x1
|
|
|
a76379 |
+ .byte 0x1
|
|
|
a76379 |
+ .byte 0x5
|
|
|
a76379 |
+ .long 0x2e
|
|
|
a76379 |
+ .uleb128 0x5
|
|
|
a76379 |
+ .byte 0x3
|
|
|
a76379 |
+ .long x
|
|
|
a76379 |
+ .uleb128 0x3
|
|
|
a76379 |
+ .byte 0x4
|
|
|
a76379 |
+ .byte 0x5
|
|
|
a76379 |
+ .string "int"
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .section .debug_abbrev,"",%progbits
|
|
|
a76379 |
+.Ldebug_abbrev0:
|
|
|
a76379 |
+ .uleb128 0x1
|
|
|
a76379 |
+ .uleb128 0x11
|
|
|
a76379 |
+ .byte 0x1
|
|
|
a76379 |
+ .uleb128 0x25
|
|
|
a76379 |
+ .uleb128 0xe
|
|
|
a76379 |
+ .uleb128 0x13
|
|
|
a76379 |
+ .uleb128 0xb
|
|
|
a76379 |
+ .uleb128 0x3
|
|
|
a76379 |
+ .uleb128 0x1f
|
|
|
a76379 |
+ .uleb128 0x1b
|
|
|
a76379 |
+ .uleb128 0x1f
|
|
|
a76379 |
+ .uleb128 0x10
|
|
|
a76379 |
+ .uleb128 0x17
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .uleb128 0x2
|
|
|
a76379 |
+ .uleb128 0x34
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .uleb128 0x3
|
|
|
a76379 |
+ .uleb128 0x8
|
|
|
a76379 |
+ .uleb128 0x3a
|
|
|
a76379 |
+ .uleb128 0xb
|
|
|
a76379 |
+ .uleb128 0x3b
|
|
|
a76379 |
+ .uleb128 0xb
|
|
|
a76379 |
+ .uleb128 0x39
|
|
|
a76379 |
+ .uleb128 0xb
|
|
|
a76379 |
+ .uleb128 0x49
|
|
|
a76379 |
+ .uleb128 0x13
|
|
|
a76379 |
+ .uleb128 0x3f
|
|
|
a76379 |
+ .uleb128 0x19
|
|
|
a76379 |
+ .uleb128 0x2
|
|
|
a76379 |
+ .uleb128 0x18
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .uleb128 0x3
|
|
|
a76379 |
+ .uleb128 0x24
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .uleb128 0xb
|
|
|
a76379 |
+ .uleb128 0xb
|
|
|
a76379 |
+ .uleb128 0x3e
|
|
|
a76379 |
+ .uleb128 0xb
|
|
|
a76379 |
+ .uleb128 0x3
|
|
|
a76379 |
+ .uleb128 0x8
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .section .debug_aranges,"",%progbits
|
|
|
a76379 |
+ .long 0x14
|
|
|
a76379 |
+ .2byte 0x2
|
|
|
a76379 |
+ .long .Ldebug_info0
|
|
|
a76379 |
+ .byte 0x4
|
|
|
a76379 |
+ .byte 0
|
|
|
a76379 |
+ .2byte 0
|
|
|
a76379 |
+ .2byte 0
|
|
|
a76379 |
+ .long 0
|
|
|
a76379 |
+ .long 0
|
|
|
a76379 |
+ .section .debug_line,"",%progbits
|
|
|
a76379 |
+.Ldebug_line0:
|
|
|
a76379 |
+ .section .debug_str,"MS",%progbits,1
|
|
|
a76379 |
+.LASF2:
|
|
|
a76379 |
+ .string "GNU C17 11.2.1 -g"
|
|
|
a76379 |
+ .section .debug_line_str,"MS",%progbits,1
|
|
|
a76379 |
+.LASF1:
|
|
|
a76379 |
+ .string "/example"
|
|
|
a76379 |
+.LASF0:
|
|
|
a76379 |
+ .string "test.c"
|
|
|
a76379 |
+ .ident "GCC: (GNU) 11.2.1"
|
|
|
a76379 |
+ .section .note.GNU-stack,"",%progbits
|
|
|
a76379 |
diff --git a/gas/testsuite/gas/elf/dwarf-5-file0-2.s b/gas/testsuite/gas/elf/dwarf-5-file0-2.s
|
|
|
a76379 |
index 135a03bf493..bab4a16b56b 100644
|
|
|
a76379 |
--- a/gas/testsuite/gas/elf/dwarf-5-file0-2.s
|
|
|
a76379 |
+++ b/gas/testsuite/gas/elf/dwarf-5-file0-2.s
|
|
|
a76379 |
@@ -5,7 +5,7 @@
|
|
|
a76379 |
.globl x
|
|
|
a76379 |
.section .bss
|
|
|
a76379 |
.balign 4
|
|
|
a76379 |
- .type x, @object
|
|
|
a76379 |
+ .type x, %object
|
|
|
a76379 |
.size x, 4
|
|
|
a76379 |
x:
|
|
|
a76379 |
.zero 4
|
|
|
a76379 |
@@ -14,30 +14,30 @@ x:
|
|
|
a76379 |
.file 1 "test.c"
|
|
|
a76379 |
.section .debug_info,"",%progbits
|
|
|
a76379 |
.Ldebug_info0:
|
|
|
a76379 |
- .long 0x32
|
|
|
a76379 |
+ .4byte 0x32
|
|
|
a76379 |
.2byte 0x5
|
|
|
a76379 |
.byte 0x1
|
|
|
a76379 |
.byte 0x4
|
|
|
a76379 |
- .long .Ldebug_abbrev0
|
|
|
a76379 |
+ .4byte .Ldebug_abbrev0
|
|
|
a76379 |
.uleb128 0x1
|
|
|
a76379 |
- .long .LASF2
|
|
|
a76379 |
+ .4byte .LASF2
|
|
|
a76379 |
.byte 0x1d
|
|
|
a76379 |
- .long .LASF0
|
|
|
a76379 |
- .long .LASF1
|
|
|
a76379 |
- .long .Ldebug_line0
|
|
|
a76379 |
+ .4byte .LASF0
|
|
|
a76379 |
+ .4byte .LASF1
|
|
|
a76379 |
+ .4byte .Ldebug_line0
|
|
|
a76379 |
.uleb128 0x2
|
|
|
a76379 |
- .string "x"
|
|
|
a76379 |
+ .asciz "x"
|
|
|
a76379 |
.byte 0x1
|
|
|
a76379 |
.byte 0x1
|
|
|
a76379 |
.byte 0x5
|
|
|
a76379 |
- .long 0x2e
|
|
|
a76379 |
+ .4byte 0x2e
|
|
|
a76379 |
.uleb128 0x5
|
|
|
a76379 |
.byte 0x3
|
|
|
a76379 |
- .long x
|
|
|
a76379 |
+ .4byte x
|
|
|
a76379 |
.uleb128 0x3
|
|
|
a76379 |
.byte 0x4
|
|
|
a76379 |
.byte 0x5
|
|
|
a76379 |
- .string "int"
|
|
|
a76379 |
+ .asciz "int"
|
|
|
a76379 |
.byte 0
|
|
|
a76379 |
.section .debug_abbrev,"",%progbits
|
|
|
a76379 |
.Ldebug_abbrev0:
|
|
|
a76379 |
@@ -88,24 +88,24 @@ x:
|
|
|
a76379 |
.byte 0
|
|
|
a76379 |
.byte 0
|
|
|
a76379 |
.section .debug_aranges,"",%progbits
|
|
|
a76379 |
- .long 0x14
|
|
|
a76379 |
+ .4byte 0x14
|
|
|
a76379 |
.2byte 0x2
|
|
|
a76379 |
- .long .Ldebug_info0
|
|
|
a76379 |
+ .4byte .Ldebug_info0
|
|
|
a76379 |
.byte 0x4
|
|
|
a76379 |
.byte 0
|
|
|
a76379 |
.2byte 0
|
|
|
a76379 |
.2byte 0
|
|
|
a76379 |
- .long 0
|
|
|
a76379 |
- .long 0
|
|
|
a76379 |
+ .4byte 0
|
|
|
a76379 |
+ .4byte 0
|
|
|
a76379 |
.section .debug_line,"",%progbits
|
|
|
a76379 |
.Ldebug_line0:
|
|
|
a76379 |
.section .debug_str,"MS",%progbits,1
|
|
|
a76379 |
.LASF2:
|
|
|
a76379 |
- .string "GNU C17 11.2.1 -g"
|
|
|
a76379 |
+ .asciz "GNU C17 11.2.1 -g"
|
|
|
a76379 |
.section .debug_line_str,"MS",%progbits,1
|
|
|
a76379 |
.LASF1:
|
|
|
a76379 |
- .string "/example"
|
|
|
a76379 |
+ .asciz "/example"
|
|
|
a76379 |
.LASF0:
|
|
|
a76379 |
- .string "test.c"
|
|
|
a76379 |
+ .asciz "test.c"
|
|
|
a76379 |
.ident "GCC: (GNU) 11.2.1"
|
|
|
a76379 |
.section .note.GNU-stack,"",%progbits
|
|
|
a76379 |
diff -rup binutils.orig/gas/dwarf2dbg.c binutils-2.35.2/gas/dwarf2dbg.c
|
|
|
a76379 |
--- binutils.orig/gas/dwarf2dbg.c 2021-11-08 14:59:19.759524743 +0000
|
|
|
a76379 |
+++ binutils-2.35.2/gas/dwarf2dbg.c 2021-11-08 15:00:55.179909708 +0000
|
|
|
a76379 |
@@ -588,6 +588,7 @@ get_basename (const char * pathname)
|
|
|
a76379 |
|
|
|
a76379 |
static unsigned int
|
|
|
a76379 |
get_directory_table_entry (const char * dirname,
|
|
|
a76379 |
+ const char * file0_dirname,
|
|
|
a76379 |
size_t dirlen,
|
|
|
a76379 |
bfd_boolean can_use_zero)
|
|
|
a76379 |
{
|
|
|
a76379 |
@@ -617,7 +618,7 @@ get_directory_table_entry (const char *
|
|
|
a76379 |
{
|
|
|
a76379 |
if (dirs == NULL || dirs[0] == NULL)
|
|
|
a76379 |
{
|
|
|
a76379 |
- const char * pwd = getpwd ();
|
|
|
a76379 |
+ const char * pwd = file0_dirname ? file0_dirname : getpwd ();
|
|
|
a76379 |
|
|
|
a76379 |
if (dwarf_level >= 5 && strcmp (dirname, pwd) != 0)
|
|
|
a76379 |
{
|
|
|
a76379 |
@@ -626,7 +627,7 @@ get_directory_table_entry (const char *
|
|
|
a76379 |
directory). Since we are about to create a directory entry that
|
|
|
a76379 |
is not the same, allocate the current directory first.
|
|
|
a76379 |
FIXME: Alternatively we could generate an error message here. */
|
|
|
a76379 |
- (void) get_directory_table_entry (pwd, strlen (pwd), TRUE);
|
|
|
a76379 |
+ (void) get_directory_table_entry (pwd, NULL, strlen (pwd), TRUE);
|
|
|
a76379 |
d = 1;
|
|
|
a76379 |
}
|
|
|
a76379 |
else
|
|
|
a76379 |
@@ -722,7 +723,7 @@ allocate_filenum (const char * pathname)
|
|
|
a76379 |
file = get_basename (pathname);
|
|
|
a76379 |
dir_len = file - pathname;
|
|
|
a76379 |
|
|
|
a76379 |
- dir = get_directory_table_entry (pathname, dir_len, FALSE);
|
|
|
a76379 |
+ dir = get_directory_table_entry (pathname, NULL, dir_len, FALSE);
|
|
|
a76379 |
|
|
|
a76379 |
/* Do not use slot-0. That is specifically reserved for use by
|
|
|
a76379 |
the '.file 0 "name"' directive. */
|
|
|
a76379 |
@@ -762,6 +763,7 @@ allocate_filename_to_slot (const char *
|
|
|
a76379 |
const char *file;
|
|
|
a76379 |
size_t dirlen;
|
|
|
a76379 |
unsigned int i, d;
|
|
|
a76379 |
+ const char *file0_dirname = dirname;
|
|
|
a76379 |
|
|
|
a76379 |
/* Short circuit the common case of adding the same pathname
|
|
|
a76379 |
as last time. */
|
|
|
a76379 |
@@ -836,7 +838,8 @@ allocate_filename_to_slot (const char *
|
|
|
a76379 |
file = filename;
|
|
|
a76379 |
}
|
|
|
a76379 |
|
|
|
a76379 |
- d = get_directory_table_entry (dirname, dirlen, num == 0);
|
|
|
a76379 |
+ d = get_directory_table_entry (dirname, file0_dirname, dirlen,
|
|
|
a76379 |
+ num == 0);
|
|
|
a76379 |
i = num;
|
|
|
a76379 |
|
|
|
a76379 |
if (! assign_file_to_slot (i, file, d))
|
|
|
a76379 |
diff -rup binutils.orig/gas/testsuite/gas/elf/elf.exp binutils-2.35.2/gas/testsuite/gas/elf/elf.exp
|
|
|
a76379 |
--- binutils.orig/gas/testsuite/gas/elf/elf.exp 2021-11-08 14:59:19.856524118 +0000
|
|
|
a76379 |
+++ binutils-2.35.2/gas/testsuite/gas/elf/elf.exp 2021-11-08 14:59:36.225418609 +0000
|
|
|
a76379 |
@@ -274,6 +274,7 @@ if { [is_elf_format] } then {
|
|
|
a76379 |
run_dump_test "dwarf2-18" $dump_opts
|
|
|
a76379 |
run_dump_test "dwarf2-19" $dump_opts
|
|
|
a76379 |
run_dump_test "dwarf-5-file0" $dump_opts
|
|
|
a76379 |
+ run_dump_test "dwarf-5-file0-2" $dump_opts
|
|
|
a76379 |
run_dump_test "dwarf-5-dir0" $dump_opts
|
|
|
a76379 |
run_dump_test "dwarf-4-cu" $dump_opts
|
|
|
a76379 |
run_dump_test "dwarf-5-cu" $dump_opts
|
|
|
a76379 |
|