[patch] Deal with full path in .file 0 directive
Eric Botcazou
botcazou@adacore.com
Sat Nov 6 11:55:55 GMT 2021
Hi,
after https://sourceware.org/pipermail/binutils/2021-September/117880.html,
Gas uses the directory part, if present, of the .file 0 directive to set entry
0 of the directory table in DWARF 5, which represents the "current directory".
Now Gas also uses the file part of the same directive to set entry 0 of the
file table, which represents the "current compilation file". But the latter
need not be located in the former so GCC will use a full path in the file part
when it is passed a full path:
gcc -c /full/path/test.c -save-temps
yields:
.file 0 "/current/directory" "/full/path/test.c"
in the assembly file and:
The Directory Table (offset 0x22, lines 2, columns 1):
Entry Name
0 (indirect line string, offset: 0x25): /current/directory
1 (indirect line string, offset: 0x38): /full/path
The File Name Table (offset 0x30, lines 2, columns 2):
Entry Dir Name
0 0 (indirect line string, offset: 0x43): /full/path/test.c
in the object file. Note the full path and the questionable Dir value in the
0 entry of the file table.
The proposed change is to deal with a full path in the file part of the .file
0 directive, so as to yield:
The Directory Table (offset 0x22, lines 2, columns 1):
Entry Name
0 (indirect line string, offset: 0x25): /current/directory
1 (indirect line string, offset: 0x38): /full/path
The File Name Table (offset 0x30, lines 2, columns 2):
Entry Dir Name
0 1 (indirect line string, offset: 0x43): test.c
in the object file instead. Tested on x86-64/Linux, OK for the trunk?
2021-11-06 Eric Botcazou <ebotcazou@adacore.com>
gas/
* doc/as.texi (File): Update description of .file 0 directive.
* dwarf2dbg.c (get_directory_table_entry): Remove obsolete comment
and pass file0_dirname in recursive call.
(allocate_filename_to_slot): Deal with a full path in the file name
if the index number is 0.
* testsuite/gas/elf/dwarf-5-file0.d: Fix pasto.
* testsuite/gas/elf/dwarf-5-file0-2.d: Likewise.
* testsuite/gas/elf/dwarf-5-file0-3.d: New file.
* testsuite/gas/elf/dwarf-5-file0-3.s: Likewise.
* testsuite/gas/elf/elf.exp: Run dwarf-5-file0-3.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 8097 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20211106/a2ff3f2a/attachment-0001.bin>
More information about the Binutils
mailing list