https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119531

            Bug ID: 119531
           Summary: GCC generates incomplete DWARF debug information for
                    TLS variables on aarch64
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hmeyer.eu at gmail dot com
  Target Milestone: ---

Created attachment 60918
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=60918&action=edit
Debug information for aarch64 (no location) and for comparison x86_64

Debug information for TLS variables is missing the DW_AT_location attribute on
aarch64.
I first noticed with GCC 13 when trying to print glibc tcache, I verified with
trunk on Compiler Explorer, it is specific to aarch64, does not happen for
x86_64, i686, armhf.
I have also reproduced the problem with GCC 10.2.1.

The variables shows up with correct TLS offset in the ELF symtab. 
The location attribute is the only way to specify in DWARF that this is a
TLS variable.

Minimal example (attachments are created on Ubuntu 24.10/GCC 14.2.0)

echo "thread_local int tls_var;" > tls_example.cpp
aarch64-linux-gnu-g++ -g -c tls_example.cpp
aarch64-linux-gnu-readelf --debug-dump=info tls_example.o

GDB displays "optimized away" for such variables without a location
attribute.

Reply via email to