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

            Bug ID: 95841
           Summary: Bad location expression for TLS variable
           Product: gcc
           Version: 9.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: horsley1953 at gmail dot com
  Target Milestone: ---

In the debuginfo for glibc on fedora 31, I found a location list for a TLS
variable which makes no sense to me. Here is a dump of the DIE:

DIE (0x6d7af4): DW_TAG_compile_unit
   DIE (0x6e4831): DW_TAG_subprogram
      DIE (0x6e4854): DW_TAG_variable
         DW_AT_location(sec_offset) PCrange(0x7f1d329ba0f0-0x7f1d329ba129):
DW_OP_GNU_push_tls_address DW_OP_const8u 80
PCrange(0x7f1d329ba129-0x7f1d329ba1bb): DW_OP_reg6
PCrange(0x7f1d329ba1cb-0x7f1d329ba274): DW_OP_reg6
         DW_AT_name(strp) "replaced_arena"
         DW_AT_decl_column(data1) 0xa
         DW_AT_decl_file(data1) 0x1
         DW_AT_decl_line(data2) 0x2f7
         DW_AT_type(ref4) 0x6dc0ca
         DW_AT_GNU_locviews(sec_offset) 0x10b40e
Previous DIE: 0x6e4831
Next DIE: 0x6e4869

The location expression for the first range has the push_tls operator as the
first thing in the expression, but there is supposed to be a value on the stack
already. It is like the expression is backwards (the variable does appear to be
located at offset 80 in the TLS block).

This is on fedora 31 x86_64:

glibc-common-2.30-11.fc31.x86_64
glibc-2.30-11.fc31.x86_64
glibc-debuginfo-2.30-11.fc31.x86_64

If I compile my own test program with __thread variables, I see their location
expressions as I'd expect them with the constant first, then the push_tls
operator.

The variable above is in the get_free_list() function of arena.c in the malloc
code from glibc.

Reply via email to