<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </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 --- - DWARF debug info has overlapping, invalid line information"
   href="http://llvm.org/bugs/show_bug.cgi?id=18790">18790</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DWARF debug info has overlapping, invalid line information
          </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>FreeBSD
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </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>yuri@tsoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=12038" name="attach_12038" title="testcase">attachment 12038</a> <a href="attachment.cgi?id=12038&action=edit" title="testcase">[details]</a></span>
testcase

I am attaching the testcase which generates wrong debug line information in
elf.

Sources: h.bc and x.bc

Script to run (also included in the testcase):
llvm-link h.bc x.bc > all.bc
llc -filetype=obj all.bc
objdump -D all.o > all.asm
dwarfdump all.o > all.dwarf

Description:
ELF all.o in its .text segment has 2 areas with line information:
0x10-0x1a with the source file z/a.xxx (10 bytes)
0x40-0x41 with the source file z/b.xxx (1 byte)

all.dwarf shows this line information:
<pc>        [row,col] NS BB ET PE EB IS= DI= uri: "filepath"
0x00000010  [ 651, 0] NS uri: "z/a.xxx"
0x00000010  [ 652, 5] NS PE
0x00000018  [ 654, 0] NS
0x00000041  [ 654, 0] NS ET

<pc>        [row,col] NS BB ET PE EB IS= DI= uri: "filepath"
0x00000040  [   2, 0] NS uri: "z/b.xxx"
0x00000040  [   3, 0] NS PE
0x00000041  [   3, 0] NS ET

The z/a.xxx section above ends at the wrong offset 0x41, and overlaps the
second section, which according to the DWARF info also ends at 0x41

As a result, 'addr2line -e all.o 0x40' command returns wrong line
'z/a.xxx:654', and it should return 'z/b.xxx:3'.

I also traced this in debugger in addr2line. If in debugger to set 'found=0'
after the line dwarf2.c:3660, it will find the correct line z/b.xxx:3 for
offset 0x40. The first cycle erroneously finds the line in z/a.xxx due to this
overlap.


rev.200186</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>