Skip to content

Commit

Permalink
* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Remove
Browse files Browse the repository at this point in the history
	special case for dl_rtld_map in R_PPC64_RELATIVE; it's harmless to
	repeat it and avoids the test for the common case.
	Clean up and fix calculations for TLS relocs.

	* sysdeps/powerpc/powerpc64/dl-tls.h: Moved to ...
	* sysdeps/powerpc/dl-tls.h: ... here.
	(TLS_TP_OFFSET): New macro.

	* sunrpc/svc_udp.c (svcudp_recv): Add a cast to last change.
  • Loading branch information
Roland McGrath committed Feb 28, 2003
1 parent 63c9fb5 commit a6963e6
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 57 deletions.
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2003-02-27 Roland McGrath <roland@redhat.com>

* sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela): Remove
special case for dl_rtld_map in R_PPC64_RELATIVE; it's harmless to
repeat it and avoids the test for the common case.
Clean up and fix calculations for TLS relocs.

* sysdeps/powerpc/powerpc64/dl-tls.h: Moved to ...
* sysdeps/powerpc/dl-tls.h: ... here.
(TLS_TP_OFFSET): New macro.

* sunrpc/svc_udp.c (svcudp_recv): Add a cast to last change.

2003-02-27 Ulrich Drepper <drepper@redhat.com>

* sysdeps/i386/fpu/libm-test-ulps: Increase ULPs for yn due to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Thread-local storage handling in the ELF dynamic linker. PowerPC64 version.
/* Thread-local storage handling in the ELF dynamic linker. PowerPC version.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Expand Down Expand Up @@ -30,6 +30,9 @@ typedef struct

extern void *__tls_get_addr (tls_index *ti);

/* The thread pointer points 0x7000 past the first static TLS block. */
# define TLS_TP_OFFSET 0x7000

/* Dynamic thread vector pointers point 0x8000 past the start of each
TLS block. */
# define TLS_DTV_OFFSET 0x8000
Expand Down
86 changes: 30 additions & 56 deletions sysdeps/powerpc/powerpc64/dl-machine.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Machine-dependent ELF dynamic relocation inline functions.
/* Machine-dependent ELF dynamic relocation inline functions.
PowerPC64 version.
Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
Free Software Foundation, Inc.
Expand Down Expand Up @@ -386,7 +386,7 @@ elf_machine_runtime_setup (struct link_map *map, int lazy, int profile)

/* Relocate the DT_PPC64_GLINK entry in the _DYNAMIC section.
elf_get_dynamic_info takes care of the standard entries but
doesn't know exactly what to do with processor specific
doesn't know exactly what to do with processor specific
entires. */
if (info[DT_PPC64(GLINK)] != NULL)
info[DT_PPC64(GLINK)]->d_un.d_ptr += l_addr;
Expand Down Expand Up @@ -425,7 +425,7 @@ elf_machine_runtime_setup (struct link_map *map, int lazy, int profile)
plt_reserve->fd_func += l_addr;
plt_reserve->fd_toc += l_addr;
#endif

/* Set up the lazy PLT entries. */
glink = (Elf64_Word *) D_PTR (map, l_info[DT_PPC64(GLINK)]);
offset = PLT_INITIAL_ENTRY_WORDS;
Expand Down Expand Up @@ -516,7 +516,7 @@ elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
{
return value + reloc->r_addend;
}

#endif /* dl_machine_h */

