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


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

alpha tls reloc fix


Pointed out by Jakub.


r~


2002-01-09  Richard Henderson  <rth@redhat.com>

	* sysdeps/alpha/dl-machine.h (elf_machine_rela): Compute
	DTPREL64 and TPREL64 without loadbase applied.


Index: sysdeps/alpha/dl-machine.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/alpha/dl-machine.h,v
retrieving revision 1.65
diff -c -p -d -r1.65 dl-machine.h
*** sysdeps/alpha/dl-machine.h	8 Nov 2002 02:19:00 -0000	1.65
--- sysdeps/alpha/dl-machine.h	10 Jan 2003 01:49:37 -0000
*************** elf_machine_rela (struct link_map *map,
*** 543,558 ****
        return;
    else
      {
!       Elf64_Addr sym_value;
  
  #if defined USE_TLS && !defined RTLD_BOOTSTRAP
        struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
!       sym_value = sym ? sym_map->l_addr + sym->st_value : 0;
  #else
        Elf64_Addr loadbase = RESOLVE (&sym, version, r_type);
!       sym_value = sym ? loadbase + sym->st_value : 0;
  #endif
-       sym_value += reloc->r_addend;
  
        if (r_type == R_ALPHA_GLOB_DAT)
  	*reloc_addr = sym_value;
--- 543,567 ----
        return;
    else
      {
!       Elf64_Addr sym_value, sym_raw_value;
  
  #if defined USE_TLS && !defined RTLD_BOOTSTRAP
        struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
!       sym_raw_value = sym_value = reloc->r_addend;
!       if (sym)
! 	{
! 	  sym_raw_value += sym->st_value;
! 	  sym_value = sym_raw_value + sym_map->l_addr;
! 	}
  #else
        Elf64_Addr loadbase = RESOLVE (&sym, version, r_type);
!       sym_raw_value = sym_value = reloc->r_addend;
!       if (sym)
! 	{
! 	  sym_raw_value += sym->st_value;
! 	  sym_value = sym_raw_value + loadbase;
! 	}
  #endif
  
        if (r_type == R_ALPHA_GLOB_DAT)
  	*reloc_addr = sym_value;
*************** elf_machine_rela (struct link_map *map,
*** 600,616 ****
  #ifndef RTLD_BOOTSTRAP
  	  /* During relocation all TLS symbols are defined and used.
  	     Therefore the offset is already correct.  */
! 	  *reloc_addr = sym_value;
  #endif
  	}
        else if (r_type == R_ALPHA_TPREL64)
  	{
  #ifdef RTLD_BOOTSTRAP
! 	  *reloc_addr = sym_value - map->l_tls_offset;
  #else
  	  if (sym_map)
  	    {
! 	      *reloc_addr = sym_value - sym_map->l_tls_offset;
  	      CHECK_STATIC_TLS (map, sym_map);
  	    }
  #endif
--- 609,625 ----
  #ifndef RTLD_BOOTSTRAP
  	  /* During relocation all TLS symbols are defined and used.
  	     Therefore the offset is already correct.  */
! 	  *reloc_addr = sym_raw_value;
  #endif
  	}
        else if (r_type == R_ALPHA_TPREL64)
  	{
  #ifdef RTLD_BOOTSTRAP
! 	  *reloc_addr = sym_raw_value - map->l_tls_offset;
  #else
  	  if (sym_map)
  	    {
! 	      *reloc_addr = sym_raw_value - sym_map->l_tls_offset;
  	      CHECK_STATIC_TLS (map, sym_map);
  	    }
  #endif


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