summaryrefslogtreecommitdiff
path: root/libc/elf
diff options
context:
space:
mode:
Diffstat (limited to 'libc/elf')
-rw-r--r--libc/elf/dl-dst.h21
-rw-r--r--libc/elf/dl-load.c14
-rw-r--r--libc/elf/elf.h36
-rw-r--r--libc/elf/tls-macros.h234
4 files changed, 167 insertions, 138 deletions
diff --git a/libc/elf/dl-dst.h b/libc/elf/dl-dst.h
index 76076a603..ae8d119c0 100644
--- a/libc/elf/dl-dst.h
+++ b/libc/elf/dl-dst.h
@@ -18,6 +18,8 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include "trusted-dirs.h"
+
/* Determine the number of DST elements in the name. Only if IS_PATH is
nonzero paths are recognized (i.e., multiple, ':' separated filenames). */
#define DL_DST_COUNT(name, is_path) \
@@ -39,12 +41,13 @@
\
if (__cnt > 0) \
{ \
- size_t origin_len; \
+ size_t dst_len; \
/* Now we make a guess how many extra characters on top of the \
length of S we need to represent the result. We know that \
we have CNT replacements. Each at most can use \
- MAX (strlen (ORIGIN), strlen (_dl_platform)) \
- minus 7 (which is the length of "$ORIGIN"). \
+ MAX (MAX (strlen (ORIGIN), strlen (_dl_platform)), \
+ strlen (DL_DST_LIB)) \
+ minus 4 (which is the length of "$LIB"). \
\
First get the origin string if it is not available yet. \
This can only happen for the map of the executable. */ \
@@ -53,14 +56,16 @@
{ \
assert ((l)->l_name[0] == '\0'); \
(l)->l_origin = _dl_get_origin (); \
- origin_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \
+ dst_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \
? strlen ((l)->l_origin) : 0); \
} \
else \
- origin_len = (l)->l_origin == (char *) -1 \
+ dst_len = (l)->l_origin == (char *) -1 \
? 0 : strlen ((l)->l_origin); \
- \
- __len += __cnt * (MAX (origin_len, GLRO(dl_platformlen)) - 7); \
+ dst_len = MAX (MAX (dst_len, GLRO(dl_platformlen)), \
+ strlen (DL_DST_LIB)); \
+ if (dst_len > 4) \
+ __len += __cnt * (dst_len - 4); \
} \
\
__len; })
@@ -72,7 +77,7 @@
if ((l) == NULL) \
{ \
const char *origin = _dl_get_origin (); \
- origin_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \
+ dst_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \
} \
else
#endif
diff --git a/libc/elf/dl-load.c b/libc/elf/dl-load.c
index 0fa3dca56..cd02c8df7 100644
--- a/libc/elf/dl-load.c
+++ b/libc/elf/dl-load.c
@@ -1,5 +1,5 @@
/* Map in a shared object's segments from the file.
- Copyright (C) 1995-2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1995-2005, 2006, 2007, 2009, 2010 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
@@ -313,7 +313,7 @@ static char *
expand_dynamic_string_token (struct link_map *l, const char *s)
{
/* We make two runs over the string. First we determine how large the
- resulting string is and then we copy it over. Since this is now
+ resulting string is and then we copy it over. Since this is no
frequently executed operation we are looking here not for performance
but rather for code size. */
size_t cnt;
@@ -391,7 +391,7 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
size_t len = strlen (cp);
/* `strsep' can pass an empty string. This has to be
- interpreted as `use the current directory'. */
+ interpreted as `use the current directory'. */
if (len == 0)
{
static const char curwd[] = "./";
@@ -1519,7 +1519,7 @@ cannot enable executable stack as shared object requires");
/* Print search path. */
static void
print_search_path (struct r_search_path_elem **list,
- const char *what, const char *name)
+ const char *what, const char *name)
{
char buf[max_dirnamelen + max_capstrlen];
int first = 1;
@@ -2044,7 +2044,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
fd = -1;
/* When the object has the RUNPATH information we don't use any
- RPATHs. */
+ RPATHs. */
if (loader == NULL || loader->l_info[DT_RUNPATH] == NULL)
{
/* This is the executable's map (if there is one). Make sure that
@@ -2067,7 +2067,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
}
/* If dynamically linked, try the DT_RPATH of the executable
- itself. NB: we do this for lookups in any namespace. */
+ itself. NB: we do this for lookups in any namespace. */
if (fd == -1 && !did_main_map
&& main_map != NULL && main_map->l_type != lt_loaded
&& cache_rpath (main_map, &main_map->l_rpath_dirs, DT_RPATH,
@@ -2164,7 +2164,7 @@ _dl_map_object (struct link_map *loader, const char *name, int preloaded,
/* Add another newline when we are tracing the library loading. */
if (__builtin_expect (GLRO_dl_debug_mask & DL_DEBUG_LIBS, 0))
- _dl_debug_printf ("\n");
+ _dl_debug_printf ("\n");
}
else
{
diff --git a/libc/elf/elf.h b/libc/elf/elf.h
index 8af7c177c..f41a02649 100644
--- a/libc/elf/elf.h
+++ b/libc/elf/elf.h
@@ -619,6 +619,7 @@ typedef struct
#define NT_PPC_VSX 0x102 /* PowerPC VSX registers */
#define NT_386_TLS 0x200 /* i386 TLS slots (struct user_desc) */
#define NT_386_IOPERM 0x201 /* x86 io permission bitmap (1=deny) */
+#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */
/* Legal values for the note segment descriptor types for object files. */
@@ -1123,8 +1124,29 @@ typedef struct
#define R_68K_GLOB_DAT 20 /* Create GOT entry */
#define R_68K_JMP_SLOT 21 /* Create PLT entry */
#define R_68K_RELATIVE 22 /* Adjust by program base */
+#define R_68K_TLS_GD32 25 /* 32 bit GOT offset for GD */
+#define R_68K_TLS_GD16 26 /* 16 bit GOT offset for GD */
+#define R_68K_TLS_GD8 27 /* 8 bit GOT offset for GD */
+#define R_68K_TLS_LDM32 28 /* 32 bit GOT offset for LDM */
+#define R_68K_TLS_LDM16 29 /* 16 bit GOT offset for LDM */
+#define R_68K_TLS_LDM8 30 /* 8 bit GOT offset for LDM */
+#define R_68K_TLS_LDO32 31 /* 32 bit module-relative offset */
+#define R_68K_TLS_LDO16 32 /* 16 bit module-relative offset */
+#define R_68K_TLS_LDO8 33 /* 8 bit module-relative offset */
+#define R_68K_TLS_IE32 34 /* 32 bit GOT offset for IE */
+#define R_68K_TLS_IE16 35 /* 16 bit GOT offset for IE */
+#define R_68K_TLS_IE8 36 /* 8 bit GOT offset for IE */
+#define R_68K_TLS_LE32 37 /* 32 bit offset relative to
+ static TLS block */
+#define R_68K_TLS_LE16 38 /* 16 bit offset relative to
+ static TLS block */
+#define R_68K_TLS_LE8 39 /* 8 bit offset relative to
+ static TLS block */
+#define R_68K_TLS_DTPMOD32 40 /* 32 bit module number */
+#define R_68K_TLS_DTPREL32 41 /* 32 bit module-relative offset */
+#define R_68K_TLS_TPREL32 42 /* 32 bit TP-relative offset */
/* Keep this the last entry. */
-#define R_68K_NUM 23
+#define R_68K_NUM 43
/* Intel 80386 specific definitions. */
@@ -1303,6 +1325,8 @@ typedef struct
#define R_SPARC_H34 85
#define R_SPARC_SIZE32 86
#define R_SPARC_SIZE64 87
+#define R_SPARC_JMP_IREL 248
+#define R_SPARC_IRELATIVE 249
#define R_SPARC_GNU_VTINHERIT 250
#define R_SPARC_GNU_VTENTRY 251
#define R_SPARC_REV32 252
@@ -2642,7 +2666,15 @@ typedef Elf32_Addr Elf32_Conflict;
#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */
#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative
offset to GOT */
-/* 27 .. 33 */
+#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */
+#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset
+ to GOT entry */
+#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */
+#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */
+#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset
+ to PLT entry */
+#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */
+#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */
#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor. */
#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS
descriptor. */
diff --git a/libc/elf/tls-macros.h b/libc/elf/tls-macros.h
index 6463a6c3f..781256db1 100644
--- a/libc/elf/tls-macros.h
+++ b/libc/elf/tls-macros.h
@@ -701,154 +701,146 @@ register void *__gp __asm__("$29");
(int *) (__builtin_thread_pointer() + __offset); })
# endif
-#elif defined __powerpc__ && !defined __powerpc64__
+#elif defined __powerpc__
-#include "config.h"
-
-# define __TLS_CALL_CLOBBERS \
- "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
+# define __TLS_CALL_CLOBBERS \
+ "0", "4", "5", "6", "7", "8", "9", "10", "11", "12", \
"lr", "ctr", "cr0", "cr1", "cr5", "cr6", "cr7"
+# ifndef __powerpc64__
+
+# include "config.h"
+
/* PowerPC32 Local Exec TLS access. */
-# define TLS_LE(x) \
- ({ int *__result; \
- asm ("addi %0,2," #x "@tprel" \
- : "=r" (__result)); \
+# define TLS_LE(x) \
+ ({ int *__result; \
+ asm ("addi %0,2," #x "@tprel" \
+ : "=r" (__result)); \
__result; })
/* PowerPC32 Initial Exec TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_IE(x) \
- ({ int *__result; \
- asm ("bcl 20,31,1f\n1:\t" \
- "mflr %0\n\t" \
- "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "lwz %0," #x "@got@tprel(%0)\n\t" \
- "add %0,%0," #x "@tls" \
- : "=b" (__result) : \
- : "lr"); \
+# ifdef HAVE_ASM_PPC_REL16
+# define TLS_IE(x) \
+ ({ int *__result; \
+ asm ("bcl 20,31,1f\n1:\t" \
+ "mflr %0\n\t" \
+ "addis %0,%0,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi %0,%0,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
__result; })
-# else
-# define TLS_IE(x) \
- ({ int *__result; \
- asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr %0\n\t" \
- "lwz %0," #x "@got@tprel(%0)\n\t" \
- "add %0,%0," #x "@tls" \
- : "=b" (__result) : \
- : "lr"); \
+# else
+# define TLS_IE(x) \
+ ({ int *__result; \
+ asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr %0\n\t" \
+ "lwz %0," #x "@got@tprel(%0)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=b" (__result) : \
+ : "lr"); \
__result; })
-# endif
+# endif
/* PowerPC32 Local Dynamic TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_LD(x) \
- ({ int *__result; \
- asm ("bcl 20,31,1f\n1:\t" \
- "mflr 3\n\t" \
- "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "addi 3,3," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr@plt\n\t" \
- "addi %0,3," #x "@dtprel" \
- : "=r" (__result) : \
- : __TLS_CALL_CLOBBERS); \
+# ifdef HAVE_ASM_PPC_REL16
+# define TLS_LD(x) \
+ ({ int *__result; \
+ asm ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : "3", __TLS_CALL_CLOBBERS); \
__result; })
-# else
-# define TLS_LD(x) \
- ({ int *__result; \
- asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr 3\n\t" \
- "addi 3,3," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr@plt\n\t" \
- "addi %0,3," #x "@dtprel" \
- : "=r" (__result) : \
- : __TLS_CALL_CLOBBERS); \
+# else
+# define TLS_LD(x) \
+ ({ int *__result; \
+ asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsld\n\t" \
+ "bl __tls_get_addr@plt\n\t" \
+ "addi %0,3," #x "@dtprel" \
+ : "=r" (__result) : \
+ : "3", __TLS_CALL_CLOBBERS); \
__result; })
-# endif
+# endif
/* PowerPC32 General Dynamic TLS access. */
-# ifdef HAVE_ASM_PPC_REL16
-# define TLS_GD(x) \
- ({ register int *__result __asm__ ("r3"); \
- asm ("bcl 20,31,1f\n1:\t" \
- "mflr 3\n\t" \
- "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
- "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
- "addi 3,3," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr@plt" \
- : : \
- : __TLS_CALL_CLOBBERS); \
+# ifdef HAVE_ASM_PPC_REL16
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ asm ("bcl 20,31,1f\n1:\t" \
+ "mflr 3\n\t" \
+ "addis 3,3,_GLOBAL_OFFSET_TABLE_-1b@ha\n\t" \
+ "addi 3,3,_GLOBAL_OFFSET_TABLE_-1b@l\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
__result; })
-# else
-# define TLS_GD(x) \
- ({ register int *__result __asm__ ("r3"); \
- asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
- "mflr 3\n\t" \
- "addi 3,3," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr@plt" \
- : : \
- : __TLS_CALL_CLOBBERS); \
+# else
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ asm ("bl _GLOBAL_OFFSET_TABLE_@local-4\n\t" \
+ "mflr 3\n\t" \
+ "addi 3,3," #x "@got@tlsgd\n\t" \
+ "bl __tls_get_addr@plt" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
__result; })
-# endif
+# endif
-#elif defined __powerpc__ && defined __powerpc64__
+# else
/* PowerPC64 Local Exec TLS access. */
-# define TLS_LE(x) \
- ({ int * __result; \
- asm ( \
- " addis %0,13," #x "@tprel@ha\n" \
- " addi %0,%0," #x "@tprel@l\n" \
- : "=b" (__result) ); \
- __result; \
+# define TLS_LE(x) \
+ ({ int * __result; \
+ asm ("addis %0,13," #x "@tprel@ha\n\t" \
+ "addi %0,%0," #x "@tprel@l" \
+ : "=b" (__result) ); \
+ __result; \
})
/* PowerPC64 Initial Exec TLS access. */
-# define TLS_IE(x) \
- ({ int * __result; \
- asm ( \
- " ld %0," #x "@got@tprel(2)\n" \
- " add %0,%0," #x "@tls\n" \
- : "=b" (__result) ); \
- __result; \
+# define TLS_IE(x) \
+ ({ int * __result; \
+ asm ("ld %0," #x "@got@tprel(2)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=r" (__result) ); \
+ __result; \
})
-# ifdef HAVE_ASM_GLOBAL_DOT_NAME
-# define __TLS_GET_ADDR ".__tls_get_addr"
-# else
-# define __TLS_GET_ADDR "__tls_get_addr"
-# endif
+# ifdef HAVE_ASM_GLOBAL_DOT_NAME
+# define __TLS_GET_ADDR ".__tls_get_addr"
+# else
+# define __TLS_GET_ADDR "__tls_get_addr"
+# endif
/* PowerPC64 Local Dynamic TLS access. */
-# define TLS_LD(x) \
- ({ int * __result; \
- asm ( \
- " addi 3,2," #x "@got@tlsld\n" \
- " bl " __TLS_GET_ADDR "\n" \
- " nop \n" \
- " addis %0,3," #x "@dtprel@ha\n" \
- " addi %0,%0," #x "@dtprel@l\n" \
- : "=b" (__result) : \
- : "0", "3", "4", "5", "6", "7", \
- "8", "9", "10", "11", "12", \
- "lr", "ctr", \
- "cr0", "cr1", "cr5", "cr6", "cr7"); \
- __result; \
+# define TLS_LD(x) \
+ ({ int * __result; \
+ asm ("addi 3,2," #x "@got@tlsld\n\t" \
+ "bl " __TLS_GET_ADDR "\n\t" \
+ "nop \n\t" \
+ "addis %0,3," #x "@dtprel@ha\n\t" \
+ "addi %0,%0," #x "@dtprel@l" \
+ : "=b" (__result) : \
+ : "3", __TLS_CALL_CLOBBERS); \
+ __result; \
})
/* PowerPC64 General Dynamic TLS access. */
-# define TLS_GD(x) \
- ({ int * __result; \
- asm ( \
- " addi 3,2," #x "@got@tlsgd\n" \
- " bl " __TLS_GET_ADDR "\n" \
- " nop \n" \
- " mr %0,3\n" \
- : "=b" (__result) : \
- : "0", "3", "4", "5", "6", "7", \
- "8", "9", "10", "11", "12", \
- "lr", "ctr", \
- "cr0", "cr1", "cr5", "cr6", "cr7"); \
- __result; \
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ asm ("addi 3,2," #x "@got@tlsgd\n\t" \
+ "bl " __TLS_GET_ADDR "\n\t" \
+ "nop " \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; \
})
+# endif
#elif !defined TLS_LE || !defined TLS_IE \
|| !defined TLS_LD || !defined TLS_GD