#ifdef RESOLVE_MAP
Expand Down Expand Up @@ -560,58 +560,32 @@ elf_machine_rela (struct link_map *map,
Elf64_Addr value, raw_value;
#ifndef RTLD_BOOTSTRAP
const Elf64_Sym *const refsym = sym;
/* This is defined in rtld.c, but nowhere in the static libc.a; make the
reference weak so static programs can still link. This declaration
cannot be done when compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP)
because rtld.c contains the common defn for _dl_rtld_map, which is
incompatible with a weak decl in the same file. */
weak_extern (GL(dl_rtld_map));
#endif

if (r_type == R_PPC64_RELATIVE)
{
#ifndef RTLD_BOOTSTRAP
/* Already done in dynamic linker. */
if (map != &GL(dl_rtld_map))
#endif
*reloc_addr = map->l_addr + reloc->r_addend;
return;
}

if (r_type == R_PPC64_NONE)
return;

value = 0;
raw_value = 0;

#if defined USE_TLS && !defined RTLD_BOOTSTRAP
sym_map = RESOLVE_MAP (&sym, version, r_type);
raw_value = value = reloc->r_addend;
value = raw_value = reloc->r_addend;
if (sym_map)
if (sym)
{
raw_value += sym->st_value;
value = raw_value + sym_map->l_addr;
}
#else
sym_map = RESOLVE_MAP (&sym, version, r_type);
if (sym_map)
{
if (sym)
{
raw_value = sym->st_value + sym_map->l_addr;
}
value = raw_value + reloc->r_addend;
}
#endif

switch (r_type)
{
case R_PPC64_ADDR64:
case R_PPC64_GLOB_DAT:
*reloc_addr = value;
*reloc_addr = value;
return;

#if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)

case R_PPC64_DTPMOD64:
Expand All @@ -620,34 +594,34 @@ elf_machine_rela (struct link_map *map,
*reloc_addr = 1;
#else
/* Get the information from the link map returned by the
resolv function. */
resolve function. */
if (sym_map != NULL)
{
*reloc_addr = sym_map->l_tls_modid;
}
*reloc_addr = sym_map->l_tls_modid;
#endif
return;

case R_PPC64_TPREL64:
#ifdef RTLD_BOOTSTRAP
*reloc_addr = raw_value + map->l_tls_offset - 0x7010;
*reloc_addr = (sym_map->l_tls_offset - TLS_TCB_SIZE
+ raw_value - TLS_TP_OFFSET);
#else
if (sym_map)
{
CHECK_STATIC_TLS (map, sym_map);
*reloc_addr = raw_value + sym_map->l_tls_offset - 0x7010;
}
{
CHECK_STATIC_TLS (map, sym_map);
*reloc_addr = (sym_map->l_tls_offset - TLS_TCB_SIZE
+ raw_value - TLS_TP_OFFSET);
}
#endif
return;

case R_PPC64_DTPREL64:
#ifndef RTLD_BOOTSTRAP
/* During relocation all TLS symbols are defined and used.
Therefore the offset is already correct. */
*reloc_addr = raw_value - 0x8000;
Therefore the offset is already correct. */
*reloc_addr = raw_value - TLS_DTV_OFFSET;
#endif
return;
#endif
#endif

case R_PPC64_JMP_SLOT:

Expand All @@ -657,39 +631,39 @@ elf_machine_rela (struct link_map *map,
#ifndef RTLD_BOOTSTRAP /* None of the following appear in ld.so */
case R_PPC64_ADDR16_LO_DS:
if (dont_expect ((value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_ADDR16_LO_DS",
_dl_reloc_overflow (map, "R_PPC64_ADDR16_LO_DS",
reloc_addr, sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
break;

case R_PPC64_TPREL16_LO_DS:
if (dont_expect ((value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_TPREL16_LO_DS",
_dl_reloc_overflow (map, "R_PPC64_TPREL16_LO_DS",
reloc_addr, sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
break;

case R_PPC64_DTPREL16_LO_DS:
if (dont_expect ((value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_DTPREL16_LO_DS",
_dl_reloc_overflow (map, "R_PPC64_DTPREL16_LO_DS",
reloc_addr, sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
break;

case R_PPC64_GOT_TPREL16_LO_DS:
if (dont_expect ((value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_GOT_TPREL16_LO_DS",
_dl_reloc_overflow (map, "R_PPC64_GOT_TPREL16_LO_DS",
reloc_addr, sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
break;

case R_PPC64_GOT_DTPREL16_LO_DS:
if (dont_expect ((value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_GOT_DTPREL16_LO_DS",
_dl_reloc_overflow (map, "R_PPC64_GOT_DTPREL16_LO_DS",
reloc_addr, sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
Expand Down Expand Up @@ -800,31 +774,31 @@ elf_machine_rela (struct link_map *map,

case R_PPC64_TPREL16_DS:
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_TPREL16_DS", reloc_addr,
_dl_reloc_overflow (map, "R_PPC64_TPREL16_DS", reloc_addr,
sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
break;

case R_PPC64_DTPREL16_DS:
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_DTPREL16_DS", reloc_addr,
_dl_reloc_overflow (map, "R_PPC64_DTPREL16_DS", reloc_addr,
sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
break;

case R_PPC64_GOT_TPREL16_DS:
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_GOT_TPREL16_DS", reloc_addr,
_dl_reloc_overflow (map, "R_PPC64_GOT_TPREL16_DS", reloc_addr,
sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
break;

case R_PPC64_GOT_DTPREL16_DS:
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
_dl_reloc_overflow (map, "R_PPC64_GOT_DTPREL16_DS",
_dl_reloc_overflow (map, "R_PPC64_GOT_DTPREL16_DS",
reloc_addr, sym, refsym);
*(Elf64_Half *) reloc_addr = BIT_INSERT (*(Elf64_Half *) reloc_addr,
value, 0xfffc);
Expand Down

0 comments on commit a6963e6

Please sign in to comment.