https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100610
Bug ID: 100610 Summary: DWARF5, wrong include_directories[0] when building in / Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: simon.marchi at polymtl dot ca Target Milestone: --- If I build a trivial test file while in the /tmp directory: $ pwd /tmp $ cat test.c #include <stdio.h> #define FOO 2 int main() { return FOO; } $ /opt/gcc/git/bin/gcc -gdwarf-5 -g3 -O0 -o test test.c The include_directories table of .debug_line looks fine: $ readelf --debug-dump=rawline test The Directory Table (offset 0x22, lines 7, columns 1): Entry Name 0 (line_strp) (offset: 0x0): /tmp 1 (line_strp) (offset: 0xc): /usr/include 2 (line_strp) (offset: 0x19): /usr/include/bits 3 (line_strp) (offset: 0x2b): /usr/include/sys 4 (line_strp) (offset: 0x3c): /usr/include/gnu 5 (line_strp) (offset: 0x4d): /opt/gcc/git/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include 6 (line_strp) (offset: 0x85): /usr/include/bits/types The File Name Table (offset 0x44, lines 26, columns 2): Entry Dir Name 0 (udata) 0 (line_strp) (offset: 0x5): test.c 1 (udata) 0 (line_strp) (offset: 0x5): test.c Files #0 and #1 point to directory 0, which gives /tmp/test.c. However, if I move test.c in the root directory, at /test.c and move there: $ pwd / $ /opt/gcc/git/bin/gcc -gdwarf-5 -g3 -O0 -o /tmp/test test.c The Directory Table (offset 0x22, lines 7, columns 1): Entry Name 0 (line_strp) (offset: 0x9): /usr/include 1 (line_strp) (offset: 0x9): /usr/include 2 (line_strp) (offset: 0x16): /usr/include/bits 3 (line_strp) (offset: 0x28): /usr/include/sys 4 (line_strp) (offset: 0x39): /usr/include/gnu 5 (line_strp) (offset: 0x4a): /opt/gcc/git/lib/gcc/x86_64-pc-linux-gnu/12.0.0/include 6 (line_strp) (offset: 0x82): /usr/include/bits/types The File Name Table (offset 0x44, lines 26, columns 2): Entry Dir Name 0 (udata) 0 (line_strp) (offset: 0x0): test.c 1 (udata) 0 (line_strp) (offset: 0x0): test.c See the files #0 and #1. They point to directory #0, which is /usr/include. That makes it believe that the source file was at /usr/include/test.c. That looks wrong to me.