This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Some SH patches


Hi!

I've finally sent a SH TLS patch for binutils to the binutils
mailing list. Now it assumes fixed TLS instruction sequences
according to Uli's suggestion.
By this, 3 TLS relocations used as markers can be removed and
I moved the ELF relocation numbers of TLS relocations to the area
which isn't used by any non-GNU linkers as I know. The SH TLS
instruction patterns in elf/tls-macros.h is updated for the new
fixed sequences. A TLS relocation handling in dl-machine.h is
corrected like as i386 case. 

This patch includes a few tiny changes not for TLS also. I think
they are almost obvious except a patch which moves __fpscr_values
from crti.o to crt1.o. This will reduce the size of normal shared
libraries 8 bytes :-)

BTW, I'm preparing a compiler part of TLS for SH. It's not yet
finished, but I have an experimental gcc patch
<URL:http://dodo.nurs.or.jp/~kkojima/gnu-on-sh/gcc-tls-sh-20020924.diff>
and an updated memo
<URL:http://dodo.nurs.or.jp/~kkojima/gnu-on-sh/tls-sh-memo.txt>.

Regards,
	kaz
--
2002-10-02  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* elf/elf.h: Change TLS ELF relocation numbers.
	* elf/tls-macros.h: Fix code sequences for SH TLS_LD and TLS_GD
	macros.
	* linuxthreads/sysdeps/sh/pt-machine.h: Make C code ifndef'ed
	with __ASSEMBLER__.
	* linuxthreads/sysdeps/sh/tls.h: Likewise.
	* linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h: New file.
	* sysdeps/sh/dl-machine.h (dl_machine_rela)
	[case R_SH_TLS_TPOFF32]: Use addend.
	* sysdeps/sh/elf/initfini.c: Move __fpscr_values to...
	* sysdeps/sh/elf/start.S: ...here.

diff -urN ORIG/libc/elf/elf.h LOCAL/libc/elf/elf.h
--- ORIG/libc/elf/elf.h	Wed Oct  2 07:47:44 2002
+++ LOCAL/libc/elf/elf.h	Wed Oct  2 08:07:07 2002
@@ -2201,21 +2201,19 @@
 #define	R_SH_SWITCH8		33
 #define	R_SH_GNU_VTINHERIT	34
 #define	R_SH_GNU_VTENTRY	35
-#define	R_SH_TLS_GD_32		128
-#define	R_SH_TLS_LD_32		129
-#define	R_SH_TLS_LDO_32		130
-#define	R_SH_TLS_IE_32		131
-#define	R_SH_TLS_LE_32		132
-#define	R_SH_TLS_DTPMOD32	133
-#define	R_SH_TLS_DTPOFF32	134
-#define	R_SH_TLS_TPOFF32	135
-#define	R_SH_TLS_GD_MOV		136
-#define	R_SH_TLS_GD_CALLMOV	137
-#define	R_SH_TLS_LDM_MOV	138
-#define	R_SH_TLS_LDO_MOV	139
-#define	R_SH_TLS_LD_CALLMOV	140
-#define	R_SH_TLS_IE_MOV		141
-#define	R_SH_TLS_LE_MOV		142
+#define	R_SH_TLS_GD_32		144
+#define	R_SH_TLS_LD_32		145
+#define	R_SH_TLS_LDO_32		146
+#define	R_SH_TLS_IE_32		147
+#define	R_SH_TLS_LE_32		148
+#define	R_SH_TLS_DTPMOD32	149
+#define	R_SH_TLS_DTPOFF32	150
+#define	R_SH_TLS_TPOFF32	151
+#define	R_SH_TLS_GD_MOV		152
+#define	R_SH_TLS_LDM_MOV	153
+#define	R_SH_TLS_LDO_MOV	154
+#define	R_SH_TLS_IE_MOV		155
+#define	R_SH_TLS_LE_MOV		156
 #define	R_SH_GOT32		160
 #define	R_SH_PLT32		161
 #define	R_SH_COPY		162
diff -urN ORIG/libc/elf/tls-macros.h LOCAL/libc/elf/tls-macros.h
--- ORIG/libc/elf/tls-macros.h	Wed Oct  2 07:47:44 2002
+++ LOCAL/libc/elf/tls-macros.h	Wed Oct  2 08:07:07 2002
@@ -166,12 +166,11 @@
 	  "mov.l 0f,r12\n\t"						      \
 	  "add r0,r12\n\t"						      \
 	  "mov.l 1f,r4\n\t"						      \
-	  "add r12,r4\n\t"						      \
 	  "mova 2f,r0\n\t"						      \
 	  "mov.l 2f,r1\n\t"						      \
 	  "add r0,r1\n\t"						      \
 	  "jsr @r1\n\t"							      \
-	  " nop\n\t"							      \
+	  " add r12,r4\n\t"						      \
 	  "mov.l 3f,%0\n\t"						      \
 	  "bra 4f\n\t"							      \
 	  " add r0,%0\n\t"						      \
@@ -191,12 +190,11 @@
 	  "mov.l 0f,r12\n\t"						      \
 	  "add r0,r12\n\t"						      \
 	  "mov.l 1f,r4\n\t"						      \
-	  "add r12,r4\n\t"						      \
 	  "mova 2f,r0\n\t"						      \
 	  "mov.l 2f,r1\n\t"						      \
 	  "add r0,r1\n\t"						      \
 	  "jsr @r1\n\t"							      \
