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

            Bug ID: 17641
           Summary: [x86-64] Convert load to lea
           Product: binutils
           Version: 2.26 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at google dot com
          Reporter: hjl.tools at gmail dot com
                CC: ian at airs dot com

For x86-64, gold should convert

   mov foo@GOTPCREL(%rip), %reg

to

   lea foo(%rip), %reg

if foo is a local symbol, like ld:

[hjl@gnu-6 lea-4]$ cat lea2.s
    .text
    .type    foo, @function
foo:
    ret
    .size    foo, .-foo
    .text
    .globl    bar
    .type    bar, @function
bar:
    movq    foo@GOTPCREL(%rip), %rax
    .size    bar, .-bar
[hjl@gnu-6 lea-4]$ gcc -c lea2.s
[hjl@gnu-6 lea-4]$ ld -shared lea2.o
[hjl@gnu-6 lea-4]$ objdump -dw a.out 

a.out:     file format elf64-x86-64


Disassembly of section .text:

00000000000001c5 <foo>:
 1c5:    c3                       retq   

00000000000001c6 <bar>:
 1c6:    48 8d 05 f8 ff ff ff     lea    -0x8(%rip),%rax        # 1c5 <foo>
[hjl@gnu-6 lea-4]$

-- 
You are receiving this mail because:
You are on the CC list for the bug.

_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to