https://bugs.llvm.org/show_bug.cgi?id=32574

            Bug ID: 32574
           Summary: `-S -g` can emit a zero-length .debug_line section
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

If you compile a source with no functions (or that otherwise doesn't emit
any instructions with line info attached, presumably) to assembler source,
you get an empty .debug_line section.  Compiling to an object file directly
gets you a .debug_line section with a header and no line table.

An empty section is bad, because the compilation unit header has a reference
to the line table section.  If the line section is empty, the reference can
end up pointing to a different CU's line table, which seems bad.

$ cat t.c
extern int i;
$ clang -c -g t.c -o t.o
$ clang -c -g t.c -o tS.s -S
$ clang -c tS.s -o tS.o
$ llvm-dwarfdump t.o > t.dump
$ llvm-dwarfdump tS.o > tS.dump
$ diff t.dump tS.dump
1c1
< t.o:  file format ELF64-x86-64
---
> tS.o: file format ELF64-x86-64
39,58c39,46
<     total_length: 0x00000019
<          version: 2
<  prologue_length: 0x00000013
<  min_inst_length: 1
<  default_is_stmt: 1
<        line_base: -5
<       line_range: 14
<      opcode_base: 13
< standard_opcode_lengths[DW_LNS_copy] = 0
< standard_opcode_lengths[DW_LNS_advance_pc] = 1
< standard_opcode_lengths[DW_LNS_advance_line] = 1
< standard_opcode_lengths[DW_LNS_set_file] = 1
< standard_opcode_lengths[DW_LNS_set_column] = 1
< standard_opcode_lengths[DW_LNS_negate_stmt] = 0
< standard_opcode_lengths[DW_LNS_set_basic_block] = 0
< standard_opcode_lengths[DW_LNS_const_add_pc] = 0
< standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
< standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
< standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
< standard_opcode_lengths[DW_LNS_set_isa] = 1
---
>     total_length: 0x00000000
>          version: 0
>  prologue_length: 0x00000000
>  min_inst_length: 0
>  default_is_stmt: 0
>        line_base: 0
>       line_range: 0
>      opcode_base: 0
$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to