diff options
author | Jakub Jelinek <jakub@redhat.com> | 2006-03-01 06:55:57 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2006-03-01 06:55:57 +0000 |
commit | 6a8c1091fdc978b0e369f4ca3f58a07c2f8b9d33 (patch) | |
tree | 754e2649fcc68e83b3ad749cb5a1a1f7549ffafb /elf | |
parent | 378b1353df56387b0706bc42cb661ff2227c8eb9 (diff) |
Updated to fedora-glibc-20060301T0647
Diffstat (limited to 'elf')
-rw-r--r-- | elf/Makefile | 13 | ||||
-rw-r--r-- | elf/Versions | 1 | ||||
-rw-r--r-- | elf/circleload1.c | 4 | ||||
-rw-r--r-- | elf/dl-debug.c | 17 | ||||
-rw-r--r-- | elf/dl-iteratephdr.c | 9 | ||||
-rw-r--r-- | elf/dl-sym.c | 4 | ||||
-rw-r--r-- | elf/dl-tls.c | 48 | ||||
-rw-r--r-- | elf/do-lookup.h | 4 | ||||
-rw-r--r-- | elf/elf.h | 9 | ||||
-rw-r--r-- | elf/link.h | 18 | ||||
-rw-r--r-- | elf/loadtest.c | 8 | ||||
-rw-r--r-- | elf/neededtest.c | 4 | ||||
-rw-r--r-- | elf/neededtest2.c | 4 | ||||
-rw-r--r-- | elf/neededtest3.c | 4 | ||||
-rw-r--r-- | elf/neededtest4.c | 4 | ||||
-rw-r--r-- | elf/rtld-Rules | 10 | ||||
-rw-r--r-- | elf/sofini.c | 8 | ||||
-rw-r--r-- | elf/soinit.c | 60 | ||||
-rw-r--r-- | elf/tst-tls-dlinfo.c | 92 | ||||
-rw-r--r-- | elf/unload.c | 4 | ||||
-rw-r--r-- | elf/unload2.c | 4 |
21 files changed, 234 insertions, 95 deletions
diff --git a/elf/Makefile b/elf/Makefile index 5cd78c2f83..791341758e 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -163,9 +163,11 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \ neededtest3 neededtest4 unload2 lateglobal initfirst global \ restest2 next dblload dblunload reldep5 reldep6 reldep7 reldep8 \ circleload1 tst-tls3 tst-tls4 tst-tls5 tst-tls6 tst-tls7 tst-tls8 \ - tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 tst-align \ - tst-align2 $(tests-execstack-$(have-z-execstack)) tst-dlmodcount \ - tst-dlopenrpath tst-deep1 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \ + tst-tls10 tst-tls11 tst-tls12 tst-tls13 tst-tls14 tst-tls15 \ + tst-tls-dlinfo \ + tst-align tst-align2 $(tests-execstack-$(have-z-execstack)) \ + tst-dlmodcount tst-dlopenrpath tst-deep1 \ + tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \ unload3 unload4 unload5 unload6 tst-audit1 tst-global1 order2 \ tst-stackguard1 # reldep9 @@ -700,6 +702,11 @@ $(objpfx)tst-tls14.out: $(objpfx)tst-tlsmod14b.so $(objpfx)tst-tls15: $(libdl) $(objpfx)tst-tls15.out: $(objpfx)tst-tlsmod15a.so $(objpfx)tst-tlsmod15b.so +$(objpfx)tst-tls-dlinfo: $(libdl) +$(objpfx)tst-tls-dlinfo.out: $(objpfx)tst-tlsmod2.so + + + CFLAGS-tst-align.c = $(stack-align-test-flags) CFLAGS-tst-align2.c = $(stack-align-test-flags) CFLAGS-tst-alignmod.c = $(stack-align-test-flags) diff --git a/elf/Versions b/elf/Versions index 87e27c5a7a..967ebdb3a5 100644 --- a/elf/Versions +++ b/elf/Versions @@ -57,6 +57,7 @@ ld { _dl_allocate_tls; _dl_deallocate_tls; _dl_get_tls_static_info; _dl_allocate_tls_init; _dl_tls_setup; _dl_rtld_di_serinfo; + _dl_tls_get_addr_soft; _dl_make_stack_executable; # Only here for gdb while a better method is developed. _dl_debug_state; diff --git a/elf/circleload1.c b/elf/circleload1.c index f5f886a1da..990ff84a84 100644 --- a/elf/circleload1.c +++ b/elf/circleload1.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <string.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + static int check_loaded_objects (const char **loaded) { @@ -24,7 +26,7 @@ check_loaded_objects (const char **loaded) printf(" Name\n"); printf(" --------------------------------------------------------\n"); - for (lm = _r_debug.r_map; lm; lm = lm->l_next) + for (lm = MAPS; lm; lm = lm->l_next) { if (lm->l_name && lm->l_name[0]) printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount); diff --git a/elf/dl-debug.c b/elf/dl-debug.c index bc7d793435..d00fe87fbb 100644 --- a/elf/dl-debug.c +++ b/elf/dl-debug.c @@ -1,5 +1,6 @@ /* Communicate dynamic linker state to the debugger at runtime. - Copyright (C) 1996, 1998,2000,2002,2004,2005 Free Software Foundation, Inc. + Copyright (C) 1996, 1998,2000,2002,2004,2005,2006 + 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 @@ -19,6 +20,18 @@ #include <ldsodefs.h> + +/* These are the members in the public `struct link_map' type. + Sanity check that the internal type and the public type match. */ +#define VERIFY_MEMBER(name) \ + (offsetof (struct link_map_public, name) == offsetof (struct link_map, name)) +extern const int verify_link_map_members[(VERIFY_MEMBER (l_addr) + && VERIFY_MEMBER (l_name) + && VERIFY_MEMBER (l_ld) + && VERIFY_MEMBER (l_next) + && VERIFY_MEMBER (l_prev)) + ? 1 : -1]; + /* This structure communicates dl state to the debugger. The debugger normally finds it via the DT_DEBUG entry in the dynamic section, but in a statically-linked program there is no dynamic section for the debugger @@ -46,7 +59,7 @@ _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) /* Tell the debugger where to find the map of loaded objects. */ r->r_version = 1 /* R_DEBUG_VERSION XXX */; r->r_ldbase = ldbase ?: _r_debug.r_ldbase; - r->r_map = GL(dl_ns)[ns]._ns_loaded; + r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded; r->r_brk = (ElfW(Addr)) &_dl_debug_state; } diff --git a/elf/dl-iteratephdr.c b/elf/dl-iteratephdr.c index 6ed90c73b1..52a114421d 100644 --- a/elf/dl-iteratephdr.c +++ b/elf/dl-iteratephdr.c @@ -1,5 +1,5 @@ /* Get loaded objects program headers. - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2001,2002,2003,2004,2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek <jakub@redhat.com>, 2001. @@ -68,6 +68,13 @@ __dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, info.dlpi_phnum = l->l_phnum; info.dlpi_adds = GL(dl_load_adds); info.dlpi_subs = GL(dl_load_adds) - nloaded; + info.dlpi_tls_modid = 0; + info.dlpi_tls_data = NULL; +#ifdef USE_TLS + info.dlpi_tls_modid = l->l_tls_modid; + if (info.dlpi_tls_modid != 0) + info.dlpi_tls_data = _dl_tls_get_addr_soft (l); +#endif ret = callback (&info, sizeof (struct dl_phdr_info), data); if (ret) break; diff --git a/elf/dl-sym.c b/elf/dl-sym.c index ca83daf21d..d2b0ec0dab 100644 --- a/elf/dl-sym.c +++ b/elf/dl-sym.c @@ -1,5 +1,5 @@ /* Look up a symbol in a shared object loaded by `dlopen'. - Copyright (C) 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 1999,2000,2001,2002,2004,2006 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 @@ -103,7 +103,7 @@ RTLD_NEXT used in code not dynamically loaded")); while (l->l_loader != NULL) l = l->l_loader; - result = GLRO(dl_lookup_symbol_x) (name, l, &ref, l->l_local_scope, + result = GLRO(dl_lookup_symbol_x) (name, match, &ref, l->l_local_scope, vers, 0, 0, match); } else diff --git a/elf/dl-tls.c b/elf/dl-tls.c index 4fed570d5c..a0f4f77ffa 100644 --- a/elf/dl-tls.c +++ b/elf/dl-tls.c @@ -1,5 +1,5 @@ /* Thread-local storage handling in the ELF dynamic linker. Generic version. - Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2002,2003,2004,2005,2006 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 @@ -735,9 +735,53 @@ __tls_get_addr (GET_ADDR_ARGS) # endif +/* Look up the module's TLS block as for __tls_get_addr, + but never touch anything. Return null if it's not allocated yet. */ +void * +internal_function +_dl_tls_get_addr_soft (struct link_map *l) +{ + if (__builtin_expect (l->l_tls_modid == 0, 0)) + /* This module has no TLS segment. */ + return NULL; + + dtv_t *dtv = THREAD_DTV (); + if (__builtin_expect (dtv[0].counter != GL(dl_tls_generation), 0)) + { + /* This thread's DTV is not completely current, + but it might already cover this module. */ + + if (l->l_tls_modid >= dtv[-1].counter) + /* Nope. */ + return NULL; + + size_t idx = l->l_tls_modid; + struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list); + while (idx >= listp->len) + { + idx -= listp->len; + listp = listp->next; + } + + /* We've reached the slot for this module. + If its generation counter is higher than the DTV's, + this thread does not know about this module yet. */ + if (dtv[0].counter < listp->slotinfo[idx].gen) + return NULL; + } + + void *data = dtv[l->l_tls_modid].pointer.val; + if (__builtin_expect (data == TLS_DTV_UNALLOCATED, 0)) + /* The DTV is current, but this thread has not yet needed + to allocate this module's segment. */ + data = NULL; + + return data; +} + void -_dl_add_to_slotinfo (struct link_map *l) +_dl_add_to_slotinfo (struct link_map *l) { /* Now that we know the object is loaded successfully add modules containing TLS data to the dtv info table. We diff --git a/elf/do-lookup.h b/elf/do-lookup.h index 62755ea013..7b62b0feec 100644 --- a/elf/do-lookup.h +++ b/elf/do-lookup.h @@ -1,5 +1,5 @@ /* Look up a symbol in the loaded objects. - Copyright (C) 1995-2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-2004, 2005, 2006 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 @@ -45,7 +45,7 @@ do_lookup_x (const char *undef_name, unsigned long int hash, map = list[i]->l_real; /* Here come the extra test needed for `_dl_lookup_symbol_skip'. */ - if (skip != NULL && map == skip) + if (map == skip) continue; /* Don't search the executable when resolving a copy reloc. */ @@ -1,5 +1,5 @@ /* This file defines standard ELF types, structures, and macros. - Copyright (C) 1995-2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-2003,2004,2005,2006 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 @@ -1250,14 +1250,15 @@ typedef struct #define DT_SPARC_REGISTER 0x70000001 #define DT_SPARC_NUM 2 -/* Bits present in AT_HWCAP, primarily for Sparc32. */ +/* Bits present in AT_HWCAP on SPARC. */ -#define HWCAP_SPARC_FLUSH 1 /* The cpu supports flush insn. */ +#define HWCAP_SPARC_FLUSH 1 /* The CPU supports flush insn. */ #define HWCAP_SPARC_STBAR 2 #define HWCAP_SPARC_SWAP 4 #define HWCAP_SPARC_MULDIV 8 -#define HWCAP_SPARC_V9 16 /* The cpu is v9, so v8plus is ok. */ +#define HWCAP_SPARC_V9 16 /* The CPU is v9, so v8plus is ok. */ #define HWCAP_SPARC_ULTRA3 32 +#define HWCAP_SPARC_BLKINIT 64 /* Sun4v with block-init/load-twin. */ /* MIPS R3000 specific definitions. */ diff --git a/elf/link.h b/elf/link.h index fdda019cbe..076531d6e7 100644 --- a/elf/link.h +++ b/elf/link.h @@ -1,6 +1,6 @@ /* Data structure for communication from the run-time dynamic linker for loaded ELF shared objects. - Copyright (C) 1995-2001, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 1995-2001, 2004, 2005, 2006 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 @@ -135,7 +135,6 @@ enum la_symbind call. */ }; - struct dl_phdr_info { ElfW(Addr) dlpi_addr; @@ -143,15 +142,24 @@ struct dl_phdr_info const ElfW(Phdr) *dlpi_phdr; ElfW(Half) dlpi_phnum; - /* Note: the next two members were introduced after the first + /* Note: Following members were introduced after the first version of this structure was available. Check the SIZE - argument passed to the dl_iterate_phdr() callback to determine - whether or not they are provided. */ + argument passed to the dl_iterate_phdr callback to determine + whether or not each later member is available. */ /* Incremented when a new object may have been added. */ unsigned long long int dlpi_adds; /* Incremented when an object may have been removed. */ unsigned long long int dlpi_subs; + + /* If there is a PT_TLS segment, its module ID as used in + TLS relocations, else zero. */ + size_t dlpi_tls_modid; + + /* The address of the calling thread's instance of this module's + PT_TLS segment, if it has one and it has been allocated + in the calling thread, otherwise a null pointer. */ + void *dlpi_tls_data; }; __BEGIN_DECLS diff --git a/elf/loadtest.c b/elf/loadtest.c index ee106ea152..727469b496 100644 --- a/elf/loadtest.c +++ b/elf/loadtest.c @@ -70,8 +70,10 @@ static const struct #include <include/link.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + #define OUT \ - for (map = _r_debug.r_map; map != NULL; map = map->l_next) \ + for (map = MAPS; map != NULL; map = map->l_next) \ if (map->l_type == lt_loaded) \ printf ("name = \"%s\", direct_opencount = %d\n", \ map->l_name, (int) map->l_direct_opencount); \ @@ -147,7 +149,7 @@ main (int argc, char *argv[]) { /* In this case none of the objects above should be present. */ - for (map = _r_debug.r_map; map != NULL; map = map->l_next) + for (map = MAPS; map != NULL; map = map->l_next) if (map->l_type == lt_loaded && (strstr (map->l_name, testobjs[0].name) != NULL || strstr (map->l_name, testobjs[1].name) != NULL @@ -180,7 +182,7 @@ main (int argc, char *argv[]) } /* Check whether all files are unloaded. */ - for (map = _r_debug.r_map; map != NULL; map = map->l_next) + for (map = MAPS; map != NULL; map = map->l_next) if (map->l_type == lt_loaded) { printf ("name = \"%s\", direct_opencount = %d\n", diff --git a/elf/neededtest.c b/elf/neededtest.c index 6c7a952066..3cea499314 100644 --- a/elf/neededtest.c +++ b/elf/neededtest.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <string.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + static int check_loaded_objects (const char **loaded) { @@ -24,7 +26,7 @@ check_loaded_objects (const char **loaded) printf(" Name\n"); printf(" --------------------------------------------------------\n"); - for (lm = _r_debug.r_map; lm; lm = lm->l_next) + for (lm = MAPS; lm; lm = lm->l_next) { if (lm->l_name && lm->l_name[0]) printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount); diff --git a/elf/neededtest2.c b/elf/neededtest2.c index b682f15792..17c75f2ba3 100644 --- a/elf/neededtest2.c +++ b/elf/neededtest2.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <string.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + static int check_loaded_objects (const char **loaded) { @@ -24,7 +26,7 @@ check_loaded_objects (const char **loaded) printf(" Name\n"); printf(" --------------------------------------------------------\n"); - for (lm = _r_debug.r_map; lm; lm = lm->l_next) + for (lm = MAPS; lm; lm = lm->l_next) { if (lm->l_name && lm->l_name[0]) printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount); diff --git a/elf/neededtest3.c b/elf/neededtest3.c index ea1dcf4794..41970cf2c7 100644 --- a/elf/neededtest3.c +++ b/elf/neededtest3.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <string.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + static int check_loaded_objects (const char **loaded) { @@ -24,7 +26,7 @@ check_loaded_objects (const char **loaded) printf(" Name\n"); printf(" --------------------------------------------------------\n"); - for (lm = _r_debug.r_map; lm; lm = lm->l_next) + for (lm = MAPS; lm; lm = lm->l_next) { if (lm->l_name && lm->l_name[0]) printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount); diff --git a/elf/neededtest4.c b/elf/neededtest4.c index 7514bed499..bd79341fb2 100644 --- a/elf/neededtest4.c +++ b/elf/neededtest4.c @@ -5,6 +5,8 @@ #include <stdlib.h> #include <string.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + static int check_loaded_objects (const char **loaded) { @@ -24,7 +26,7 @@ check_loaded_objects (const char **loaded) printf(" Name\n"); printf(" --------------------------------------------------------\n"); - for (lm = _r_debug.r_map; lm; lm = lm->l_next) + for (lm = MAPS; lm; lm = lm->l_next) { if (lm->l_name && lm->l_name[0]) printf(" %s, count = %d\n", lm->l_name, (int) lm->l_direct_opencount); diff --git a/elf/rtld-Rules b/elf/rtld-Rules index 61143b180c..01fbbdf0c5 100644 --- a/elf/rtld-Rules +++ b/elf/rtld-Rules @@ -1,6 +1,6 @@ # Subroutine makefile for compiling libc modules linked into dynamic linker. -# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2005, 2006 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 @@ -72,10 +72,16 @@ include $(patsubst %,../o-iterator.mk,$(object-suffixes-left)) # This is how we descend into each subdirectory. See below. define rtld-subdir-make -$(MAKE) -C ../$* objdir=$(objdir) -f Makefile -f ../elf/rtld-Rules rtld-all \ +$(MAKE) $(subdir-args) objdir=$(objdir) \ + -f Makefile -f ../elf/rtld-Rules rtld-all \ rtld-modules='$(addprefix rtld-,$(rtld-$*))' endef +# See subdir-target-args in ../Makefile for the model. +subdir-args = subdir=$*$(if $($*-srcdir),\ + -C $($*-srcdir) ..=`pwd`/,\ + -C $(..)$* ..=../) + FORCE: else diff --git a/elf/sofini.c b/elf/sofini.c index 16e77e72ad..5e06f0ca92 100644 --- a/elf/sofini.c +++ b/elf/sofini.c @@ -8,12 +8,10 @@ static void (*const __DTOR_END__[1]) (void) __attribute__ ((used, section (".dtors"))) = { 0 }; -#ifdef HAVE_DWARF2_UNWIND_INFO /* Terminate the frame unwind info section with a 4byte 0 as a sentinel; this would be the 'length' field in a real FDE. */ typedef unsigned int ui32 __attribute__ ((mode (SI))); -static ui32 __FRAME_END__[1] - __attribute__ ((used, section (".eh_frame"))) - = { 0 }; -#endif +static const ui32 __FRAME_END__[1] + __attribute__ ((used, section (".eh_frame"))) + = { 0 }; diff --git a/elf/soinit.c b/elf/soinit.c index 29e4707ceb..c0a881ef5d 100644 --- a/elf/soinit.c +++ b/elf/soinit.c @@ -6,10 +6,6 @@ #include <libc-internal.h> #include <stdlib.h> -#ifdef HAVE_DWARF2_UNWIND_INFO_STATIC -# include <gccframe.h> -#endif - static void (*const __CTOR_LIST__[1]) (void) __attribute__ ((section (".ctors"))) = { (void (*) (void)) -1 }; @@ -24,21 +20,9 @@ run_hooks (void (*const list[]) (void)) (**list) (); } -#ifdef HAVE_DWARF2_UNWIND_INFO -static char __EH_FRAME_BEGIN__[] - __attribute__ ((section (".eh_frame"))) - = { }; -# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC -extern void __register_frame_info (const void *, struct object *); -extern void __register_frame_info_bases (const void *, struct object *, - void *, void *); -extern void __deregister_frame_info (const void *); -extern void __deregister_frame_info_bases (const void *); -# else -extern void __register_frame (const void *); -extern void __deregister_frame (const void *); -# endif -#endif +static const char __EH_FRAME_BEGIN__[] + __attribute__ ((used, section (".eh_frame"))) + = { }; /* This function will be called from _init in init-first.c. */ void @@ -46,33 +30,6 @@ __libc_global_ctors (void) { /* Call constructor functions. */ run_hooks (__CTOR_LIST__); - -#ifdef HAVE_DWARF2_UNWIND_INFO -# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC - { - static struct object ob; -# if defined CRT_GET_RFIB_TEXT || defined CRT_GET_RFIB_DATA - void *tbase, *dbase; - -# ifdef CRT_GET_RFIB_TEXT - CRT_GET_RFIB_TEXT (tbase); -# else - tbase = NULL; -# endif -# ifdef CRT_GET_RFIB_DATA - CRT_GET_RFIB_DATA (dbase); -# else - dbase = NULL; -# endif - __register_frame_info_bases (__EH_FRAME_BEGIN__, &ob, tbase, dbase); -# else - __register_frame_info (__EH_FRAME_BEGIN__, &ob); -# endif - } -# else - __register_frame (__EH_FRAME_BEGIN__); -# endif -#endif } @@ -83,17 +40,6 @@ __libc_fini (void) { /* Call destructor functions. */ run_hooks (__DTOR_LIST__); -#ifdef HAVE_DWARF2_UNWIND_INFO -# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC -# if defined CRT_GET_RFIB_TEXT || defined CRT_GET_RFIB_DATA - __deregister_frame_info_bases (__EH_FRAME_BEGIN__); -# else - __deregister_frame_info (__EH_FRAME_BEGIN__); -# endif -# else - __deregister_frame (__EH_FRAME_BEGIN__); -# endif -#endif } void (*_fini_ptr) (void) __attribute__ ((section (".fini_array"))) diff --git a/elf/tst-tls-dlinfo.c b/elf/tst-tls-dlinfo.c new file mode 100644 index 0000000000..e97b5081fd --- /dev/null +++ b/elf/tst-tls-dlinfo.c @@ -0,0 +1,92 @@ +#include <dlfcn.h> +#include <stdio.h> +#include <stdlib.h> + +#include <tls.h> + + +#define TEST_FUNCTION do_test () +static int +do_test (void) +{ +#ifdef USE_TLS + static const char modname[] = "tst-tlsmod2.so"; + int result = 0; + int *foop; + int (*fp) (int, int *); + void *h; + + h = dlopen (modname, RTLD_LAZY); + if (h == NULL) + { + printf ("cannot open '%s': %s\n", modname, dlerror ()); + exit (1); + } + + fp = dlsym (h, "in_dso"); + if (fp == NULL) + { + printf ("cannot get symbol 'in_dso': %s\n", dlerror ()); + exit (1); + } + + size_t modid = -1; + if (dlinfo (h, RTLD_DI_TLS_MODID, &modid)) + { + printf ("dlinfo RTLD_DI_TLS_MODID failed: %s\n", dlerror ()); + result = 1; + } + else + printf ("dlinfo says TLS module ID %Zu\n", modid); + + void *block; + if (dlinfo (h, RTLD_DI_TLS_DATA, &block)) + { + printf ("dlinfo RTLD_DI_TLS_DATA failed: %s\n", dlerror ()); + result = 1; + } + else if (block != NULL) + { + printf ("dlinfo RTLD_DI_TLS_DATA says %p but should be unallocated\n", + block); + result = 1; + } + + result |= fp (0, NULL); + + foop = dlsym (h, "foo"); + if (foop == NULL) + { + printf ("cannot get symbol 'foo' the second time: %s\n", dlerror ()); + exit (1); + } + if (*foop != 16) + { + puts ("foo != 16"); + result = 1; + } + + /* Now the module's TLS block has been used and should appear. */ + if (dlinfo (h, RTLD_DI_TLS_DATA, &block)) + { + printf ("dlinfo RTLD_DI_TLS_DATA failed the second time: %s\n", + dlerror ()); + result = 1; + } + else if (block != foop) + { + printf ("dlinfo RTLD_DI_TLS_DATA says %p but should be %p\n", + block, foop); + result = 1; + } + + dlclose (h); + + return result; +#else + return 0; +#endif +} + + +#include "../test-skeleton.c" diff --git a/elf/unload.c b/elf/unload.c index ffb33482c0..4566f226f8 100644 --- a/elf/unload.c +++ b/elf/unload.c @@ -9,8 +9,10 @@ #include <stdio.h> #include <stdlib.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + #define OUT \ - for (map = _r_debug.r_map; map != NULL; map = map->l_next) \ + for (map = MAPS; map != NULL; map = map->l_next) \ if (map->l_type == lt_loaded) \ printf ("name = \"%s\", direct_opencount = %d\n", \ map->l_name, (int) map->l_direct_opencount); \ diff --git a/elf/unload2.c b/elf/unload2.c index e14c6f06af..eef2bfd426 100644 --- a/elf/unload2.c +++ b/elf/unload2.c @@ -6,8 +6,10 @@ #include <stdio.h> #include <stdlib.h> +#define MAPS ((struct link_map *) _r_debug.r_map) + #define OUT \ - for (map = _r_debug.r_map; map != NULL; map = map->l_next) \ + for (map = MAPS; map != NULL; map = map->l_next) \ if (map->l_type == lt_loaded) \ printf ("name = \"%s\", direct_opencount = %d\n", \ map->l_name, (int) map->l_direct_opencount); \ |