[git commit ldso-future 1/1] ldso/include: reorganize a bit headers

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


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

Move init_fini_list structure to dl-hash.h.
Use __UCLIBC_HAS_TLS__ instead of USE_TLS.

Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
 ldso/include/dl-defs.h    |    2 +
 ldso/include/dl-elf.h     |    4 +--
 ldso/include/dl-hash.h    |   16 +++++++++-
 ldso/include/dl-syscall.h |   14 +++++---
 ldso/include/ldso.h       |   77 ++++++++++++++++++---------------------------
 5 files changed, 57 insertions(+), 56 deletions(-)

diff --git a/ldso/include/dl-defs.h b/ldso/include/dl-defs.h
index c81ff30..d5aaad1 100644
--- a/ldso/include/dl-defs.h
+++ b/ldso/include/dl-defs.h
@@ -8,6 +8,8 @@
 #ifndef _DL_DEFS_H
 #define _DL_DEFS_H
 
+#include <features.h>
+
 #define FLAG_ANY             -1
 #define FLAG_TYPE_MASK       0x00ff
 #define FLAG_LIBC4           0x0000
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 2d2a72a..de8fade 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -10,9 +10,9 @@
 
 #include <features.h>
 #include <bits/wordsize.h>
-#include <dl-string.h> /* before elf.h to get ELF_USES_RELOCA right */
 #include <elf.h>
 #include <link.h>
+
 #include <dl-defs.h>
 
 /* Forward declarations for stuff defined in dl-hash.h */
@@ -215,12 +215,10 @@ unsigned int __dl_parse_dynamic_info(ElfW(Dyn) *dpnt, ElfW(Word) dynamic_info[],
    itself, e.g., a function descriptor.  */
 #define ELF_RTYPE_CLASS_DLSYM 0x80000000
 
-
 /* Convert between the Linux flags for page protections and the
    ones specified in the ELF standard. */
 #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
 		    (((X) & PF_W) ? PROT_WRITE : 0) | \
 		    (((X) & PF_X) ? PROT_EXEC : 0))
 
-
 #endif /* _DL_ELF_H */
diff --git a/ldso/include/dl-hash.h b/ldso/include/dl-hash.h
index 699e691..0a7d9fd 100644
--- a/ldso/include/dl-hash.h
+++ b/ldso/include/dl-hash.h
@@ -8,15 +8,29 @@
 #ifndef _DL_HASH_H
 #define _DL_HASH_H
 
+#include <features.h>
+
+#include <elf.h>
+#include <link.h>
+
+#include <dlfcn.h>
 #ifndef RTLD_NEXT
 #define RTLD_NEXT	((void*)-1)
 #endif
 
+#include <dl-elf.h>	/* DYNAMIC_SIZE */
+
 struct init_fini {
 	struct elf_resolve **init_fini;
 	unsigned long nlist; /* Number of entries in init_fini */
 };
 
