[git commit ldso-future 1/1] ldso: use only ldso.h in *.c files

Peter S. Mazinger ps.m at gmx.net
Wed Mar 30 11:53:36 UTC 2011


commit: http://git.uclibc.org/uClibc/commit/?id=d63c19be29ec0ecb522c3f93d6a2f7a8631b5755
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/ldso-future

While there, replace USE_TLS with __UCLIBC_HAS_TLS__

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 ldso/ldso/dl-array.c       |    3 +--
 ldso/ldso/dl-elf.c         |   11 +++++------
 ldso/ldso/dl-hash.c        |    5 +++--
 ldso/ldso/dl-startup.c     |    7 +++----
 ldso/ldso/dl-symbols.c     |    1 +
 ldso/ldso/dl-tls.c         |    3 +--
 ldso/ldso/ldso.c           |   25 +++++++++++++------------
 ldso/ldso/mips/dl-sysdep.h |    4 ++--
 ldso/libdl/libdl.c         |   20 ++++++++++----------
 9 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/ldso/ldso/dl-array.c b/ldso/ldso/dl-array.c
index dabb466..9e7508c 100644
--- a/ldso/ldso/dl-array.c
+++ b/ldso/ldso/dl-array.c
@@ -28,8 +28,7 @@
  * SUCH DAMAGE.
  */
 
-
-#include "ldso.h"
+#include <ldso.h>
 
 static void _dl_run_array_forward(unsigned long array, unsigned long size,
                                   DL_LOADADDR_TYPE loadaddr)
diff --git a/ldso/ldso/dl-elf.c b/ldso/ldso/dl-elf.c
index 0696e4f..8214cab 100644
--- a/ldso/ldso/dl-elf.c
+++ b/ldso/ldso/dl-elf.c
@@ -29,8 +29,7 @@
  * SUCH DAMAGE.
  */
 
-
-#include "ldso.h"
+#include <ldso.h>
 
 #ifdef __LDSO_CACHE_SUPPORT__
 
@@ -329,7 +328,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
 	ElfW(Dyn) *dpnt;
 	struct elf_resolve *tpnt;
 	ElfW(Phdr) *ppnt;
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	ElfW(Phdr) *tlsppnt = NULL;
 #endif
 	char *status, *header;
