<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - `-S -g` can emit a zero-length .debug_line section"
   href="https://bugs.llvm.org/show_bug.cgi?id=32574">32574</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>`-S -g` can emit a zero-length .debug_line section
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>paul_robinson@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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
---
<span class="quote">> tS.o:  file format ELF64-x86-64</span >
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
---
<span class="quote">>     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</span >
$</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>