about summary refs log tree commit diff
path: root/sysdeps/i386
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/dl-machine.h39
-rwxr-xr-xsysdeps/i386/elf/configure6
2 files changed, 42 insertions, 3 deletions
diff --git a/sysdeps/i386/dl-machine.h b/sysdeps/i386/dl-machine.h
index 69a0c5550e..f791fa3ffa 100644
--- a/sysdeps/i386/dl-machine.h
+++ b/sysdeps/i386/dl-machine.h
@@ -342,7 +342,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
   else
 #endif
     {
-#ifdef RTLD_BOOTSTRAP
+#if defined RTLD_BOOTSTRAP && !defined USE_TLS
       Elf32_Addr value;
 
       assert (r_type == R_386_GLOB_DAT || r_type == R_386_JMP_SLOT);
@@ -352,7 +352,9 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 #else
       const Elf32_Sym *const refsym = sym;
       Elf32_Addr value = RESOLVE (&sym, version, r_type);
+# ifndef RTLD_BOOTSTRAP
       if (sym)
+# endif
 	value += sym->st_value;
 
       switch (r_type)
@@ -361,6 +363,40 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 	case R_386_JMP_SLOT:
 	  *reloc_addr = value;
 	  break;
+
+	  /* XXX Remove TLS relocations which are not needed.  */
+
+	case R_386_TLS_DTPMOD32:
+# ifdef RTLD_BOOTSTRAP
+	  /* During startup the dynamic linker is always the module
+	     with index 1.
+	     XXX If this relocation is necessary move before RESOLVE
+	     call.  */
+	  *reloc_addr = 1;
+# else
+	  /* XXX Implement.  RESOLVE must return the map from which we
+	     get the module ID.  */
+	  _exit (99);
+# endif
+	  break;
+	case R_386_TLS_DTPOFF32:
+# ifndef RTLD_BOOTSTRAP
+	  /* During relocation all TLS symbols are defined and used.
+	     Therefore the offset is already correct.  */
+	  *reloc_addr = sym->st_value;
+# endif
+	  break;
+	case R_386_TLS_TPOFF32:
+	  /* The offset is positive, backward from the thread pointer.  */
+# ifdef RTLD_BOOTSTRAP
+	  *reloc_addr = GL(rtld_tlsoffset) - sym->st_value;
+# else
+	  /* XXX Implement.  */
+	  _exit (98);
+# endif
+	  break;
+
+# ifndef RTLD_BOOTSTRAP
 	case R_386_32:
 	  *reloc_addr += value;
 	  break;
@@ -390,6 +426,7 @@ elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
 	default:
 	  _dl_reloc_bad_type (map, r_type, 0);
 	  break;
+# endif
 	}
 #endif
     }
diff --git a/sysdeps/i386/elf/configure b/sysdeps/i386/elf/configure
index e12bf4a164..ca7f567bcb 100755
--- a/sysdeps/i386/elf/configure
+++ b/sysdeps/i386/elf/configure
@@ -9,16 +9,18 @@ if eval "test \"`echo '$''{'libc_cv_386_tls'+set}'`\" = set"; then
 else
   cat > conftest.s <<\EOF
 	.section ".tdata", "awT", @progbits
+	.globl foo
 foo:	.long	1
 	.section ".tbss", "awT", @nobits
-	.comm	bar,4,4
+	.globl bar
+bar:	.skip	4
 	.text
 baz:	leal	bar@TLSLDM(%ebx), %eax
 	leal	bar@DTPOFF(%eax), %edx
 	subl	foo@GOTTPOFF(%edx), %eax
 	subl	$bar@TPOFF, %eax
 EOF
-if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:22: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
+if { ac_try='${CC-cc} -c $CFLAGS conftest.s 1>&5'; { (eval echo configure:24: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; }; then
   libc_cv_386_tls=yes
 else
   libc_cv_386_tls=no