@@ -438,7 +437,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
 			}
 		}
 		if (ppnt->p_type == PT_TLS) {
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 			if (ppnt->p_memsz == 0)
 				/* Nothing to do for an empty segment.  */
 				continue;
@@ -734,7 +733,7 @@ struct elf_resolve *_dl_load_elf_shared_library(int secure,
 	tpnt->n_phent = epnt->e_phnum;
 	tpnt->rtld_flags |= rtld_flags;
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	if (tlsppnt) {
 		_dl_debug_early("Found TLS header for %s\n", libname);
 # if NO_TLS_OFFSET != 0
@@ -928,7 +927,7 @@ int _dl_fixup(struct dyn_elf *rpnt, int now_flag)
 #if 0
 /* _dl_add_to_slotinfo is called by init_tls() for initial DSO
    or by dlopen() for dynamically loaded DSO. */
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	/* Add object to slot information data if necessasy. */
 	if (tpnt->l_tls_blocksize != 0 && tls_init_tp_called)
 		_dl_add_to_slotinfo ((struct link_map *) tpnt);
diff --git a/ldso/ldso/dl-hash.c b/ldso/ldso/dl-hash.c
index 6345487..4ece1ad 100644
--- a/ldso/ldso/dl-hash.c
+++ b/ldso/ldso/dl-hash.c
@@ -30,6 +30,7 @@
  * SUCH DAMAGE.
  */
 
+#include <ldso.h>
 
 /* Various symbol table handling functions, including symbol lookup */
 /*
@@ -158,7 +159,7 @@ static __attribute_noinline__ const ElfW(Sym) *
 check_match (const ElfW(Sym) *sym, char *strtab, const char* undef_name, int type_class)
 {
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	if ((sym->st_value == 0 && (ELF_ST_TYPE(sym->st_info) != STT_TLS))
 		      || (type_class & (sym->st_shndx == SHN_UNDEF)))
 		/* No value or undefined symbol itself */
@@ -340,7 +341,7 @@ char *_dl_find_hash(const char *name, struct dyn_elf *rpnt, struct elf_resolve *
 
 	if (sym) {
 		/* At this point we have found the requested symbol, do binding */
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 		if (ELF_ST_TYPE(sym->st_info) == STT_TLS) {
 			_dl_assert(sym_ref != NULL);
 			sym_ref->tpnt = tpnt;
diff --git a/ldso/ldso/dl-startup.c b/ldso/ldso/dl-startup.c
index 27cbc3d..09b0a43 100644
--- a/ldso/ldso/dl-startup.c
+++ b/ldso/ldso/dl-startup.c
@@ -89,11 +89,10 @@
  * the user's application.
  */
 
-#include "ldso.h"
+#include <ldso.h>
 
 /* Pull in all the arch specific stuff */
-#include "dl-startup.h"
-#include <ldsodefs.h>
+#include <dl-startup.h>
 
 /* Static declarations */
 static int (*_dl_elf_main) (int, char **, char **);
@@ -216,7 +215,7 @@ DL_START(unsigned long args)
 	 *                 more work than what is done below for the
 	 *                 loader will have to happen.
 	 */
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	/* This was done by _dl_memset above. */
 	/* tpnt->l_tls_modid = 0; */
 # if NO_TLS_OFFSET != 0
diff --git a/ldso/ldso/dl-symbols.c b/ldso/ldso/dl-symbols.c
index e5c0021..0997536 100644
--- a/ldso/ldso/dl-symbols.c
+++ b/ldso/ldso/dl-symbols.c
@@ -15,6 +15,7 @@
  * in the system with pointers to all of the symbol, string, and hash tables,
  * as well as all of the other good stuff in the binary.
  */
+
 #include <ldso.h>
 
 struct elf_resolve *_dl_loaded_modules = NULL;
diff --git a/ldso/ldso/dl-tls.c b/ldso/ldso/dl-tls.c
index a3b5383..b4a466d 100644
--- a/ldso/ldso/dl-tls.c
+++ b/ldso/ldso/dl-tls.c
@@ -28,7 +28,7 @@
 
 #include <tls.h>
 #include <dl-tls.h>
-#include <ldsodefs.h>
+#include <ldso.h>
 
 void *(*_dl_calloc_function) (size_t __nmemb, size_t __size) = NULL;
 void *(*_dl_realloc_function) (void *__ptr, size_t __size) = NULL;
@@ -1035,4 +1035,3 @@ init_tls (void)
 }
 rtld_hidden_def (init_tls)
 #endif
-
diff --git a/ldso/ldso/ldso.c b/ldso/ldso/ldso.c
index 2f5c879..25acf02 100644
--- a/ldso/ldso/ldso.c
+++ b/ldso/ldso/ldso.c
@@ -30,15 +30,16 @@
  * SUCH DAMAGE.
  */
 
-#include "ldso.h"
-#include "unsecvars.h"
+#include <ldso.h>
+
+#include <unsecvars.h>
 
 /* Pull in common debug code */
 #include "dl-debug.c"
 
 #define ALLOW_ZERO_PLTGOT
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 #include "dl-tls.c"
 #endif
 
@@ -214,7 +215,7 @@ void _dl_free(void *p)
 		(*_dl_free_function) (p);
 }
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 void *_dl_memalign(size_t __boundary, size_t __size)
 {
 	void *result;
@@ -283,7 +284,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 	ElfW(Addr) relro_addr = 0;
 	size_t relro_size = 0;
 	struct stat st;
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	void *tcbp = NULL;
 #endif
 
@@ -364,7 +365,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 		unlazy = RTLD_NOW;
 	}
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	_dl_error_catch_tsd = &_dl_initial_error_catch_tsd;
 	_dl_init_static_tls = &_dl_nothread_init_static_tls;
 #endif
@@ -484,7 +485,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 
 		/* Discover any TLS sections if the target supports them. */
 		if (ppnt->p_type == PT_TLS) {
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 			if (ppnt->p_memsz > 0) {
 				app_tpnt->l_tls_blocksize = ppnt->p_memsz;
 				app_tpnt->l_tls_align = ppnt->p_align;
@@ -511,7 +512,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 	app_tpnt->relro_addr = relro_addr;
 	app_tpnt->relro_size = relro_size;
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	/*
 	 * Adjust the address of the TLS initialization image in
 	 * case the executable is actually an ET_DYN object.
@@ -921,7 +922,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 	}
 #endif
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	/* We do not initialize any of the TLS functionality unless any of the
 	 * initial modules uses TLS.  This makes dynamic loading of modules with
 	 * TLS impossible, but to support it requires either eagerly doing setup
@@ -974,7 +975,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 			_dl_protect_relro (tpnt);
 	}
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	if (!was_tls_init_tp_called && _dl_tls_max_dtv_idx > 0)
 		++_dl_tls_generation;
 
@@ -994,7 +995,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 			_dl_exit(30);
 		}
 	}
-#endif /* USE_TLS */
+#endif /* __UCLIBC_HAS_TLS__ */
 
 	/* OK, at this point things are pretty much ready to run.  Now we need
 	 * to touch up a few items that are required, and then we can let the
@@ -1061,7 +1062,7 @@ void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load_addr,
 	_dl_malloc_function = (void* (*)(size_t)) (intptr_t) _dl_find_hash(__C_SYMBOL_PREFIX__ "malloc",
 			_dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT, NULL);
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	/* Find the real functions and make ldso functions use them from now on */
 	_dl_calloc_function = (void* (*)(size_t, size_t)) (intptr_t)
 		_dl_find_hash(__C_SYMBOL_PREFIX__ "calloc", _dl_symbol_tables, NULL, ELF_RTYPE_CLASS_PLT, NULL);
diff --git a/ldso/ldso/mips/dl-sysdep.h b/ldso/ldso/mips/dl-sysdep.h
index 69fc8b9..16a245c 100644
--- a/ldso/ldso/mips/dl-sysdep.h
+++ b/ldso/ldso/mips/dl-sysdep.h
@@ -169,7 +169,7 @@ void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy)
 #define OFFS_ALIGN (0x10000000000UL-0x1000)
 #endif	/* O32 || N32 */
 
-#if defined USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 # if _MIPS_SIM == _MIPS_SIM_ABI64
 # define elf_machine_type_class(type) 					\
   ((((type) == R_MIPS_JUMP_SLOT || (type) == R_MIPS_TLS_DTPMOD64	\
@@ -187,7 +187,7 @@ void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy)
 #define elf_machine_type_class(type)					\
   ((((type) == R_MIPS_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT)			\
    | (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
-#endif /* USE_TLS */
+#endif /* __UCLIBC_HAS_TLS__ */
 
 #define OFFSET_GP_GOT 0x7ff0
 
diff --git a/ldso/libdl/libdl.c b/ldso/libdl/libdl.c
index 66190df..2c6d770 100644
--- a/ldso/libdl/libdl.c
+++ b/ldso/libdl/libdl.c
@@ -39,13 +39,13 @@
 #include <tls.h>
 #endif
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 #include <ldsodefs.h>
 extern void _dl_add_to_slotinfo(struct link_map  *l);
 #endif
 
 #ifdef SHARED
-# if defined(USE_TLS) && USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
 # include <dl-tls.h>
 extern struct link_map *_dl_update_slotinfo(unsigned long int req_modid);
 # endif
@@ -103,7 +103,7 @@ struct r_debug *_dl_debug_addr = NULL;
 #include "../ldso/dl-debug.c"
 
 
-# if defined(USE_TLS) && USE_TLS
+# ifdef __UCLIBC_HAS_TLS__
 /*
  * Giving this initialized value preallocates some surplus bytes in the
  * static TLS area, see __libc_setup_tls (libc-tls.c).
@@ -157,7 +157,7 @@ static const char *const dl_error_names[] = {
 };
 
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 #ifdef SHARED
 /*
  * Systems which do not have tls_index also probably have to define
@@ -275,7 +275,7 @@ void *dlopen(const char *libname, int flag)
 	unsigned int nlist, i;
 	struct elf_resolve **init_fini_list;
 	static bool _dl_init;
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	bool any_tls = false;
 #endif
 
@@ -510,7 +510,7 @@ void *dlopen(const char *libname, int flag)
 	/* TODO:  Should we set the protections of all pages back to R/O now ? */
 
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 
 	for (i=0; i < nlist; i++) {
 		struct elf_resolve *tmp_tpnt = init_fini_list[i];
@@ -661,7 +661,7 @@ void *dlsym(void *vhandle, const char *name)
 		tpnt = handle->dyn; /* Only search RTLD_GLOBAL objs if global object */
 	ret = _dl_find_hash(name2, handle, tpnt, 0, &sym_ref);
 
-#if defined(USE_TLS) && USE_TLS && defined SHARED
+#if defined __UCLIBC_HAS_TLS__ && defined SHARED
 	if (sym_ref.tpnt) {
 		/* The found symbol is a thread-local storage variable.
 		Return the address for to the current thread.  */
@@ -700,7 +700,7 @@ static int do_dlclose(void *vhandle, int need_fini)
 	struct dyn_elf *handle;
 	unsigned int end;
 	unsigned int i, j;
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	bool any_tls = false;
 	size_t tls_free_start = NO_TLS_OFFSET;
 	size_t tls_free_end = NO_TLS_OFFSET;
@@ -763,7 +763,7 @@ static int do_dlclose(void *vhandle, int need_fini)
 					end = ppnt->p_vaddr + ppnt->p_memsz;
 			}
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 			/* Do the cast to make things easy. */
 			tls_lmap = (struct link_map *) tpnt;
 
@@ -920,7 +920,7 @@ static int do_dlclose(void *vhandle, int need_fini)
 	free(handle->init_fini.init_fini);
 	free(handle);
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 	/* If we removed any object which uses TLS bump the generation counter.  */
 	if (any_tls) {
 		if (__builtin_expect(++_dl_tls_generation == 0, 0)) {
-- 
1.7.3.4



More information about the uClibc-cvs mailing list