Add glibc 2.2.5 linux support.

This commit is contained in:
agibert 2003-01-17 07:52:42 +00:00
parent 35becf27e2
commit 4457a6b1b5
2 changed files with 195 additions and 11 deletions

View File

@ -1,20 +1,20 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#ifdef LINUX #ifdef __linux
#else #else
#include <libelf.h> #include <libelf.h>
#endif #endif
#include <dlfcn.h> #include <dlfcn.h>
#include <ver.h> #include <ver.h>
VER_INFO_EXPORT (libver, "$Revision: 1.1 $", "$Name: $", __FILE__, "$Author: smas $") VER_INFO_EXPORT (libver, "$Revision: 1.2 $", "$Name: $", __FILE__, "$Author: agibert $")
void VER_Error_Print (void); void VER_Error_Print (void);
void * VER_Symbol_Next_Find (const char *, VERT_Object *, VERT_Index *); void * VER_Symbol_Next_Find (const char *, VERT_Object *, VERT_Index *);
extern char * strdup (const char *); extern char * strdup (const char *);
#ifdef LINUX #ifdef __linux
extern struct r_scope_elem *_dl_global_scope [2]; extern struct r_scope_elem *_dl_global_scope [2];
#endif #endif
@ -344,13 +344,13 @@ VERT_Status VER_Object_Print (FILE * Stream, VERT_Print_Mode Mode)
Handle = dlopen (NULL, RTLD_LAZY); Handle = dlopen (NULL, RTLD_LAZY);
#ifdef LINUX #ifdef __linux
/* /*
Sous LINUX, le linker définit une variable globale bien pratique qui référence Sous LINUX, le linker définit une variable globale bien pratique qui référence
la liste des objets linkés dynamiquement. la liste des objets linkés dynamiquement.
*/ */
Object = ((struct r_scope_elem *)(_dl_global_scope [0]))->r_list [0]; Object = (VERT_Object *)((struct r_scope_elem *)(_dl_global_scope [0]))->r_list [0];
#else #else
/* /*
Sous SOLARIS, on doit faire appel à la fonction dlinfo() pour obtenir Sous SOLARIS, on doit faire appel à la fonction dlinfo() pour obtenir
@ -414,7 +414,7 @@ VERT_Status VER_Object_Print (FILE * Stream, VERT_Print_Mode Mode)
{ {
/* Recherche dans l'objet suivant */ /* Recherche dans l'objet suivant */
Object = Object->l_next; Object = (VERT_Object *)(Object->l_next);
Index = 0; Index = 0;
} }
} }
@ -466,7 +466,7 @@ void * VER_Symbol_Next_Find (const char * Symbol_Name, VERT_Object * Object, VER
/* Recherche des sections relatives aux symboles */ /* Recherche des sections relatives aux symboles */
#ifdef LINUX #ifdef __linux
/* Sous LINUX, les sections sont directement accessibles par le champs <l_info> de l'entête de l'objet */ /* Sous LINUX, les sections sont directement accessibles par le champs <l_info> de l'entête de l'objet */
Symbol_Table = (Elf32_Sym *)(Object->l_info [DT_SYMTAB]->d_un.d_ptr); Symbol_Table = (Elf32_Sym *)(Object->l_info [DT_SYMTAB]->d_un.d_ptr);

188
lib/ver.h
View File

@ -5,8 +5,192 @@
extern "C" { extern "C" {
#endif #endif
#ifdef LINUX #ifdef __linux
# define DT_THISPROCNUM 0
# include <link.h> # include <link.h>
typedef __u_quad_t ino64_t;
/* Some internal data structures of the dynamic linker used in the
linker map. We only provide forward declarations. */
struct libname_list;
struct r_found_version;
struct r_search_path_elem;
/* Forward declaration. */
struct link_map;
/* Structure to describe a single list of scope elements. The lookup
functions get passed an array of pointers to such structures. */
struct r_scope_elem
{
/* Array of maps for the scope. */
struct link_map **r_list;
/* Number of entries in the scope. */
unsigned int r_nlist;
};
/* Structure to record search path and allocation mechanism. */
struct r_search_path_struct
{
struct r_search_path_elem **dirs;
int malloced;
};
struct link_map_machine
{
/* empty by default */
};
/* Structure describing a loaded shared object. The `l_next' and `l_prev'
members form a chain of all the shared objects loaded at startup.
These data structures exist in space used by the run-time dynamic linker;
modifying them may have disastrous results.
This data structure might change in future, if necessary. User-level
programs must avoid defining objects of this type. */
struct _link_map
{
/* These first few members are part of the protocol with the debugger.
This is the same format used in SVR4. */
ElfW(Addr) l_addr; /* Base address shared object is loaded at. */
char *l_name; /* Absolute file name object was found in. */
ElfW(Dyn) *l_ld; /* Dynamic section of the shared object. */
struct link_map *l_next, *l_prev; /* Chain of loaded objects. */
/* All following members are internal to the dynamic linker.
They may change without notice. */
struct libname_list *l_libname;
/* Indexed pointers to dynamic section.
[0,DT_NUM) are indexed by the processor-independent tags.
[DT_NUM,DT_NUM+DT_THISPROCNUM) are indexed by the tag minus DT_LOPROC.
[DT_NUM+DT_THISPROCNUM,DT_NUM+DT_THISPROCNUM+DT_EXTRANUM) are indexed
by DT_EXTRATAGIDX(tagvalue) and
[DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM,
DT_NUM+DT_THISPROCNUM+DT_VERSIONTAGNUM+DT_EXTRANUM)
are indexed by DT_EXTRATAGIDX(tagvalue) (see <elf.h>). */
ElfW(Dyn) *l_info[DT_NUM + DT_THISPROCNUM + DT_VERSIONTAGNUM
+ DT_EXTRANUM];
const ElfW(Phdr) *l_phdr; /* Pointer to program header table in core. */
ElfW(Addr) l_entry; /* Entry point location. */
ElfW(Half) l_phnum; /* Number of program header entries. */
ElfW(Half) l_ldnum; /* Number of dynamic segment entries. */
/* Array of DT_NEEDED dependencies and their dependencies, in
dependency order for symbol lookup (with and without
duplicates). There is no entry before the dependencies have
been loaded. */
struct r_scope_elem l_searchlist;
/* We need a special searchlist to process objects marked with
DT_SYMBOLIC. */
struct r_scope_elem l_symbolic_searchlist;
/* Dependent object that first caused this object to be loaded. */
struct link_map *l_loader;
/* Symbol hash table. */
Elf_Symndx l_nbuckets;
const Elf_Symndx *l_buckets, *l_chain;
unsigned int l_opencount; /* Reference count for dlopen/dlclose. */
enum /* Where this object came from. */
{
lt_executable, /* The main executable program. */
lt_library, /* Library needed by main executable. */
lt_loaded /* Extra run-time loaded shared object. */
} l_type:2;
unsigned int l_relocated:1; /* Nonzero if object's relocations done. */
unsigned int l_init_called:1; /* Nonzero if DT_INIT function called. */
unsigned int l_global:1; /* Nonzero if object in _dl_global_scope. */
unsigned int l_reserved:2; /* Reserved for internal use. */
unsigned int l_phdr_allocated:1; /* Nonzero if the data structure pointed
to by `l_phdr' is allocated. */
unsigned int l_soname_added:1; /* Nonzero if the SONAME is for sure in
the l_libname list. */
unsigned int l_faked:1; /* Nonzero if this is a faked descriptor
without associated file. */
/* Array with version names. */
unsigned int l_nversions;
struct r_found_version *l_versions;
/* Collected information about own RPATH directories. */
struct r_search_path_struct l_rpath_dirs;
/* Collected results of relocation while profiling. */
ElfW(Addr) *l_reloc_result;
/* Pointer to the version information if available. */
ElfW(Versym) *l_versyms;
/* String specifying the path where this object was found. */
const char *l_origin;
/* Start and finish of memory map for this object. l_map_start
need not be the same as l_addr. */
ElfW(Addr) l_map_start, l_map_end;
/* Default array for 'l_scope'. */
struct r_scope_elem *l_scope_mem[4];
/* Size of array allocated for 'l_scope'. */
size_t l_scope_max;
/* This is an array defining the lookup scope for this link map.
There are at most three different scope lists. */
struct r_scope_elem **l_scope;
/* A similar array, this time only with the local scope. This is
used occasionally. */
struct r_scope_elem *l_local_scope[2];
/* This information is kept to check for sure whether a shared
object is the same as one already loaded. */
dev_t l_dev;
ino64_t l_ino;
/* Collected information about own RUNPATH directories. */
struct r_search_path_struct l_runpath_dirs;
/* List of object in order of the init and fini calls. */
struct link_map **l_initfini;
/* List of the dependencies introduced through symbol binding. */
unsigned int l_reldepsmax;
unsigned int l_reldepsact;
struct link_map **l_reldeps;
/* Various flag words. */
ElfW(Word) l_feature_1;
ElfW(Word) l_flags_1;
/* Temporarily used in `dl_close'. */
unsigned int l_idx;
struct link_map_machine l_mach;
struct
{
const ElfW(Sym) *sym;
int type_class;
#ifdef DL_LOOKUP_RETURNS_MAP
struct link_map *value;
#else
ElfW(Addr) value;
#endif
const ElfW(Sym) *ret;
} l_lookup_cache;
};
#else #else
# include <sys/link.h> # include <sys/link.h>
#endif #endif
@ -42,7 +226,7 @@ typedef struct {
typedef VERT_Info_Container * VERT_Fcn (void); typedef VERT_Info_Container * VERT_Fcn (void);
typedef struct link_map VERT_Object; typedef struct _link_map VERT_Object;
typedef unsigned int VERT_Index; typedef unsigned int VERT_Index;