<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/149957>149957</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Inconsistency Between Assembly Code and Debug Information
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          DropsWJL
      </td>
    </tr>
</table>

<pre>
    **Clang version**: 20.1.8 (other versions also exhibit the same issue)

Here is a sample code snippet:
```c
#include <stdlib.h>
void foo() {}
int main() {
    atexit(foo);   
    return 0;
}
```
The executable `demo` is compiled using the command `clang main.c -g -o demo`.

I disassembled it using `objdump` and extracted the debug information using `llvm-dwarfdump`.
In the .text section, the `atexit` function is present (I believe Clang inlined it into .text):
```
0000000000001180 <atexit>:
    1180:       f3 0f 1e fa             endbr64
    1184:       48 8b 15 85 2e 00 00    mov    0x2e85(%rip),%rdx        # 4010 <__dso_handle>
    118b:       31 f6                   xor    %esi,%esi
    118d:       e9 9e fe ff ff          jmp    1030 <__cxa_atexit@plt>
```

However, the debug information does not include any details about the `atexit` function, making it impossible to locate the `atexit` function during debugging.

This issue might not be limited to `atexit`—other library functions could also be affected.

I believe debug information should include details related to the `atexit` function, since it does exist in the .text section and is a function explicitly used in the source code.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VU1v4zgM_TXKhWggy3ZiH3JI2ym2iz0OsMdCH3SsWVkyJDnj_PuFJDftTrFjGEgs8ZHU4yPFQ9AXi3gi7SNpn3d8iaPzp2fv5vD3n3_thFO3E2Fnws5PhtsLXNEH7WxZIvUZGN1X-w4I61wc0b8bBOAmOMB11EJHiCNC4BOCDmFBwnpCz4Se_0CfloCnzdkgSKcQgtXzjJHUyYQcaHll-mC1ttIsCoHUTyEqo8V-JPU3Qs9XpxUMzhHWEdYDOT6S4zOhZ20jTFzbT-v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