https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102481

            Bug ID: 102481
           Summary: Incorrect source file path in debuginfo for assembly
                    file specified with relative path
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: roc at ocallahan dot org
  Target Milestone: ---

Steps to reproduce:

$ cat > /tmp/test.S
.global foo
foo:
    ret
$ cd /tmp/obj
$ mkdir /tmp/obj
$ gcc -g -c - o test.o ../test.S
$ dwarfdump -i test.o

I get

UNIT<header overall offset = 0x00000000>:
< 0><0x0000000c>  DW_TAG_compile_unit
                    DW_AT_stmt_list             <.debug_line+0x00000000>
                    DW_AT_low_pc                0x00000000
                    DW_AT_high_pc               <offset-from-lowpc>1
                    DW_AT_name                  test.S
                    DW_AT_comp_dir              /tmp/obj
                    DW_AT_producer              GNU AS 2.37.50
                    DW_AT_language              DW_LANG_Mips_Assembler

This indicates the source file is at /tmp/obj/test.S, which is incorrect. If I
call the assembler directly, I get correct output:

$ as -g -o test.o ../test.S
$ dwarfdump -i test.o

UNIT<header overall offset = 0x00000000>:
< 0><0x0000000b>  DW_TAG_compile_unit
                    DW_AT_stmt_list             <.debug_line+0x00000000>
                    DW_AT_low_pc                0x00000000
                    DW_AT_high_pc               0x00000001
                    DW_AT_name                  ../test.S
                    DW_AT_comp_dir              /tmp/obj
                    DW_AT_producer              GNU AS 2.37.50
                    DW_AT_language              DW_LANG_Mips_Assembler

gcc version is 11.2.1 20210728 (Red Hat 11.2.1-1).

Reply via email to