[Bug ld/27016] x86-64: GOTPCREL relaxation with abs symbol and REX byte creates incorrect code

2020-12-04 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27016

H.J. Lu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
   Target Milestone|--- |2.36
 Resolution|--- |FIXED

--- Comment #6 from H.J. Lu  ---
Fixed for 2.36 and 2.35 branch.

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


[Bug ld/27016] x86-64: GOTPCREL relaxation with abs symbol and REX byte creates incorrect code

2020-12-04 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27016

--- Comment #5 from cvs-commit at gcc dot gnu.org  ---
The binutils-2_35-branch branch has been updated by H.J. Lu
:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e539c8303ff871dda6ea95c5ec3da9ea6f3609ae

commit e539c8303ff871dda6ea95c5ec3da9ea6f3609ae
Author: H.J. Lu 
Date:   Fri Dec 4 18:54:47 2020 -0800

x86-64: Convert load to mov only for GOTPCRELX relocations

Since converting load to mov needs to rewrite the REX byte and we don't
know if there is a REX byte with GOTPCREL relocation, do it only for
GOTPCRELX relocations.

bfd/

PR ld/27016
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Convert load
to mov only for GOTPCRELX relocations.

ld/

PR ld/27016
* testsuite/ld-x86-64/x86-64.exp: Run pr27016a and pr27016b.
* testsuite/ld-x86-64/pr27016a.d: New file.
* testsuite/ld-x86-64/pr27016a.s: Likewise.
* testsuite/ld-x86-64/pr27016b.d: Likewise.
* testsuite/ld-x86-64/pr27016b.s: Likewise.

(cherry picked from commit 7e45e7a9ab38ee904ca62ed9934e933fdb1d6e9c)

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


[Bug ld/27016] x86-64: GOTPCREL relaxation with abs symbol and REX byte creates incorrect code

2020-12-04 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=27016

--- Comment #4 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by H.J. Lu :

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7e45e7a9ab38ee904ca62ed9934e933fdb1d6e9c

commit 7e45e7a9ab38ee904ca62ed9934e933fdb1d6e9c
Author: H.J. Lu 
Date:   Fri Dec 4 18:54:47 2020 -0800

x86-64: Convert load to mov only for GOTPCRELX relocations

Since converting load to mov needs to rewrite the REX byte and we don't
know if there is a REX byte with GOTPCREL relocation, do it only for
GOTPCRELX relocations.

bfd/

PR ld/27016
* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Convert load
to mov only for GOTPCRELX relocations.

ld/

PR ld/27016
* testsuite/ld-x86-64/x86-64.exp: Run pr27016a and pr27016b.
* testsuite/ld-x86-64/pr27016a.d: New file.
* testsuite/ld-x86-64/pr27016a.s: Likewise.
* testsuite/ld-x86-64/pr27016b.d: Likewise.
* testsuite/ld-x86-64/pr27016b.s: Likewise.

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


[Bug ld/27016] x86-64: GOTPCREL relaxation with abs symbol and REX byte creates incorrect code

2020-12-04 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27016

H.J. Lu  changed:

   What|Removed |Added

 Status|WAITING |NEW

--- Comment #3 from H.J. Lu  ---
Never mind. I can reproduce it.

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


[Bug ld/27016] x86-64: GOTPCREL relaxation with abs symbol and REX byte creates incorrect code

2020-12-04 Thread hjl.tools at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=27016

H.J. Lu  changed:

   What|Removed |Added

 Status|NEW |WAITING
 CC||hjl.tools at gmail dot com

--- Comment #2 from H.J. Lu  ---
I can't reproduce it with binutils master branch:

[hjl@gnu-cfl-2 pr27016]$ cat pr27016a.s
.text
.comm   global_int,4,4
.globl  main
.type   main, @function
main:
.cfi_startproc
pushq   %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq%rsp, %rbp
.cfi_def_cfa_register 6
movqthesym@GOTPCREL(%rip), %r11
movl(%r11), %eax
leal1(%rax), %edx
movqthesym@GOTPCREL(%rip), %r11
movl%edx, (%r11)
movl$0, %eax
popq%rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.size   main, .-main
.section.note.GNU-stack,"",@progbits
[hjl@gnu-cfl-2 pr27016]$ cat pr27016b.s
.globl thesym
thesym = 0x40402c

.section.note.GNU-stack,"",@progbits
[hjl@gnu-cfl-2 pr27016]$ make
as -mrelax-relocations=no  -o pr27016a.o pr27016a.s
as -mrelax-relocations=no  -o pr27016b.o pr27016b.s
/usr/gcc-9.3.1-x32/bin/gcc -B./ -o x pr27016a.o pr27016b.o -Wl,-R,.
objdump -dwr pr27016a.o

pr27016a.o: file format elf64-x86-64


Disassembly of section .text:

 :
   0:   55  push   %rbp
   1:   48 89 e5mov%rsp,%rbp
   4:   4c 8b 1d 00 00 00 00mov0x0(%rip),%r11# b 
7: R_X86_64_GOTPCRELthesym-0x4
   b:   41 8b 03mov(%r11),%eax
   e:   8d 50 01lea0x1(%rax),%edx
  11:   4c 8b 1d 00 00 00 00mov0x0(%rip),%r11# 18   
14: R_X86_64_GOTPCREL   thesym-0x4
  18:   41 89 13mov%edx,(%r11)
  1b:   b8 00 00 00 00  mov$0x0,%eax
  20:   5d  pop%rbp
  21:   c3  ret
objdump --disassemble=main x

x: file format elf64-x86-64


Disassembly of section .init:

Disassembly of section .text:

00400596 :
  400596:   55  push   %rbp
  400597:   48 89 e5mov%rsp,%rbp
  40059a:   4c 8d 1d 8b 3a 00 00lea0x3a8b(%rip),%r11#
40402c 
  4005a1:   41 8b 03mov(%r11),%eax
  4005a4:   8d 50 01lea0x1(%rax),%edx
  4005a7:   4c 8d 1d 7e 3a 00 00lea0x3a7e(%rip),%r11#
40402c 
  4005ae:   41 89 13mov%edx,(%r11)
  4005b1:   b8 00 00 00 00  mov$0x0,%eax
  4005b6:   5d  pop%rbp
  4005b7:   c3  ret

Disassembly of section .fini:
[hjl@gnu-cfl-2 pr27016]$

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


[Bug ld/27016] x86-64: GOTPCREL relaxation with abs symbol and REX byte creates incorrect code

2020-12-04 Thread matz at suse dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=27016

--- Comment #1 from Michael Matz  ---
This also happen in 2.35 of course.

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