-	  " nop\n\t"							      \
+	  " add r12,r4\n\t"						      \
 	  "bra 3f\n\t"							      \
 	  " mov r0,%0\n\t"						      \
 	  ".align 2\n\t"						      \
diff -urN ORIG/libc/linuxthreads/sysdeps/sh/pt-machine.h LOCAL/libc/linuxthreads/sysdeps/sh/pt-machine.h
--- ORIG/libc/linuxthreads/sysdeps/sh/pt-machine.h	Tue Aug 27 07:07:48 2002
+++ LOCAL/libc/linuxthreads/sysdeps/sh/pt-machine.h	Wed Oct  2 08:34:38 2002
@@ -22,6 +22,7 @@
 #ifndef _PT_MACHINE_H
 #define _PT_MACHINE_H   1
 
+#ifndef __ASSEMBLER__
 #ifndef PT_EI
 # define PT_EI extern inline
 #endif
@@ -71,5 +72,6 @@
 #define THREAD_GETMEM_NC(descr, member) THREAD_SELF->member
 #define THREAD_SETMEM(descr, member, value) THREAD_SELF->member = (value)
 #define THREAD_SETMEM_NC(descr, member, value) THREAD_SELF->member = (value)
+#endif /* __ASSEMBLER__ */
 
 #endif /* pt-machine.h */
diff -urN ORIG/libc/linuxthreads/sysdeps/sh/tls.h LOCAL/libc/linuxthreads/sysdeps/sh/tls.h
--- ORIG/libc/linuxthreads/sysdeps/sh/tls.h	Mon Aug 26 17:31:24 2002
+++ LOCAL/libc/linuxthreads/sysdeps/sh/tls.h	Wed Oct  2 08:35:57 2002
@@ -20,6 +20,7 @@
 #ifndef _TLS_H
 #define _TLS_H
 
+#ifndef __ASSEMBLER__
 #include <stddef.h>
 
 #include <pt-machine.h>
@@ -109,5 +110,6 @@
      THREAD_GETMEM (__descr, p_header.data.dtvp); })
 
 #endif	/* FLOATING_STACKS && HAVE_TLS_SUPPORT */
+#endif /* __ASSEMBLER__ */
 
 #endif	/* tls.h */
diff -urN ORIG/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h LOCAL/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h
--- ORIG/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h	Thu Jan  1 09:00:00 1970
+++ LOCAL/libc/linuxthreads/sysdeps/unix/sysv/linux/sh/smp.h	Wed Oct  2 08:07:07 2002
@@ -0,0 +1,24 @@
+/* Determine whether the host has multiple processors.  SH version.
+   Copyright (C) 2002 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+static inline int
+is_smp_system (void)
+{
+  return 0;
+}
diff -urN ORIG/libc/sysdeps/sh/dl-machine.h LOCAL/libc/sysdeps/sh/dl-machine.h
--- ORIG/libc/sysdeps/sh/dl-machine.h	Mon Aug 26 17:32:51 2002
+++ LOCAL/libc/sysdeps/sh/dl-machine.h	Wed Oct  2 08:07:07 2002
@@ -573,14 +573,15 @@
 	case R_SH_TLS_TPOFF32:
 	  /* The offset is positive, afterward from the thread pointer.  */
 # ifdef RTLD_BOOTSTRAP
-	  *reloc_addr = map->l_tls_offset + sym->st_value;
+	  *reloc_addr = map->l_tls_offset + sym->st_value + reloc->r_addend;
 # else
 	  /* We know the offset of object the symbol is contained in.
 	     It is a positive value which will be added to the thread
 	     pointer.  To get the variable position in the TLS block
 	     we add the offset from that of the TLS block.  */
-	  if (sym_map != NULL && sym != NULL)
-	    *reloc_addr = sym_map->l_tls_offset + sym->st_value;
+	  *reloc_addr
+	    = ((sym == NULL ? 0 : sym_map->l_tls_offset + sym->st_value)
+	       + reloc->r_addend);
 # endif
 	  break;
 #endif	/* use TLS */
diff -urN ORIG/libc/sysdeps/sh/elf/initfini.c LOCAL/libc/sysdeps/sh/elf/initfini.c
--- ORIG/libc/sysdeps/sh/elf/initfini.c	Fri Jul  6 13:56:03 2001
+++ LOCAL/libc/sysdeps/sh/elf/initfini.c	Wed Oct  2 08:07:07 2002
@@ -71,12 +71,6 @@
 .L23:
 	.long	__gmon_start__
 #endif
-	.data
-	.global __fpscr_values
-__fpscr_values:
-	.long   0
-	.long   0x80000
-	.previous
 1:
 	ALIGN
 	END_INIT
diff -urN ORIG/libc/sysdeps/sh/elf/start.S LOCAL/libc/sysdeps/sh/elf/start.S
--- ORIG/libc/sysdeps/sh/elf/start.S	Fri Jul  6 13:56:03 2001
+++ LOCAL/libc/sysdeps/sh/elf/start.S	Wed Oct  2 08:07:07 2002
@@ -89,3 +89,7 @@
 	.long 0
 	.weak data_start
 	data_start = __data_start
+	.global __fpscr_values
+__fpscr_values:
+	.long   0
+	.long   0x80000


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]