[Bug gold/14858] New: X32 TLS relocations are incorrectly handled

2012-11-19 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=14858

 Bug #: 14858
   Summary: X32 TLS relocations are incorrectly handled
   Product: binutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: gold
AssignedTo: i...@airs.com
ReportedBy: hjl.to...@gmail.com
CC: ccout...@google.com
Classification: Unclassified


With GCC 4.7 on x32, gold causes:

FAIL: gcc.dg/torture/tls/run-ld.c  -O1  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O2  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -fomit-frame-pointer  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -g  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -Os  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O1  -fpic  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O2  -fpic  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -fomit-frame-pointer  -fpic  execution
test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -g  -fpic  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -Os  -fpic  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O1  -fPIC  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O2  -fPIC  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -fomit-frame-pointer  -fPIC  execution
test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -g  -fPIC  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -Os  -fPIC  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O1  -pie -fpie  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O2  -pie -fpie  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -fomit-frame-pointer  -pie -fpie 
execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -g  -pie -fpie  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -Os  -pie -fpie  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O1  -pie -fPIE  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O2  -pie -fPIE  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -fomit-frame-pointer  -pie -fPIE 
execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O3 -g  -pie -fPIE  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -Os  -pie -fPIE  execution test
FAIL: gcc.dg/torture/tls/run-ld.c  -O2 -flto -fno-use-linker-plugin
-flto-partition=none  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O1  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O2  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O3 -fomit-frame-pointer  -fpic 
execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O3 -g  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -Os  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O1  -fPIC  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O2  -fPIC  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O3 -fomit-frame-pointer  -fPIC 
execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -O3 -g  -fPIC  execution test
FAIL: gcc.dg/torture/tls/thr-init-1.c  -Os  -fPIC  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O1  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O2  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O3 -fomit-frame-pointer  -fpic 
execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O3 -g  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -Os  -fpic  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O1  -fPIC  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O2  -fPIC  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O3 -fomit-frame-pointer  -fPIC 
execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -O3 -g  -fPIC  execution test
FAIL: gcc.dg/torture/tls/thr-init-2.c  -Os  -fPIC  execution test

BFD linker is OK.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gold/14858] X32 TLS relocations are incorrectly handled

2012-11-19 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=14858

--- Comment #1 from H.J. Lu  2012-11-20 04:44:19 
UTC ---
Input relocation is:

 :
   0:53   push   %rbx
   1:48 8d 3d 00 00 00 00 lea0x0(%rip),%rdi# 8 
   4: R_X86_64_TLSLDtls_ld-0x4
   8:e8 00 00 00 00   callq  d 9: R_X86_64_PC32   
__tls_get_addr-0x4
   d:48 89 c3 mov%rax,%rbx
  10:8b 83 00 00 00 00mov0x0(%rbx),%eax12:
R_X86_64_DTPOFF32tls_ld
  16:03 83 00 00 00 00add0x0(%rbx),%eax18:
R_X86_64_DTPOFF32tls_ld2
  1c:5b   pop%rbx
  1d:c3   retq   

Gold output is:

004004d0 :
  4004d0:53   push   %rbx
  4004d1:66 66 66 64 48 8b 04 25 00 00 00 00 data32 data32 data32 mov
%fs:0x0,%rax
  4004dd:48 89 c3 mov%rax,%rbx
  4004e0:8b 83 fc ff ff ffmov-0x4(%rbx),%eax
  4004e6:03 83 f8 ff ff ffadd-0x8(%rbx),%eax
  4004ec:5b   pop%rbx
  4004ed:c3   retq

The correct one should be:

  4004d0:53   push   %rbx
  4004d1:0f 1f 40 00  nopl   0x0(%rax)
  4004d5:64 8b 04 25 00 00 00 00 mov%fs:0x0,%eax
  4004dd:48 89 c3 mov%rax,%rbx
  4004e0:8b 83 fc ff ff ffmov-0x4(%rbx),%eax
  4004e6:03 83 f8 ff ff ffadd-0x8(%rbx),%eax
  4004ec:5b   pop%rbx
  4004ed:c3   retq

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gold/14858] X32 TLS relocations are incorrectly handled

2012-11-19 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=14858

H.J. Lu  changed:

   What|Removed |Added

URL||http://sourceware.org/ml/bi
   ||nutils/2012-11/msg00288.htm
   ||l

--- Comment #2 from H.J. Lu  2012-11-20 04:50:13 
UTC ---
A patch is posted at

http://sourceware.org/ml/binutils/2012-11/msg00288.html

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gold/14858] X32 TLS relocations are incorrectly handled

