[llvm-bugs] [Bug 24964] New: llvm uses GOT to access locally defined variable for PIE

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 28 05:30:03 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=24964

            Bug ID: 24964
           Summary: llvm uses GOT to access locally defined variable for
                    PIE
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: hjl.tools at gmail.com
                CC: llvm-bugs at lists.llvm.org,
                    michael.m.kuperstein at intel.com
    Classification: Unclassified

On x86-64, llvm uses GOT to access locally defined variable for PIE.
GOT shouldn't be needed:

[hjl at gnu-32 bin]$ cat x.c
int i;

int
foo (void)
{
  return i;
}
[hjl at gnu-32 bin]$ ./clang -S -O2 -fPIE -m64 x.c
[hjl at gnu-32 bin]$ cat x.s
    .text
    .file    "x.c"
    .globl    foo
    .align    16, 0x90
    .type    foo, at function
foo:                                    # @foo
    .cfi_startproc
# BB#0:
    movq    i at GOTPCREL(%rip), %rax
    movl    (%rax), %eax
    retq
.Lfunc_end0:
    .size    foo, .Lfunc_end0-foo
    .cfi_endproc

    .type    i, at object               # @i
    .comm    i,4,4
[hjl at gnu-32 bin]$ gcc  -S -O2 -fPIE -m64 x.c
[hjl at gnu-32 bin]$ cat x.s
    .file    "x.c"
    .section    .text.unlikely,"ax", at progbits
.LCOLDB0:
    .text
.LHOTB0:
    .p2align 4,,15
    .globl    foo
    .type    foo, @function
foo:
.LFB0:
    .cfi_startproc
    movl    i(%rip), %eax
    ret
    .cfi_endproc
.LFE0:
    .size    foo, .-foo
    .section    .text.unlikely
.LCOLDE0:
    .text
.LHOTE0:
    .comm    i,4,4
[hjl at gnu-32 bin]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150928/2a0895ec/attachment.html>


More information about the llvm-bugs mailing list