<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68592>68592</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Crash / incorrect .debug_line when assembling file with .include directive
</td>
</tr>
<tr>
<th>Labels</th>
<td>
debuginfo
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
john-brawn-arm
</td>
</tr>
</table>
<pre>
If we have the following in tmp.s
```
.text
mov x0, #0
.include "include.s"
```
and the following in include.s
```
mov x0, #1
```
then ``clang --target=aarch64-none-elf -c -g tmp.s`` crashes with
```
clang: ../src/llvm-project/llvm/lib/Support/SourceMgr.cpp:109: unsigned int llvm::SourceMgr::SrcBuffer::getLineNumberSpecialized(const char*) const [with T = unsigned char]: Assertion `Ptr >= BufStart && Ptr <= Buffer->getBufferEnd()' failed.
```
If I insert blank lines at the start and end of of include.s
```
mov x0, #1
```
then an object is generated but looking at the .debug_line output of ``llvm-dwarfdump --all`` it has
```
file_names[ 1]:
name: "tmp.s"
dir_index: 0
mod_time: 0x00000000
length: 0x00000000
Address Line Column File ISA Discriminator Flags
------------------ ------ ------ ------ --- ------------- -------------
0x0000000000000000 2 0 1 0 0 is_stmt
0x0000000000000004 2 0 1 0 0 is_stmt
0x0000000000000008 2 0 1 0 0 is_stmt end_sequence
```
the instruction at address 0x4 is the mov from include.s, but the line information places it in tmp.s.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVV9vrLYT_TTmZQRizUKWBx422awU6ferKqXvK2MP4HuNTf0nm_bTVzakSXo3V5U6Wi2MPTM-Y59jmHNy1Igdqe9JfcpY8JOx3Tcz6by37KpzZuesN-KP7mmAK8LEXhD8hDAYpcxV6hGkBj8vhSPliZRH0pTbL7mwWeHx1X8ems0LvJaEPgCh1T_DpeYqCARC6fZaOELpzTWYFj9Ces_6GaxPGHY3Q_2EGtYBrpgeIc89syN6Up0Ys3xq9rk2G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