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

            Bug ID: 65846
           Summary: Optimize data access in PIE with copy reloc
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: evstupac at gmail dot com
            Target: i386-elf

With linker which supports copy relocation in PIE:

https://sourceware.org/bugzilla/show_bug.cgi?id=18289

For

extern int glob_a;
int foo ()
{
  return glob_a;
}

compiler can optimize it from

    call    __x86.get_pc_thunk.ax
    addl    $_GLOBAL_OFFSET_TABLE_, %eax
    movl    glob_a@GOT(%eax), %eax
    movl    (%eax), %eax
    ret

to

    call    __x86.get_pc_thunk.ax
    addl    $_GLOBAL_OFFSET_TABLE_, %eax
    movl    glob_a@GOTOFF(%eax), %eax
    ret

Reply via email to