[PATCH] Sparc32 ELF TLS fixes

Jakub Jelinek jakub@redhat.com
Mon Apr 11 20:16:00 GMT 2005


On Sat, Apr 09, 2005 at 10:46:45PM -0700, David S. Miller wrote:
> While working on Sparc64 ELF TLS support, I found a bug in TLS
> handling on sparc32 ELF TLS.
> 
> For relocations R_SPARC_TLS_*_{HIX22,LOX10} it clearly states at:
> 
> http://docsun.cities.uiuc.edu/sun_docs/C/Solaris_9/SUNWdev/LLM/p60.html
> 
> that the formula for R_SPARC_TLS_LDO_HIX22 is:
> 	@dtpoff(S + A) >> 10
> and for R_SPARC_TLS_LDO_LOX10 it is:
> 	@dtpoff(S + A) & 0x3ff

The relocation are then misnamed, but guess we have to live with that.
The values used in those relocations are never negative, so it makes sense.

> 2005-04-09  David S. Miller  <davem@davemloft.net>
> 
> 	* elf32-sparc.c (elf32_sparc_relocate_section,
> 	R_SPARC_TLS_LDO_{HIX22,LOX10}): When not shared, transition to
> 	R_SPARC_TLS_LE_{HIX22,LOX10}.
> 	(elf32_sparc_relocate_section, R_SPARC_TLS_{LDO,LE}_HIX22): Only
> 	xor relocation with 0xffffffff if R_SPARC_TLS_LE_HIX22.
> 	(elf32_sparc_relocate_section, R_SPARC_TLS_{LDO,LE}_LOX10): Only
> 	or 0x1c00 into relocation if R_SPARC_TLS_LE_HIX22.

Thanks, please commit.
I see
FAIL: S-records with constructors
failure both without and with this patch (SREC tests don't use TLS,
so that's not surprising).

> 2005-04-09  David S. Miller  <davem@davemloft.net>
> 
> 	* ld-sparc/tlssunbin32.dd: Update for TLS relocation fixes.
> 	* ld-sparc/tlssunbin32.rd: Likewise.
> 	* ld-sparc/tlssunbin32.sd: Likewise.

You apparently missed also:

	* ld-sparc/tlssunpic32.dd: Update for TLS relocation fixes.

--- ld/testsuite/ld-sparc/tlssunpic32.dd.jj	2004-07-01 12:24:18.000000000 -0400
+++ ld/testsuite/ld-sparc/tlssunpic32.dd	2005-04-11 16:00:07.470083241 -0400
@@ -105,15 +105,15 @@ Disassembly of section .text:
  +1168:	01 00 00 00 	nop *
  +116c:	40 00 44 02 	call  [0-9a-f]+ <__tls_get_addr@plt>
  +1170:	01 00 00 00 	nop *
- +1174:	27 3f ff ff 	sethi  %hi\(0xfffffc00\), %l3
+ +1174:	27 00 00 00 	sethi  %hi\(0\), %l3
  +1178:	01 00 00 00 	nop *
- +117c:	a8 1c fc 20 	xor  %l3, -992, %l4
+ +117c:	a8 1c e0 20 	xor  %l3, 0x20, %l4
  +1180:	01 00 00 00 	nop *
  +1184:	aa 02 00 14 	add  %o0, %l4, %l5
  +1188:	01 00 00 00 	nop *
- +118c:	25 3f ff ff 	sethi  %hi\(0xfffffc00\), %l2
+ +118c:	25 00 00 00 	sethi  %hi\(0\), %l2
  +1190:	01 00 00 00 	nop *
- +1194:	a6 1c bc 26 	xor  %l2, -986, %l3
+ +1194:	a6 1c a0 26 	xor  %l2, 0x26, %l3
  +1198:	01 00 00 00 	nop *
  +119c:	ec 12 00 13 	lduh  \[ %o0 \+ %l3 \], %l6
  +11a0:	01 00 00 00 	nop *
@@ -121,13 +121,13 @@ Disassembly of section .text:
  +11a8:	01 00 00 00 	nop *
  +11ac:	01 00 00 00 	nop *
  +11b0:	13 00 00 00 	sethi  %hi\(0\), %o1
- +11b4:	27 3f ff ff 	sethi  %hi\(0xfffffc00\), %l3
+ +11b4:	27 00 00 00 	sethi  %hi\(0\), %l3
  +11b8:	94 02 60 14 	add  %o1, 0x14, %o2
- +11bc:	25 3f ff ff 	sethi  %hi\(0xfffffc00\), %l2
+ +11bc:	25 00 00 00 	sethi  %hi\(0\), %l2
  +11c0:	90 05 c0 0a 	add  %l7, %o2, %o0
- +11c4:	a8 1c fc 40 	xor  %l3, -960, %l4
+ +11c4:	a8 1c e0 40 	xor  %l3, 0x40, %l4
  +11c8:	40 00 43 eb 	call  [0-9a-f]+ <__tls_get_addr@plt>
- +11cc:	a6 1c bc 45 	xor  %l2, -955, %l3
+ +11cc:	a6 1c a0 45 	xor  %l2, 0x45, %l3
  +11d0:	aa 02 00 14 	add  %o0, %l4, %l5
  +11d4:	ec 0a 00 13 	ldub  \[ %o0 \+ %l3 \], %l6
  +11d8:	01 00 00 00 	nop *
@@ -135,13 +135,13 @@ Disassembly of section .text:
  +11e0:	01 00 00 00 	nop *
  +11e4:	01 00 00 00 	nop *
  +11e8:	13 00 00 00 	sethi  %hi\(0\), %o1
- +11ec:	27 3f ff ff 	sethi  %hi\(0xfffffc00\), %l3
+ +11ec:	27 00 00 00 	sethi  %hi\(0\), %l3
  +11f0:	94 02 60 14 	add  %o1, 0x14, %o2
- +11f4:	25 3f ff ff 	sethi  %hi\(0xfffffc00\), %l2
+ +11f4:	25 00 00 00 	sethi  %hi\(0\), %l2
  +11f8:	90 05 c0 0a 	add  %l7, %o2, %o0
- +11fc:	a8 1c fc 63 	xor  %l3, -925, %l4
+ +11fc:	a8 1c e0 63 	xor  %l3, 0x63, %l4
  +1200:	40 00 43 dd 	call  [0-9a-f]+ <__tls_get_addr@plt>
- +1204:	a6 1c bc 64 	xor  %l2, -924, %l3
+ +1204:	a6 1c a0 64 	xor  %l2, 0x64, %l3
  +1208:	aa 02 00 14 	add  %o0, %l4, %l5
  +120c:	ec 02 00 13 	ld  \[ %o0 \+ %l3 \], %l6
  +1210:	01 00 00 00 	nop *


	Jakub



More information about the Binutils mailing list