Issue 149957
Summary [Clang] Inconsistency Between Assembly Code and Debug Information
Labels clang
Assignees
Reporter DropsWJL
    **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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to