[git commit ldso-future] ldsodefs.h: move all structure and function prototypes from dl-elf.h and dl-hash.h
Peter S. Mazinger
ps.m at gmx.net
Mon Apr 11 11:27:03 UTC 2011
commit: http://git.uclibc.org/uClibc/commit/?id=aa10066065d79aff4a364be8df0a7a79008ca650
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/ldso-future
non-ldso files should include only this file.
Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
ldso/include/dl-elf.h | 34 +--------
ldso/include/dl-hash.h | 136 -------------------------------
ldso/include/ldso.h | 3 +-
ldso/include/ldsodefs.h | 170 ++++++++++++++++++++++++++++++++++++++-
ldso/ldso/dl-array.c | 2 +-
ldso/ldso/dl-symbols.c | 4 +-
libc/misc/elf/dl-iterate-phdr.c | 8 +-
7 files changed, 177 insertions(+), 180 deletions(-)
diff --git a/ldso/include/dl-elf.h b/ldso/include/dl-elf.h
index 0103d3d..41a5997 100644
--- a/ldso/include/dl-elf.h
+++ b/ldso/include/dl-elf.h
@@ -13,26 +13,7 @@
#include <elf.h>
#include <link.h>
-#include <dl-defs.h>
-
-/* Forward declarations for stuff defined in dl-hash.h */
-struct dyn_elf;
-struct elf_resolve;
-
-#ifdef __LDSO_CACHE_SUPPORT__
-extern int _dl_map_cache(void);
-extern int _dl_unmap_cache(void);
-#else
-static __inline__ void _dl_map_cache(void) { }
-static __inline__ void _dl_unmap_cache(void) { }
-#endif
-
-/* Function prototypes for non-static stuff in dl-elf.c and elfinterp.c */
-extern struct elf_resolve * _dl_load_shared_library(int secure,
- struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
- int trace_loaded_objects);
-extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
-extern void _dl_protect_relro (struct elf_resolve *l) internal_function;
+#include <ldsodefs.h>
/*
* Bitsize related settings for things ElfW()
@@ -75,19 +56,6 @@ extern void _dl_protect_relro (struct elf_resolve *l) internal_function;
# define UNSUPPORTED_RELOC_STR "RELA"
#endif
-/* OS and/or GNU dynamic extensions */
-#ifdef __LDSO_GNU_HASH_SUPPORT__
-# define OS_NUM 2 /* for DT_RELOCCOUNT and DT_GNU_HASH entries */
-#else
-# define OS_NUM 1 /* for DT_RELOCCOUNT entry */
-#endif
-
-#ifndef ARCH_DYNAMIC_INFO
- /* define in arch specific code, if needed */
-# define ARCH_NUM 0
-#endif
-
-#define DYNAMIC_SIZE (DT_NUM+OS_NUM+ARCH_NUM)
/* Keep ARCH specific entries into dynamic section at the end of the array */
#define DT_RELCONT_IDX (DYNAMIC_SIZE - OS_NUM - ARCH_NUM)
diff --git a/ldso/include/dl-hash.h b/ldso/include/dl-hash.h
index 3e25692..c2cc50e 100644
--- a/ldso/include/dl-hash.h
+++ b/ldso/include/dl-hash.h
@@ -8,153 +8,17 @@
#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. */
- struct init_fini init_fini;
- struct dyn_elf * next;
- struct dyn_elf * prev;
-};
-
-struct symbol_ref {
- const ElfW(Sym) *sym;
- struct elf_resolve *tpnt;
-};
-
-struct elf_resolve {
- /* These entries must be in this order to be compatible with the interface used
- by gdb to obtain the list of symbols. */
- DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */
- char *libname; /* Absolute file name object was found in. */
- ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */
- struct elf_resolve * next;
- struct elf_resolve * prev;
- /* Nothing after this address is used by gdb. */
-
-#ifdef __UCLIBC_HAS_TLS__
- /* Thread-local storage related info. */
-
- /* Start of the initialization image. */
- void *l_tls_initimage;
- /* Size of the initialization image. */
- size_t l_tls_initimage_size;
- /* Size of the TLS block. */
- size_t l_tls_blocksize;
- /* Alignment requirement of the TLS block. */
- size_t l_tls_align;
- /* Offset of first byte module alignment. */
- size_t l_tls_firstbyte_offset;
-# ifndef NO_TLS_OFFSET
-# define NO_TLS_OFFSET 0
-# endif
- /* For objects present at startup time: offset in the static TLS block. */
- ptrdiff_t l_tls_offset;
- /* Index of the module in the dtv array. */
- size_t l_tls_modid;
- /* Nonzero if _dl_init_static_tls should be called for this module */
- unsigned int l_need_tls_init:1;
-#endif
-
- ElfW(Addr) mapaddr;
- enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
- struct dyn_elf * symbol_scope;
- unsigned short usage_count;
- unsigned short int init_flag;
- unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
- Elf_Symndx nbucket;
-
-#ifdef __LDSO_GNU_HASH_SUPPORT__
- /* Data needed to support GNU hash style */
- Elf32_Word l_gnu_bitmask_idxbits;
- Elf32_Word l_gnu_shift;
- const ElfW(Addr) *l_gnu_bitmask;
-
- union
- {
- const Elf32_Word *l_gnu_chain_zero;
- const Elf_Symndx *elf_buckets;
- };
-#else
- Elf_Symndx *elf_buckets;
-#endif
-
- struct init_fini_list *init_fini;
- struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
- /*
- * These are only used with ELF style shared libraries
- */
- Elf_Symndx nchain;
-
-#ifdef __LDSO_GNU_HASH_SUPPORT__
- union
- {
- const Elf32_Word *l_gnu_buckets;
- const Elf_Symndx *chains;
- };
-#else
- Elf_Symndx *chains;
-#endif
- ElfW(Word) dynamic_info[DYNAMIC_SIZE];
-
- unsigned long n_phent;
- ElfW(Phdr) * ppnt;
-
- ElfW(Addr) relro_addr;
- size_t relro_size;
-
- dev_t st_dev; /* device */
- ino_t st_ino; /* inode */
-
-#ifdef __powerpc__
- /* this is used to store the address of relocation data words, so
- * we don't have to calculate it every time, which requires a divide */
- unsigned long data_words;
-#endif
-
-#ifdef __FDPIC__
- /* Every loaded module holds a hashtable of function descriptors of
- functions defined in it, such that it's easy to release the
- memory when the module is dlclose()d. */
- struct funcdesc_ht *funcdesc_ht;
-#endif
-};
-
#define RELOCS_DONE 0x000001
#define JMP_RELOCS_DONE 0x000002
#define INIT_FUNCS_CALLED 0x000004
#define FINI_FUNCS_CALLED 0x000008
#define DL_OPENED 0x000010
-extern struct dyn_elf * _dl_symbol_tables;
-extern struct elf_resolve * _dl_loaded_modules;
-
-extern char *_dl_find_hash(const char *name, struct dyn_elf *rpnt,
- struct elf_resolve *mytpnt, int type_class,
- struct symbol_ref *symbol);
-
#define LD_ERROR_NOFILE 1
#define LD_ERROR_NOZERO 2
#define LD_ERROR_NOTELF 3
diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h
index 9a2fc74..201db68 100644
--- a/ldso/include/ldso.h
+++ b/ldso/include/ldso.h
@@ -21,7 +21,7 @@
/* Pull in the arch specific page size */
#include <bits/uClibc_page.h>
-#include <dl-defs.h>
+#include <ldsodefs.h>
#ifndef __ARCH_HAS_NO_SHARED__
#include <dlfcn.h>
@@ -34,7 +34,6 @@
# include <tls.h>
# include <dl-tls.h>
#endif
-#include <ldsodefs.h>
/* common align masks, if not specified by dl-sysdep.h */
#ifndef ADDR_ALIGN
diff --git a/ldso/include/ldsodefs.h b/ldso/include/ldsodefs.h
index ebfee72..6454dd4 100644
--- a/ldso/include/ldsodefs.h
+++ b/ldso/include/ldsodefs.h
@@ -1,14 +1,154 @@
#ifndef _LDSODEFS_H
-#define _LDSODEFS_H 1
-
-#include <bits/kernel-features.h>
+#define _LDSODEFS_H
#include <features.h>
#include <stdbool.h>
+#include <elf.h>
+#include <link.h>
+#include <bits/kernel-features.h>
+
+#include <dl-defs.h>
#ifdef __UCLIBC_HAS_TLS__
-#include <tls.h>
+# include <tls.h>
+#endif
+
+/* OS and/or GNU dynamic extensions */
+#ifdef __LDSO_GNU_HASH_SUPPORT__
+# define OS_NUM 2 /* for DT_RELOCCOUNT and DT_GNU_HASH entries */
+#else
+# define OS_NUM 1 /* for DT_RELOCCOUNT entry */
+#endif
+
+#ifndef ARCH_DYNAMIC_INFO
+ /* define in arch specific code, if needed */
+# define ARCH_NUM 0
#endif
+#define DYNAMIC_SIZE (DT_NUM+OS_NUM+ARCH_NUM)
+
+struct elf_resolve;
+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. */
+ struct init_fini init_fini;
+ struct dyn_elf * next;
+ struct dyn_elf * prev;
+};
+
+struct symbol_ref {
+ const ElfW(Sym) *sym;
+ struct elf_resolve *tpnt;
+};
+
+struct elf_resolve {
+ /* These entries must be in this order to be compatible with the interface used
+ by gdb to obtain the list of symbols. */
+ DL_LOADADDR_TYPE loadaddr; /* Base address shared object is loaded at. */
+ char *libname; /* Absolute file name object was found in. */
+ ElfW(Dyn) *dynamic_addr; /* Dynamic section of the shared object. */
+ struct elf_resolve * next;
+ struct elf_resolve * prev;
+ /* Nothing after this address is used by gdb. */
+
+#ifdef __UCLIBC_HAS_TLS__
+ /* Thread-local storage related info. */
+
+ /* Start of the initialization image. */
+ void *l_tls_initimage;
+ /* Size of the initialization image. */
+ size_t l_tls_initimage_size;
+ /* Size of the TLS block. */
+ size_t l_tls_blocksize;
+ /* Alignment requirement of the TLS block. */
+ size_t l_tls_align;
+ /* Offset of first byte module alignment. */
+ size_t l_tls_firstbyte_offset;
+# ifndef NO_TLS_OFFSET
+# define NO_TLS_OFFSET 0
+# endif
+ /* For objects present at startup time: offset in the static TLS block. */
+ ptrdiff_t l_tls_offset;
+ /* Index of the module in the dtv array. */
+ size_t l_tls_modid;
+ /* Nonzero if _dl_init_static_tls should be called for this module */
+ unsigned int l_need_tls_init:1;
+#endif
+
+ ElfW(Addr) mapaddr;
+ enum {elf_lib, elf_executable,program_interpreter, loaded_file} libtype;
+ struct dyn_elf * symbol_scope;
+ unsigned short usage_count;
+ unsigned short int init_flag;
+ unsigned long rtld_flags; /* RTLD_GLOBAL, RTLD_NOW etc. */
+ Elf_Symndx nbucket;
+
+#ifdef __LDSO_GNU_HASH_SUPPORT__
+ /* Data needed to support GNU hash style */
+ Elf32_Word l_gnu_bitmask_idxbits;
+ Elf32_Word l_gnu_shift;
+ const ElfW(Addr) *l_gnu_bitmask;
+
+ union
+ {
+ const Elf32_Word *l_gnu_chain_zero;
+ const Elf_Symndx *elf_buckets;
+ };
+#else
+ Elf_Symndx *elf_buckets;
+#endif
+
+ struct init_fini_list *init_fini;
+ struct init_fini_list *rtld_local; /* keep tack of RTLD_LOCAL libs in same group */
+ /*
+ * These are only used with ELF style shared libraries
+ */
+ Elf_Symndx nchain;
+
+#ifdef __LDSO_GNU_HASH_SUPPORT__
+ union
+ {
+ const Elf32_Word *l_gnu_buckets;
+ const Elf_Symndx *chains;
+ };
+#else
+ Elf_Symndx *chains;
+#endif
+ ElfW(Word) dynamic_info[DYNAMIC_SIZE];
+
+ unsigned long n_phent;
+ ElfW(Phdr) * ppnt;
+
+ ElfW(Addr) relro_addr;
+ size_t relro_size;
+
+ dev_t st_dev; /* device */
+ ino_t st_ino; /* inode */
+
+#ifdef __powerpc__
+ /* this is used to store the address of relocation data words, so
+ * we don't have to calculate it every time, which requires a divide */
+ unsigned long data_words;
+#endif
+
+#ifdef __FDPIC__
+ /* Every loaded module holds a hashtable of function descriptors of
+ functions defined in it, such that it's easy to release the
+ memory when the module is dlclose()d. */
+ struct funcdesc_ht *funcdesc_ht;
+#endif
+};
+
#ifdef __mips__
/* The MIPS ABI specifies that the dynamic section has to be read-only. */
@@ -59,6 +199,28 @@ struct elf_resolve;
extern void _dl_run_init_array(struct elf_resolve *);
extern void _dl_run_fini_array(struct elf_resolve *);
+extern struct dyn_elf * _dl_symbol_tables;
+extern struct elf_resolve * _dl_loaded_modules;
+
+extern char *_dl_find_hash(const char *name, struct dyn_elf *rpnt,
+ struct elf_resolve *mytpnt, int type_class,
+ struct symbol_ref *symbol);
+
+#ifdef __LDSO_CACHE_SUPPORT__
+extern int _dl_map_cache(void);
+extern int _dl_unmap_cache(void);
+#else
+static __inline__ void _dl_map_cache(void) { }
+static __inline__ void _dl_unmap_cache(void) { }
+#endif
+
+/* Function prototypes for non-static stuff in dl-elf.c and elfinterp.c */
+extern struct elf_resolve * _dl_load_shared_library(int secure,
+ struct dyn_elf **rpnt, struct elf_resolve *tpnt, char *full_libname,
+ int trace_loaded_objects);
+extern int _dl_fixup(struct dyn_elf *rpnt, int flag);
+extern void _dl_protect_relro (struct elf_resolve *l) internal_function;
+
#ifdef __UCLIBC_HAS_TLS__
/* Determine next available module ID. */
extern size_t _dl_next_tls_modid (void) internal_function attribute_hidden;
diff --git a/ldso/ldso/dl-array.c b/ldso/ldso/dl-array.c
index cc5e197..edbf59d 100644
--- a/ldso/ldso/dl-array.c
+++ b/ldso/ldso/dl-array.c
@@ -28,7 +28,7 @@
* SUCH DAMAGE.
*/
-#include <ldso.h>
+#include <ldsodefs.h>
static void _dl_run_array_forward(unsigned long array, unsigned long size,
DL_LOADADDR_TYPE loadaddr)
diff --git a/ldso/ldso/dl-symbols.c b/ldso/ldso/dl-symbols.c
index 0997536..b03d516 100644
--- a/ldso/ldso/dl-symbols.c
+++ b/ldso/ldso/dl-symbols.c
@@ -16,7 +16,9 @@
* as well as all of the other good stuff in the binary.
*/
-#include <ldso.h>
+#define __need_NULL
+#include <stddef.h>
+#include <ldsodefs.h>
struct elf_resolve *_dl_loaded_modules = NULL;
diff --git a/libc/misc/elf/dl-iterate-phdr.c b/libc/misc/elf/dl-iterate-phdr.c
index 5b86db0..188ab1e 100644
--- a/libc/misc/elf/dl-iterate-phdr.c
+++ b/libc/misc/elf/dl-iterate-phdr.c
@@ -11,12 +11,14 @@
Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
-
-#include <link.h>
-#include <ldso.h>
+#include <features.h>
/* we want this in libc but nowhere else */
#ifdef __USE_GNU
+# define __need_NULL
+# include <stddef.h>
+# include <link.h>
+# include <ldsodefs.h>
static int
__dl_iterate_phdr (int (*callback) (struct dl_phdr_info *info, size_t size, void *data), void *data)
--
1.7.3.4
More information about the uClibc-cvs
mailing list