+/* For INIT/FINI dependency sorting. */
+struct init_fini_list {
+	struct init_fini_list *next;
+	struct elf_resolve *tpnt;
+};
+
 struct dyn_elf {
   struct elf_resolve * dyn;
   struct dyn_elf * next_handle;  /* Used by dlopen et al. */
@@ -40,7 +54,7 @@ struct elf_resolve {
   struct elf_resolve * prev;
   /* Nothing after this address is used by gdb. */
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
   /* Thread-local storage related info.  */
 
   /* Start of the initialization image.  */
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h
index d0aa156..d68d8a8 100644
--- a/ldso/include/dl-syscall.h
+++ b/ldso/include/dl-syscall.h
@@ -8,11 +8,11 @@
 #ifndef _DL_SYSCALL_H
 #define _DL_SYSCALL_H
 
-/* Pull in the arch specific syscall implementation */
-#include <dl-syscalls.h>
-/*  For MAP_ANONYMOUS -- differs between platforms */
-#define _SYS_MMAN_H 1
-#include <bits/mman.h>
+#include <features.h>
+
+#include <sys/syscall.h>
+#include <sys/mman.h>	/* MAP_ANONYMOUS -- differs between platforms */
+
 /* Pull in whatever this particular arch's kernel thinks the kernel version of
  * struct stat should look like.  It turns out that each arch has a different
  * opinion on the subject, and different kernel revs use different names... */
@@ -24,10 +24,12 @@
 #include <bits/kernel_stat.h>
 #include <bits/kernel_types.h>
 
-/* Protection bits.  */
+/* Protection bits. -- instead of including sys/stat.h */
 #define	S_ISUID		04000	/* Set user ID on execution.  */
 #define	S_ISGID		02000	/* Set group ID on execution.  */
 
+/* Pull in the arch specific syscall implementation */
+#include <dl-syscalls.h>
 
 /* Here are the definitions for some syscalls that are used
    by the dynamic linker.  The idea is that we want to be able
diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h
index 1127a61..ea19c92 100644
--- a/ldso/include/ldso.h
+++ b/ldso/include/ldso.h
@@ -1,53 +1,43 @@
 /* vi: set sw=4 ts=4: */
 /*
- * Copyright (C) 2000-2005 by Erik Andersen <andersen at codepoet.org>
+ * Copyright (C) 2000-2011 by Erik Andersen <andersen at codepoet.org>
  *
- * GNU Lesser General Public License version 2.1 or later.
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  */
 
 #ifndef _LDSO_H
 #define _LDSO_H
 
 #include <features.h>
-
-/* Prepare for the case that `__builtin_expect' is not available.  */
-#if defined __GNUC__ && __GNUC__ == 2 && __GNUC_MINOR__ < 96
-#define __builtin_expect(x, expected_value) (x)
-#endif
-#ifndef likely
-# define likely(x)	__builtin_expect((!!(x)),1)
-#endif
-#ifndef unlikely
-# define unlikely(x)	__builtin_expect((!!(x)),0)
-#endif
-#ifndef __LINUX_COMPILER_H
-#define __LINUX_COMPILER_H
-#endif
-
-/* Pull in compiler and arch stuff */
-#include <stdlib.h>
+#define __need_NULL
+#include <stddef.h>
 #include <stdarg.h>
-#define _FCNTL_H
-#include <bits/fcntl.h>
-#include <bits/wordsize.h>
-/* Pull in the arch specific type information */
+#include <stdlib.h>
 #include <sys/types.h>
+#include <bits/wordsize.h>
+#include <elf.h>
+#include <link.h>
 /* Pull in the arch specific page size */
 #include <bits/uClibc_page.h>
-/* Pull in the ldso syscalls and string functions */
+
+#include <dl-defs.h>
+
 #ifndef __ARCH_HAS_NO_SHARED__
-#include <dl-syscall.h>
-#include <dl-string.h>
+#define _FCNTL_H
+#include <bits/fcntl.h>
 #include <dlfcn.h>
-/* Now the ldso specific headers */
+
+#include <dl-string.h>
 #include <dl-elf.h>
+#include <dl-hash.h>
+#include <dl-syscall.h>
 #ifdef __UCLIBC_HAS_TLS__
-/* Defines USE_TLS */
-#include <tls.h>
+# include <tls.h>
+# include <dl-tls.h>
 #endif
-#include <dl-hash.h>
+#include <ldsodefs.h>
 
-/* common align masks, if not specified by sysdep headers */
+/* common align masks, if not specified by dl-sysdep.h */
 #ifndef ADDR_ALIGN
 #define ADDR_ALIGN (_dl_pagesize - 1)
 #endif
@@ -60,12 +50,6 @@
 #define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1)))
 #endif
 
-/* For INIT/FINI dependency sorting. */
-struct init_fini_list {
-	struct init_fini_list *next;
-	struct elf_resolve *tpnt;
-};
-
 /* Global variables used within the shared library loader */
 extern char *_dl_library_path attribute_hidden;	/* Where we look for libraries */
 extern char *_dl_preload;			/* Things to be loaded before the libs */
@@ -73,15 +57,11 @@ extern char *_dl_ldsopath;			/* Where the shared lib loader was found */
 extern const char *_dl_progname;		/* The name of the executable being run */
 extern size_t _dl_pagesize;			/* Store the page size for use later */
 
-#if defined(USE_TLS) && USE_TLS
+#ifdef __UCLIBC_HAS_TLS__
 extern void _dl_add_to_slotinfo (struct link_map  *l);
 extern void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
 #endif
 
-#ifdef USE_TLS
-void _dl_add_to_slotinfo (struct link_map  *l);
-void ** __attribute__ ((const)) _dl_initial_error_catch_tsd (void);
-#endif
 #ifdef __SUPPORT_LD_DEBUG__
 extern char *_dl_debug;
 extern char *_dl_debug_symbols;
@@ -100,6 +80,10 @@ extern int   _dl_debug_file;
 # define _dl_if_debug_dprint(fmt, args...) do {} while (0)
 /* disabled on purpose, _dl_debug_file should be guarded by __SUPPORT_LD_DEBUG__
 # define _dl_debug_file 2*/
+
+# define debug_sym(symtab, strtab, symtab_index)
+# define debug_reloc(symtab, strtab, rpnt)
+
 #endif /* __SUPPORT_LD_DEBUG__ */
 
 #ifdef IS_IN_rtld
@@ -129,14 +113,17 @@ extern int   _dl_debug_file;
 #define NULL ((void *) 0)
 #endif
 
+#ifdef IS_IN_rtld
 extern void *_dl_malloc(size_t size);
 extern void *_dl_calloc(size_t __nmemb, size_t __size);
 extern void *_dl_realloc(void *__ptr, size_t __size);
 extern void _dl_free(void *);
-#ifdef IS_IN_rtld
 extern char *_dl_strdup(const char *string) attribute_hidden;
 extern void _dl_dprintf(int, const char *, ...) attribute_hidden;
 #else
+# include <stdlib.h>
+# define _dl_malloc malloc
+# define _dl_free free
 # include <string.h>
 # define _dl_strdup strdup
 # include <stdio.h>
@@ -162,8 +149,6 @@ extern void _dl_get_ready_to_run(struct elf_resolve *tpnt, DL_LOADADDR_TYPE load
 #include <dl-inlines.h>
 #endif
 
-#else /* __ARCH_HAS_NO_SHARED__ */
-#include <dl-defs.h>
-#endif
+#endif /* __ARCH_HAS_NO_SHARED__ */
 
 #endif /* _LDSO_H */
-- 
1.7.3.4



More information about the uClibc-cvs mailing list