This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Committed: fix R_CRIS_32_DTPREL
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: binutils at sourceware dot org
- Date: Mon, 19 Oct 2009 18:38:00 +0200
- Subject: Committed: fix R_CRIS_32_DTPREL
A thinko, exposed by debug-patches for TLS. R_CRIS_32_DTPREL
and R_CRIS_16_DTPREL were incorrectly calculated for
executables. The bug trigs for an executable with thread
variables and debug info or code compiled with -fPIC/-fpic and
static thread variables (or explicitly using the local-dynamic
model).
Basically, for non-DSO's, R_CRIS_32_DTPREL was treated as a
synonym for R_CRIS_32_TPREL (sym=tp+reloc; used in the
initial-exec and local-exec models). That can't work, so
there's no compatibility issue. I ran the (e)glibc test-suite
as well as the binutils test-suites, the latter for cris-elf
(the preferred target there; tests are pruned for other
sub-targets). Committed to trunk and the 2.20-branch.
bfd:
* elf32-cris.c (cris_elf_relocate_section) <case R_CRIS_32_DTPREL>:
Don't subtract the size of the TLS block for non-shared objects
from the relocation.
ld/testsuite:
* ld-cris/tls-e-20.d, ld-cris/tls-e-20a.d, ld-cris/tls-e-22.d,
ld-cris/tls-e-80.d, ld-cris/tls-e-dtpoffd1.d,
ld-cris/tls-e-dtpoffd3.d, ld-cris/tls-ldgde-14.d,
ld-cris/tls-ldgde-15.d, ld-cris/tls-ldgdex-14.d,
ld-cris/tls-ldgdex-15.d: Adjust for change in non-shared
R_CRIS_32_DTPREL and R_CRIS_16_DTPREL relocations.
Index: elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.104
diff -p -u -r1.104 elf32-cris.c
--- elf32-cris.c 25 Mar 2009 03:03:40 -0000 1.104
+++ elf32-cris.c 19 Oct 2009 16:04:19 -0000
@@ -1690,15 +1690,10 @@ cris_elf_relocate_section (output_bfd, i
= -elf_cris_hash_table (info)->dtpmod_refcount;
}
- /* The thread-based offset to the local symbol is the
- relocation.
- For the executable, TLS data begins at the thread pointer plus
- the negative size of the TLS data. For a DSO, that's part of
- the module TLS offset. */
+ /* The relocation is the offset from the start of the module
+ TLS block to the (local) symbol. */
relocation -= elf_hash_table (info)->tls_sec == NULL
- ? 0 : (elf_hash_table (info)->tls_sec->vma
- + (info->shared
- ? 0 : elf_hash_table (info)->tls_size));
+ ? 0 : elf_hash_table (info)->tls_sec->vma;
break;
case R_CRIS_32_GD:
Index: ld-cris/tls-e-20.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-e-20.d,v
retrieving revision 1.5
diff -p -u -r1.5 tls-e-20.d
--- ld-cris/tls-e-20.d 24 Sep 2009 15:56:51 -0000 1.5
+++ ld-cris/tls-e-20.d 19 Oct 2009 16:18:56 -0000
@@ -64,7 +64,7 @@ Disassembly of section \.text:
80098: 6fae 1800 0000 move\.d 18 <x2\+0x10>,\$r10
#...
000800a0 <tlsdsofn>:
- 800a0: 6fae f4ff ffff move\.d 0xfffffff4,\$r10
+ 800a0: 6fae 0000 0000 move\.d 0 <x>,\$r10
#...
000800a8 <tlsdsofn10>:
800a8: 6fae 1400 0000 move\.d 14 <x2\+0xc>,\$r10
Index: ld-cris/tls-e-20a.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-e-20a.d,v
retrieving revision 1.6
diff -p -u -r1.6 tls-e-20a.d
--- ld-cris/tls-e-20a.d 24 Sep 2009 15:56:51 -0000 1.6
+++ ld-cris/tls-e-20a.d 19 Oct 2009 16:18:56 -0000
@@ -102,7 +102,7 @@ Disassembly of section \.text:
#...
000800cc <tlsdsofn>:
- 800cc: 6fae f4ff ffff move\.d 0xfffffff4,\$r10
+ 800cc: 6fae 8000 0000 move\.d 80 <x>,\$r10
#...
000800d4 <tlsdsofn10>:
Index: ld-cris/tls-e-22.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-e-22.d,v
retrieving revision 1.2
diff -p -u -r1.2 tls-e-22.d
--- ld-cris/tls-e-22.d 27 Jan 2009 07:05:47 -0000 1.2
+++ ld-cris/tls-e-22.d 19 Oct 2009 16:18:56 -0000
@@ -35,5 +35,5 @@ Disassembly of section \.text:
80094: 41b2 moveq 1,\$r11
#...
00080098 <tlsdsofn>:
- 80098: 6fae fcff ffff move\.d 0xfffffffc,\$r10
+ 80098: 6fae 8000 0000 move\.d 80 <x>,\$r10
#...
Index: ld-cris/tls-e-80.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-e-80.d,v
retrieving revision 1.3
diff -p -u -r1.3 tls-e-80.d
--- ld-cris/tls-e-80.d 24 Sep 2009 15:56:51 -0000 1.3
+++ ld-cris/tls-e-80.d 19 Oct 2009 16:18:56 -0000
@@ -81,7 +81,7 @@ Disassembly of section \.text:
800a8: 6fae b4ff ffff move.d 0xffffffb4,\$r10
#...
000800b0 <tlsdsofn>:
- 800b0: 6fae b0ff ffff move\.d 0xffffffb0,\$r10
+ 800b0: 6fae 0000 0000 move\.d 0 <x>,\$r10
#...
000800b8 <tlsdsofn10>:
800b8: 6fae 1400 0000 move\.d 14 <gx\+0x4>,\$r10
Index: ld-cris/tls-e-dtpoffd1.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-e-dtpoffd1.d,v
retrieving revision 1.1
diff -p -u -r1.1 tls-e-dtpoffd1.d
--- ld-cris/tls-e-dtpoffd1.d 24 Mar 2009 07:58:23 -0000 1.1
+++ ld-cris/tls-e-dtpoffd1.d 19 Oct 2009 16:18:56 -0000
@@ -27,6 +27,6 @@ Contents of section .got:
82120 00000000 00000000 00000000 01000000 .*
82130 80000000 .*
Contents of section .debug_info:
- 0000 fcffffff .*
+ 0000 80000000 .*
Contents of section .debug_line:
#pass
Index: ld-cris/tls-e-dtpoffd3.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-e-dtpoffd3.d,v
retrieving revision 1.1
diff -p -u -r1.1 tls-e-dtpoffd3.d
--- ld-cris/tls-e-dtpoffd3.d 25 Mar 2009 03:04:21 -0000 1.1
+++ ld-cris/tls-e-dtpoffd3.d 19 Oct 2009 16:18:56 -0000
@@ -27,6 +27,6 @@ Contents of section .got:
8211c 00000000 00000000 00000000 01000000 .*
8212c 80000000 .*
Contents of section .debug_info:
- 0000 fcffffff .*
+ 0000 80000000 .*
Contents of section .debug_line:
#pass
Index: ld-cris/tls-ldgde-14.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-ldgde-14.d,v
retrieving revision 1.4
diff -p -u -r1.4 tls-ldgde-14.d
--- ld-cris/tls-ldgde-14.d 24 Mar 2009 03:34:05 -0000 1.4
+++ ld-cris/tls-ldgde-14.d 19 Oct 2009 16:18:56 -0000
@@ -51,8 +51,8 @@ Disassembly of section \.text:
80094: 41b2 moveq 1,\$r11
#...
00080098 <tlsdsofn>:
- 80098: 5fae f8ff move\.w 0xfff8,\$r10
- 8009c: 5fbe fcff move\.w 0xfffc,\$r11
+ 80098: 5fae 8800 move\.w 0x88,\$r10
+ 8009c: 5fbe 8c00 move\.w 0x8c,\$r11
000800a0 <tlsdsofn0>:
800a0: 5fae 1400 move\.w 0x14,\$r10
Index: ld-cris/tls-ldgde-15.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-ldgde-15.d,v
retrieving revision 1.4
diff -p -u -r1.4 tls-ldgde-15.d
--- ld-cris/tls-ldgde-15.d 24 Mar 2009 03:34:05 -0000 1.4
+++ ld-cris/tls-ldgde-15.d 19 Oct 2009 16:18:56 -0000
@@ -51,8 +51,8 @@ Disassembly of section \.text:
80094: 41b2 moveq 1,\$r11
#...
00080098 <tlsdsofn>:
- 80098: 6fae f8ff ffff move.d 0xfffffff8,\$r10
- 8009e: 6fbe fcff ffff move.d 0xfffffffc,\$r11
+ 80098: 6fae 8800 0000 move.d 88 <x1>,\$r10
+ 8009e: 6fbe 8c00 0000 move.d 8c <x2>,\$r11
000800a4 <tlsdsofn2>:
800a4: 6fae 1400 0000 move.d 14 <tls128\+0x14>,\$r10
#...
Index: ld-cris/tls-ldgdex-14.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-ldgdex-14.d,v
retrieving revision 1.2
diff -p -u -r1.2 tls-ldgdex-14.d
--- ld-cris/tls-ldgdex-14.d 27 Jan 2009 07:05:47 -0000 1.2
+++ ld-cris/tls-ldgdex-14.d 19 Oct 2009 16:18:56 -0000
@@ -44,7 +44,7 @@ OFFSET TYPE VALUE
Contents of section .interp:
#...
Contents of section \.text:
- 801dc 41b20000 5faef8ff 5fbefcff 5fae1400 .*
+ 801dc 41b20000 5fae8000 5fbe8400 5fae1400 .*
801ec 5fae1c00 .*
Contents of section \.tdata:
#...
Index: ld-cris/tls-ldgdex-15.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-cris/tls-ldgdex-15.d,v
retrieving revision 1.2
diff -p -u -r1.2 tls-ldgdex-15.d
--- ld-cris/tls-ldgdex-15.d 27 Jan 2009 07:05:47 -0000 1.2
+++ ld-cris/tls-ldgdex-15.d 19 Oct 2009 16:18:56 -0000
@@ -44,7 +44,7 @@ OFFSET TYPE VALUE
Contents of section \.interp:
#...
Contents of section \.text:
- 801dc 41b20000 6faef8ff ffff6fbe fcffffff .*
+ 801dc 41b20000 6fae8000 00006fbe 84000000 .*
801ec 6fae1400 00000000 6fae1c00 00000000 .*
Contents of section \.tdata:
#...
brgds, H-P