2012-11-19 Thread cvs-commit at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=14858

--- Comment #3 from cvs-commit at gcc dot gnu.org  2012-11-20 05:56:11 UTC ---
CVSROOT:/cvs/src
Module name:src
Changes by:h...@sourceware.org2012-11-20 05:56:06

Modified files:
gold   : ChangeLog x86_64.cc 

Log message:
Fix TLS to LE optimization for x32

PR gold/14858
* x86_64.cc (Relocate::tls_ld_to_le): Support x32.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&r1=1.995&r2=1.996
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/x86_64.cc.diff?cvsroot=src&r1=1.160&r2=1.161

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gold/14858] X32 TLS relocations are incorrectly handled

2012-11-19 Thread cvs-commit at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=14858

--- Comment #4 from cvs-commit at gcc dot gnu.org  2012-11-20 05:58:00 UTC ---
CVSROOT:/cvs/src
Module name:src
Branch: binutils-2_23-branch
Changes by:h...@sourceware.org2012-11-20 05:57:54

Modified files:
gold   : ChangeLog x86_64.cc 

Log message:
Fix TLS LD to LE optimization for x32

PR gold/14858
* x86_64.cc (Relocate::tls_ld_to_le): Support x32.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.928.2.11&r2=1.928.2.12
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gold/x86_64.cc.diff?cvsroot=src&only_with_tag=binutils-2_23-branch&r1=1.153.2.1&r2=1.153.2.2

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gold/14858] X32 TLS relocations are incorrectly handled

2012-11-19 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=14858

H.J. Lu  changed:

   What|Removed |Added

Version|unspecified |2.23

--- Comment #5 from H.J. Lu  2012-11-20 05:59:38 
UTC ---
Fixed in trunk and 2.23.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gold/14858] X32 TLS relocations are incorrectly handled

2012-11-19 Thread hjl.tools at gmail dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=14858

H.J. Lu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED

--- Comment #6 from H.J. Lu  2012-11-20 06:00:23 
UTC ---
Fixed.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gas/14859] New: Redundant ASP generated for jecxz

2012-11-19 Thread kyukhin at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=14859

 Bug #: 14859
   Summary: Redundant ASP generated for jecxz
   Product: binutils
   Version: 2.24 (HEAD)
Status: NEW
  Severity: normal
  Priority: P2
 Component: gas
AssignedTo: unassig...@sourceware.org
ReportedBy: kyuk...@gcc.gnu.org
Classification: Unclassified


-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gas/14859] Redundant ASP generated for jecxz

2012-11-19 Thread kyukhin at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=14859

--- Comment #1 from Kirill Yukhin  2012-11-20 
06:53:51 UTC ---
Got following problem if jecxz.
Having following test:
jecxz 1
jrcxz 1
je 1

objdump is:
 <.text>:
   0:   67 67 e3 00 addr64 jecxz 0x4
   4:   e3 00   jrcxz  0x6
   6:   0f 84 00 00 00 00   je 0xc

You can see that ASP is doubled for jecxz.

Seems like a bug.

Possible fix would be:
$ git diff opcodes/i386-opc.tbl
diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
index f2b2f14..e7001e9 100644
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -389,8 +389,7 @@ jg, 1, 0x7f, None, 1, 0,
Jump|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf,

 // jcxz vs. jecxz is chosen on the basis of the address size prefix.
 jcxz, 1, 0xe3, None, 1, CpuNo64,
JumpByte|Size16|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {
Disp8|Disp16|Disp32 }
-jecxz, 1, 0xe3, None, 1, CpuNo64,
JumpByte|Size32|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {
Disp8|Disp16|Disp32 }
-jecxz, 1, 0x67e3, None, 2, Cpu64,
JumpByte|Size32|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {
Disp8|Disp32|Disp32S }
+jecxz, 1, 0xe3, None, 1, 0,
JumpByte|Size32|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf, {
Disp8|Disp16|Disp32 }
 jrcxz, 1, 0xe3, None, 1, Cpu64,
JumpByte|Size64|No_bSuf|No_wSuf|No_lSuf|No_sSuf|No_qSuf|No_ldSuf|NoRex64, {
Disp8|Disp32|Disp32S }

 // The loop instructions also use the address size prefix to select

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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


[Bug gas/14859] Redundant ASP generated for jecxz

2012-11-19 Thread kyukhin at gcc dot gnu.org
http://sourceware.org/bugzilla/show_bug.cgi?id=14859

Kirill Yukhin  changed:

   What|Removed |Added

 CC||hjl.tools at gmail dot com,
   ||kyukhin at gcc dot gnu.org

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
--- 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