[Bug debug/82631] New: Bogus DW_AT_GNU_call_site_value

rafael.espindola at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Oct 20 01:40:00 GMT 2017


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

            Bug ID: 82631
           Summary: Bogus DW_AT_GNU_call_site_value
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rafael.espindola at gmail dot com
  Target Milestone: ---

Created attachment 42408
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42408&action=edit
testcase

If the attached file is compiled with "g++ test.cpp -fPIC  -g  -O3 -m32", the
produced dwarf has

DW_AT_location              len 0x0001: 52: DW_OP_reg2

Which means an argument is begin passed in edx. It also has

DW_AT_GNU_call_site_value   len 0x000e: 730003000000001c030000000022:
DW_OP_breg3+0 DW_OP_addr 0x00000000 DW_OP_minus DW_OP_addr 0x00000000
DW_OP_plus

The first DW_op_addr is

 .long   _GLOBAL_OFFSET_TABLE_

and the second one is

.long   .LC0

The first line actually produces a R_386_GOTPC, so it looks like the expression
is computing

(ebx - (GOTEND - PC)) + LC0

The code using LC0 is

_Z3fn3Pi:
        pushl   %esi
        pushl   %ebx
        xorl    %ebx, %ebx
        call    __x86.get_pc_thunk.si
        addl    $_GLOBAL_OFFSET_TABLE_, %esi
        subl    $12, %esp
        movl    24(%esp), %eax
        leal    .LC0@GOTOFF(%esi), %edx
        pushl   %ebx
        movl    %esi, %ebx
        pushl   %eax
        call    _ZL3fn2PiPKc1C.constprop.0

So at the point of the call ebx is GOTEND. This suggests that gcc is actually
trying to compute

(ebx - GOTEND) + LC0 but getting R_386_GOTPC wrong. But the expression also
simplifies to just LC0, which is what is actually in edx.


More information about the Gcc-bugs mailing list