2011-06-25 09:45:10 +04:00
|
|
|
/* $NetBSD: rtld.h,v 1.106 2011/06/25 05:45:12 nonaka Exp $ */
|
1996-12-16 23:37:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 1996 John D. Polstra.
|
|
|
|
* Copyright 1996 Matt Thomas <matt@3am-software.com>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by John Polstra.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1999-03-01 19:40:07 +03:00
|
|
|
#ifndef RTLD_H
|
|
|
|
#define RTLD_H
|
1996-12-16 23:37:55 +03:00
|
|
|
|
1999-11-07 03:21:12 +03:00
|
|
|
#include <dlfcn.h>
|
2011-03-30 00:56:35 +04:00
|
|
|
#include <signal.h>
|
2007-09-02 13:57:16 +04:00
|
|
|
#include <stdbool.h>
|
1996-12-16 23:37:55 +03:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
1999-11-07 03:21:12 +03:00
|
|
|
#include <sys/queue.h>
|
1996-12-16 23:37:55 +03:00
|
|
|
#include <sys/exec_elf.h>
|
2011-03-10 02:10:05 +03:00
|
|
|
#include <sys/tls.h>
|
1996-12-16 23:37:55 +03:00
|
|
|
#include "rtldenv.h"
|
|
|
|
#include "link.h"
|
|
|
|
|
1999-07-05 21:55:34 +04:00
|
|
|
#if defined(_RTLD_SOURCE)
|
|
|
|
|
2001-12-28 08:44:22 +03:00
|
|
|
#ifndef RTLD_DEFAULT_LIBRARY_PATH
|
1999-03-19 21:25:57 +03:00
|
|
|
#define RTLD_DEFAULT_LIBRARY_PATH "/usr/lib"
|
2001-12-28 08:44:22 +03:00
|
|
|
#endif
|
1999-08-20 03:42:15 +04:00
|
|
|
#define _PATH_LD_HINTS "/etc/ld.so.conf"
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2009-11-17 21:44:33 +03:00
|
|
|
extern size_t _rtld_pagesz;
|
1999-03-01 19:40:07 +03:00
|
|
|
|
2002-09-24 13:45:59 +04:00
|
|
|
#define round_down(x) ((x) & ~(_rtld_pagesz - 1))
|
|
|
|
#define round_up(x) round_down((x) + _rtld_pagesz - 1)
|
1996-12-16 23:37:55 +03:00
|
|
|
|
|
|
|
#define NEW(type) ((type *) xmalloc(sizeof(type)))
|
|
|
|
#define CNEW(type) ((type *) xcalloc(sizeof(type)))
|
|
|
|
|
2010-02-27 14:16:38 +03:00
|
|
|
/*
|
|
|
|
* Fill in a DoneList with an allocation large enough to hold all of
|
2010-03-19 01:17:55 +03:00
|
|
|
* the currently-loaded objects. Keep this in a macro since it calls
|
|
|
|
* alloca and we want that to occur within the scope of the caller.
|
2010-02-27 14:16:38 +03:00
|
|
|
*/
|
2010-03-19 01:17:55 +03:00
|
|
|
#define _rtld_donelist_init(dlp) \
|
|
|
|
((dlp)->num_alloc = _rtld_objcount, \
|
|
|
|
(dlp)->objs = alloca((dlp)->num_alloc * sizeof((dlp)->objs[0])), \
|
|
|
|
assert((dlp)->objs != NULL), \
|
2010-02-27 14:16:38 +03:00
|
|
|
(dlp)->num_used = 0)
|
|
|
|
|
1999-07-05 21:55:34 +04:00
|
|
|
#endif /* _RTLD_SOURCE */
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
/*
|
|
|
|
* C++ has mandated the use of the following keywords for its new boolean
|
|
|
|
* type. We might as well follow their lead.
|
|
|
|
*/
|
|
|
|
struct Struct_Obj_Entry;
|
|
|
|
|
1999-11-07 03:21:12 +03:00
|
|
|
typedef struct Struct_Objlist_Entry {
|
|
|
|
SIMPLEQ_ENTRY(Struct_Objlist_Entry) link;
|
|
|
|
struct Struct_Obj_Entry *obj;
|
|
|
|
} Objlist_Entry;
|
|
|
|
|
|
|
|
typedef SIMPLEQ_HEAD(Struct_Objlist, Struct_Objlist_Entry) Objlist;
|
|
|
|
|
2010-10-16 14:27:06 +04:00
|
|
|
typedef struct Struct_Name_Entry {
|
|
|
|
STAILQ_ENTRY(Struct_Name_Entry) link;
|
|
|
|
char name[1];
|
|
|
|
} Name_Entry;
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
typedef struct Struct_Needed_Entry {
|
1999-03-01 19:40:07 +03:00
|
|
|
struct Struct_Needed_Entry *next;
|
|
|
|
struct Struct_Obj_Entry *obj;
|
|
|
|
unsigned long name; /* Offset of name in string table */
|
2002-09-19 18:05:37 +04:00
|
|
|
} Needed_Entry;
|
1996-12-16 23:37:55 +03:00
|
|
|
|
|
|
|
typedef struct _rtld_search_path_t {
|
1999-03-01 19:40:07 +03:00
|
|
|
struct _rtld_search_path_t *sp_next;
|
|
|
|
const char *sp_path;
|
|
|
|
size_t sp_pathlen;
|
2002-09-19 18:05:37 +04:00
|
|
|
} Search_Path;
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2011-06-25 09:45:10 +04:00
|
|
|
typedef struct Struct_Ver_Entry {
|
|
|
|
Elf_Word hash;
|
|
|
|
u_int flags;
|
|
|
|
const char *name;
|
|
|
|
const char *file;
|
|
|
|
} Ver_Entry;
|
|
|
|
|
|
|
|
/* Ver_Entry.flags */
|
|
|
|
#define VER_INFO_HIDDEN 0x01
|
|
|
|
|
1999-12-13 12:09:34 +03:00
|
|
|
|
|
|
|
#define RTLD_MAX_ENTRY 10
|
|
|
|
#define RTLD_MAX_LIBRARY 4
|
1999-12-15 08:22:37 +03:00
|
|
|
#define RTLD_MAX_CTL 2
|
1999-12-13 12:09:34 +03:00
|
|
|
typedef struct _rtld_library_xform_t {
|
|
|
|
struct _rtld_library_xform_t *next;
|
|
|
|
char *name;
|
2004-07-05 15:50:07 +04:00
|
|
|
const char *ctlname;
|
1999-12-13 12:09:34 +03:00
|
|
|
struct {
|
|
|
|
char *value;
|
|
|
|
char *library[RTLD_MAX_LIBRARY];
|
|
|
|
} entry[RTLD_MAX_ENTRY];
|
|
|
|
} Library_Xform;
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
/*
|
|
|
|
* Shared object descriptor.
|
|
|
|
*
|
|
|
|
* Items marked with "(%)" are dynamically allocated, and must be freed
|
|
|
|
* when the structure is destroyed.
|
2010-10-11 01:27:16 +04:00
|
|
|
*
|
|
|
|
* The layout of this structure needs to be preserved because pre-2.0 binaries
|
|
|
|
* hard-coded the location of dlopen() and friends.
|
1996-12-16 23:37:55 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define RTLD_MAGIC 0xd550b87a
|
|
|
|
#define RTLD_VERSION 1
|
|
|
|
|
|
|
|
typedef struct Struct_Obj_Entry {
|
1999-03-01 19:40:07 +03:00
|
|
|
Elf32_Word magic; /* Magic number (sanity check) */
|
|
|
|
Elf32_Word version; /* Version number of struct format */
|
|
|
|
|
|
|
|
struct Struct_Obj_Entry *next;
|
|
|
|
char *path; /* Pathname of underlying file (%) */
|
|
|
|
int refcount;
|
|
|
|
int dl_refcount; /* Number of times loaded by dlopen */
|
|
|
|
|
|
|
|
/* These items are computed by map_object() or by digest_phdr(). */
|
|
|
|
caddr_t mapbase; /* Base address of mapped region */
|
|
|
|
size_t mapsize; /* Size of mapped region in bytes */
|
|
|
|
size_t textsize; /* Size of text segment in bytes */
|
|
|
|
Elf_Addr vaddrbase; /* Base address in shared object file */
|
|
|
|
caddr_t relocbase; /* Reloc const = mapbase - *vaddrbase */
|
|
|
|
Elf_Dyn *dynamic; /* Dynamic section */
|
|
|
|
caddr_t entry; /* Entry point */
|
2010-10-16 14:27:06 +04:00
|
|
|
const Elf_Phdr *phdr; /* Program header (may be xmalloc'ed) */
|
|
|
|
size_t phsize; /* Size of program header in bytes */
|
1999-03-01 19:40:07 +03:00
|
|
|
|
|
|
|
/* Items from the dynamic section. */
|
|
|
|
Elf_Addr *pltgot; /* PLTGOT table */
|
|
|
|
const Elf_Rel *rel; /* Relocation entries */
|
|
|
|
const Elf_Rel *rellim; /* Limit of Relocation entries */
|
2001-04-25 16:24:50 +04:00
|
|
|
const Elf_Rela *rela; /* Relocation entries */
|
|
|
|
const Elf_Rela *relalim; /* Limit of Relocation entries */
|
1999-03-01 19:40:07 +03:00
|
|
|
const Elf_Rel *pltrel; /* PLT relocation entries */
|
|
|
|
const Elf_Rel *pltrellim; /* Limit of PLT relocation entries */
|
2001-04-25 16:24:50 +04:00
|
|
|
const Elf_Rela *pltrela; /* PLT relocation entries */
|
|
|
|
const Elf_Rela *pltrelalim; /* Limit of PLT relocation entries */
|
1999-03-01 19:40:07 +03:00
|
|
|
const Elf_Sym *symtab; /* Symbol table */
|
|
|
|
const char *strtab; /* String table */
|
|
|
|
unsigned long strsize; /* Size in bytes of string table */
|
2002-09-25 10:43:46 +04:00
|
|
|
#ifdef __mips__
|
1999-03-01 19:40:07 +03:00
|
|
|
Elf_Word local_gotno; /* Number of local GOT entries */
|
|
|
|
Elf_Word symtabno; /* Number of dynamic symbols */
|
|
|
|
Elf_Word gotsym; /* First dynamic symbol in GOT */
|
1998-03-25 07:12:32 +03:00
|
|
|
#endif
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2010-09-30 13:11:18 +04:00
|
|
|
const Elf_Symindx *buckets; /* Hash table buckets array */
|
2010-10-11 01:27:16 +04:00
|
|
|
unsigned long unused1; /* Used to be nbuckets */
|
2010-09-30 13:11:18 +04:00
|
|
|
const Elf_Symindx *chains; /* Hash table chain array */
|
1999-03-01 19:40:07 +03:00
|
|
|
unsigned long nchains; /* Number of chains */
|
|
|
|
|
|
|
|
Search_Path *rpaths; /* Search path specified in object */
|
|
|
|
Needed_Entry *needed; /* Shared objects needed by this (%) */
|
|
|
|
|
2003-07-24 14:12:25 +04:00
|
|
|
void (*init)(void); /* Initialization function to call */
|
|
|
|
void (*fini)(void); /* Termination function to call */
|
1999-03-01 19:40:07 +03:00
|
|
|
|
2010-01-15 10:07:11 +03:00
|
|
|
/* Entry points for dlopen() and friends. */
|
|
|
|
void *(*dlopen)(const char *, int);
|
|
|
|
void *(*dlsym)(void *, const char *);
|
2011-06-25 09:45:10 +04:00
|
|
|
void *(*dlvsym)(void *, const char *, const char *);
|
2010-01-15 10:07:11 +03:00
|
|
|
char *(*dlerror)(void);
|
|
|
|
int (*dlclose)(void *);
|
|
|
|
int (*dladdr)(const void *, Dl_info *);
|
|
|
|
|
2003-04-24 20:55:29 +04:00
|
|
|
u_int32_t mainprog:1, /* True if this is the main program */
|
|
|
|
rtld:1, /* True if this is the dynamic linker */
|
2000-07-06 07:16:51 +04:00
|
|
|
textrel:1, /* True if there are relocations to
|
1999-03-01 19:40:07 +03:00
|
|
|
* text seg */
|
2000-07-06 07:16:51 +04:00
|
|
|
symbolic:1, /* True if generated with
|
1999-03-01 19:40:07 +03:00
|
|
|
* "-Bsymbolic" */
|
2002-09-06 17:20:29 +04:00
|
|
|
printed:1, /* True if ldd has printed it */
|
2002-10-03 05:09:21 +04:00
|
|
|
isdynamic:1, /* True if this is a pure PIC object */
|
2002-10-04 00:35:19 +04:00
|
|
|
mainref:1, /* True if on _rtld_list_main */
|
2007-12-07 23:34:04 +03:00
|
|
|
globalref:1, /* True if on _rtld_list_global */
|
|
|
|
init_done:1, /* True if .init has been added */
|
|
|
|
init_called:1, /* True if .init function has been
|
|
|
|
* called */
|
|
|
|
fini_called:1, /* True if .fini function has been
|
|
|
|
* called */
|
2010-12-24 15:41:42 +03:00
|
|
|
z_now:1, /* True if object's symbols should be
|
|
|
|
bound immediately */
|
|
|
|
z_nodelete:1, /* True if object should never be
|
|
|
|
unloaded */
|
|
|
|
z_initfirst:1, /* True if object's .init/.fini take
|
2010-10-16 14:27:06 +04:00
|
|
|
* priority over others */
|
2010-12-24 15:41:42 +03:00
|
|
|
z_noopen:1, /* True if object should never be
|
|
|
|
dlopen'ed */
|
|
|
|
phdr_loaded:1, /* Phdr is loaded and doesn't need to
|
2010-10-16 14:27:06 +04:00
|
|
|
* be freed. */
|
2011-03-10 02:10:05 +03:00
|
|
|
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
|
|
|
|
tls_done:1, /* True if static TLS offset
|
|
|
|
* has been allocated */
|
|
|
|
#endif
|
2010-12-24 15:41:42 +03:00
|
|
|
ref_nodel:1; /* Refcount increased to prevent dlclose */
|
1999-03-01 19:40:07 +03:00
|
|
|
|
|
|
|
struct link_map linkmap; /* for GDB */
|
1999-11-07 03:21:12 +03:00
|
|
|
|
|
|
|
/* These items are computed by map_object() or by digest_phdr(). */
|
|
|
|
const char *interp; /* Pathname of the interpreter, if any */
|
|
|
|
Objlist dldags; /* Object belongs to these dlopened DAGs (%) */
|
|
|
|
Objlist dagmembers; /* DAG has these members (%) */
|
|
|
|
dev_t dev; /* Object's filesystem's device */
|
|
|
|
ino_t ino; /* Object's inode number */
|
2010-01-17 11:04:20 +03:00
|
|
|
|
|
|
|
void *ehdr;
|
2010-10-11 01:27:16 +04:00
|
|
|
|
|
|
|
uint32_t nbuckets; /* Number of buckets */
|
|
|
|
uint32_t nbuckets_m; /* Precomputed for fast remainder */
|
|
|
|
uint8_t nbuckets_s1;
|
|
|
|
uint8_t nbuckets_s2;
|
2010-10-16 14:27:06 +04:00
|
|
|
size_t pathlen; /* Pathname length */
|
|
|
|
STAILQ_HEAD(, Struct_Name_Entry) names; /* List of names for this object we
|
|
|
|
know about. */
|
2011-03-10 02:10:05 +03:00
|
|
|
|
2011-01-16 18:56:37 +03:00
|
|
|
#ifdef __powerpc__
|
|
|
|
Elf_Addr *gotptr; /* GOT table (secure-plt only) */
|
|
|
|
#endif
|
2011-03-10 02:10:05 +03:00
|
|
|
|
|
|
|
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
|
|
|
|
/* Thread Local Storage support for this module */
|
|
|
|
size_t tlsindex; /* Index in DTV */
|
|
|
|
void *tlsinit; /* Base address of TLS init block */
|
|
|
|
size_t tlsinitsize; /* Size of TLS init block */
|
|
|
|
size_t tlssize; /* Size of TLS block */
|
|
|
|
size_t tlsoffset; /* Offset in the static TLS block */
|
|
|
|
size_t tlsalign; /* Needed alignment for static TLS */
|
|
|
|
#endif
|
2011-06-25 09:45:10 +04:00
|
|
|
|
|
|
|
/* symbol versioning */
|
|
|
|
const Elf_Verneed *verneed; /* Required versions. */
|
|
|
|
Elf_Word verneednum; /* Number of entries in verneed table */
|
|
|
|
const Elf_Verdef *verdef; /* Provided versions. */
|
|
|
|
Elf_Word verdefnum; /* Number of entries in verdef table */
|
|
|
|
const Elf_Versym *versyms; /* Symbol versions table */
|
|
|
|
|
|
|
|
Ver_Entry *vertab; /* Versions required/defined by this
|
|
|
|
* object */
|
|
|
|
int vertabnum; /* Number of entries in vertab */
|
1996-12-16 23:37:55 +03:00
|
|
|
} Obj_Entry;
|
|
|
|
|
2010-02-27 14:16:38 +03:00
|
|
|
typedef struct Struct_DoneList {
|
|
|
|
const Obj_Entry **objs; /* Array of object pointers */
|
|
|
|
unsigned int num_alloc; /* Allocated size of the array */
|
|
|
|
unsigned int num_used; /* Number of array slots used */
|
|
|
|
} DoneList;
|
|
|
|
|
|
|
|
|
1999-07-05 21:55:34 +04:00
|
|
|
#if defined(_RTLD_SOURCE)
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
extern struct r_debug _rtld_debug;
|
1999-08-01 23:47:07 +04:00
|
|
|
extern Search_Path *_rtld_default_paths;
|
1996-12-16 23:37:55 +03:00
|
|
|
extern Obj_Entry *_rtld_objlist;
|
|
|
|
extern Obj_Entry **_rtld_objtail;
|
2010-10-16 14:27:06 +04:00
|
|
|
extern u_int _rtld_objcount;
|
|
|
|
extern u_int _rtld_objloads;
|
1999-11-07 03:21:12 +03:00
|
|
|
extern Obj_Entry *_rtld_objmain;
|
1996-12-16 23:37:55 +03:00
|
|
|
extern Obj_Entry _rtld_objself;
|
|
|
|
extern Search_Path *_rtld_paths;
|
1999-12-13 12:09:34 +03:00
|
|
|
extern Library_Xform *_rtld_xforms;
|
1996-12-16 23:37:55 +03:00
|
|
|
extern bool _rtld_trust;
|
1999-11-07 03:21:12 +03:00
|
|
|
extern Objlist _rtld_list_global;
|
|
|
|
extern Objlist _rtld_list_main;
|
|
|
|
extern Elf_Sym _rtld_sym_zero;
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2010-12-24 15:41:42 +03:00
|
|
|
#define RTLD_MODEMASK 0x3
|
|
|
|
|
2011-06-25 09:45:10 +04:00
|
|
|
/* Flags to be passed into _rtld_symlook_ family of functions. */
|
|
|
|
#define SYMLOOK_IN_PLT 0x01 /* Lookup for PLT symbol */
|
|
|
|
#define SYMLOOK_DLSYM 0x02 /* Return newes versioned symbol.
|
|
|
|
Used by dlsym. */
|
|
|
|
|
2010-12-24 15:41:42 +03:00
|
|
|
/* Flags for _rtld_load_object() and friends. */
|
|
|
|
#define _RTLD_GLOBAL 0x01 /* Add object to global DAG. */
|
|
|
|
#define _RTLD_MAIN 0x02
|
|
|
|
#define _RTLD_NOLOAD 0x04 /* dlopen() specified RTLD_NOLOAD. */
|
|
|
|
#define _RTLD_DLOPEN 0x08 /* Load_object() called from dlopen(). */
|
|
|
|
|
2011-03-10 02:10:05 +03:00
|
|
|
/* Preallocation for static TLS model */
|
|
|
|
#define RTLD_STATIC_TLS_RESERVATION 64
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
/* rtld.c */
|
2003-08-12 13:18:38 +04:00
|
|
|
|
2010-10-16 14:27:06 +04:00
|
|
|
/* We export these symbols using _rtld_symbol_lookup and is_exported. */
|
2010-12-05 03:56:06 +03:00
|
|
|
__dso_public char *dlerror(void);
|
|
|
|
__dso_public void *dlopen(const char *, int);
|
|
|
|
__dso_public void *dlsym(void *, const char *);
|
|
|
|
__dso_public int dlclose(void *);
|
|
|
|
__dso_public int dladdr(const void *, Dl_info *);
|
|
|
|
__dso_public int dlinfo(void *, int, void *);
|
|
|
|
__dso_public int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
|
2010-10-16 14:27:06 +04:00
|
|
|
void *);
|
2003-08-12 13:18:38 +04:00
|
|
|
|
2010-10-16 14:27:06 +04:00
|
|
|
/* These aren't exported */
|
2003-07-24 14:12:25 +04:00
|
|
|
void _rtld_error(const char *, ...)
|
2000-10-10 23:54:37 +04:00
|
|
|
__attribute__((__format__(__printf__,1,2)));
|
2006-05-22 23:49:09 +04:00
|
|
|
void _rtld_die(void) __attribute__((__noreturn__));
|
2003-07-24 14:12:25 +04:00
|
|
|
void *_rtld_objmain_sym(const char *);
|
2011-01-25 15:25:43 +03:00
|
|
|
__dso_public void _rtld_debug_state(void);
|
2003-07-24 14:12:25 +04:00
|
|
|
void _rtld_linkmap_add(Obj_Entry *);
|
|
|
|
void _rtld_linkmap_delete(Obj_Entry *);
|
2007-12-07 23:34:04 +03:00
|
|
|
void _rtld_objlist_push_head(Objlist *, Obj_Entry *);
|
|
|
|
void _rtld_objlist_push_tail(Objlist *, Obj_Entry *);
|
2003-07-24 14:12:25 +04:00
|
|
|
Objlist_Entry *_rtld_objlist_find(Objlist *, const Obj_Entry *);
|
2010-12-24 15:41:42 +03:00
|
|
|
void _rtld_ref_dag(Obj_Entry *);
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2011-03-25 21:07:04 +03:00
|
|
|
void _rtld_shared_enter(void);
|
|
|
|
void _rtld_shared_exit(void);
|
2011-03-30 00:56:35 +04:00
|
|
|
void _rtld_exclusive_enter(sigset_t *);
|
|
|
|
void _rtld_exclusive_exit(sigset_t *);
|
2011-03-25 21:07:04 +03:00
|
|
|
|
2007-05-19 01:44:08 +04:00
|
|
|
/* expand.c */
|
|
|
|
size_t _rtld_expand_path(char *, size_t, const char *, const char *,\
|
|
|
|
const char *);
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
/* headers.c */
|
2007-05-19 01:44:08 +04:00
|
|
|
void _rtld_digest_dynamic(const char *, Obj_Entry *);
|
2003-07-24 14:12:25 +04:00
|
|
|
Obj_Entry *_rtld_digest_phdr(const Elf_Phdr *, int, caddr_t);
|
1996-12-16 23:37:55 +03:00
|
|
|
|
|
|
|
/* load.c */
|
2006-03-21 20:48:10 +03:00
|
|
|
Obj_Entry *_rtld_load_object(const char *, int);
|
2003-07-24 14:12:25 +04:00
|
|
|
int _rtld_load_needed_objects(Obj_Entry *, int);
|
|
|
|
int _rtld_preload(const char *);
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2010-12-24 15:41:42 +03:00
|
|
|
#define OBJ_ERR (Obj_Entry *)(-1)
|
1996-12-16 23:37:55 +03:00
|
|
|
/* path.c */
|
2007-05-19 01:44:08 +04:00
|
|
|
void _rtld_add_paths(const char *, Search_Path **, const char *);
|
|
|
|
void _rtld_process_hints(const char *, Search_Path **, Library_Xform **,
|
|
|
|
const char *);
|
2004-07-05 15:50:07 +04:00
|
|
|
int _rtld_sysctl(const char *, void *, size_t *);
|
1996-12-16 23:37:55 +03:00
|
|
|
|
|
|
|
/* reloc.c */
|
2003-07-24 14:12:25 +04:00
|
|
|
int _rtld_do_copy_relocations(const Obj_Entry *);
|
|
|
|
int _rtld_relocate_objects(Obj_Entry *, bool);
|
2010-08-06 20:33:17 +04:00
|
|
|
int _rtld_relocate_nonplt_objects(Obj_Entry *);
|
2003-07-24 14:12:25 +04:00
|
|
|
int _rtld_relocate_plt_lazy(const Obj_Entry *);
|
|
|
|
int _rtld_relocate_plt_objects(const Obj_Entry *);
|
|
|
|
void _rtld_setup_pltgot(const Obj_Entry *);
|
1996-12-16 23:37:55 +03:00
|
|
|
|
|
|
|
/* search.c */
|
2003-07-24 14:12:25 +04:00
|
|
|
Obj_Entry *_rtld_load_library(const char *, const Obj_Entry *, int);
|
1996-12-16 23:37:55 +03:00
|
|
|
|
|
|
|
/* symbol.c */
|
2003-07-24 14:12:25 +04:00
|
|
|
unsigned long _rtld_elf_hash(const char *);
|
|
|
|
const Elf_Sym *_rtld_symlook_obj(const char *, unsigned long,
|
2011-06-25 09:45:10 +04:00
|
|
|
const Obj_Entry *, u_int, const Ver_Entry *);
|
2003-07-24 14:12:25 +04:00
|
|
|
const Elf_Sym *_rtld_find_symdef(unsigned long, const Obj_Entry *,
|
2011-06-25 09:45:10 +04:00
|
|
|
const Obj_Entry **, u_int);
|
2010-01-13 23:17:21 +03:00
|
|
|
const Elf_Sym *_rtld_find_plt_symdef(unsigned long, const Obj_Entry *,
|
|
|
|
const Obj_Entry **, bool);
|
|
|
|
|
1999-11-07 03:21:12 +03:00
|
|
|
const Elf_Sym *_rtld_symlook_list(const char *, unsigned long,
|
2011-06-25 09:45:10 +04:00
|
|
|
const Objlist *, const Obj_Entry **, u_int, const Ver_Entry *, DoneList *);
|
2003-05-30 19:43:33 +04:00
|
|
|
const Elf_Sym *_rtld_symlook_default(const char *, unsigned long,
|
2011-06-25 09:45:10 +04:00
|
|
|
const Obj_Entry *, const Obj_Entry **, u_int, const Ver_Entry *);
|
2008-10-04 13:37:12 +04:00
|
|
|
const Elf_Sym *_rtld_symlook_needed(const char *, unsigned long,
|
2011-06-25 09:45:10 +04:00
|
|
|
const Needed_Entry *, const Obj_Entry **, u_int, const Ver_Entry *,
|
2010-02-27 14:16:38 +03:00
|
|
|
DoneList *, DoneList *);
|
2010-01-10 10:29:47 +03:00
|
|
|
#ifdef COMBRELOC
|
|
|
|
void _rtld_combreloc_reset(const Obj_Entry *);
|
|
|
|
#endif
|
2011-06-25 09:45:10 +04:00
|
|
|
|
|
|
|
/* symver.c */
|
|
|
|
int _rtld_object_match_name(const Obj_Entry *, const char *);
|
|
|
|
int _rtld_verify_object_versions(Obj_Entry *);
|
|
|
|
|
|
|
|
static __inline const Ver_Entry *
|
|
|
|
_rtld_fetch_ventry(const Obj_Entry *obj, unsigned long symnum)
|
|
|
|
{
|
|
|
|
Elf_Half vernum;
|
|
|
|
|
|
|
|
if (obj->vertab) {
|
|
|
|
vernum = VER_NDX(obj->versyms[symnum].vs_vers);
|
|
|
|
if (vernum >= obj->vertabnum) {
|
|
|
|
_rtld_error("%s: symbol %s has wrong verneed value %d",
|
|
|
|
obj->path, &obj->strtab[symnum], vernum);
|
|
|
|
} else if (obj->vertab[vernum].hash) {
|
|
|
|
return &obj->vertab[vernum];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2011-03-10 02:10:05 +03:00
|
|
|
#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
|
|
|
|
/* tls.c */
|
|
|
|
void *_rtld_tls_get_addr(void *, size_t, size_t);
|
|
|
|
void _rtld_tls_initial_allocation(void);
|
|
|
|
void *_rtld_tls_module_allocate(size_t index);
|
|
|
|
int _rtld_tls_offset_allocate(Obj_Entry *);
|
|
|
|
void _rtld_tls_offset_free(Obj_Entry *);
|
|
|
|
|
|
|
|
extern size_t _rtld_tls_dtv_generation;
|
|
|
|
extern size_t _rtld_tls_max_index;
|
|
|
|
|
2011-03-10 17:27:31 +03:00
|
|
|
__dso_public extern void *__tls_get_addr(void *);
|
2011-03-13 01:54:36 +03:00
|
|
|
#ifdef __i386__
|
|
|
|
__dso_public extern void *___tls_get_addr(void *)
|
|
|
|
__attribute__((__regparm__(1)));
|
|
|
|
#endif
|
2011-03-10 02:10:05 +03:00
|
|
|
#endif
|
|
|
|
|
1996-12-16 23:37:55 +03:00
|
|
|
/* map_object.c */
|
2010-08-06 20:33:17 +04:00
|
|
|
struct stat;
|
2006-03-21 20:48:10 +03:00
|
|
|
Obj_Entry *_rtld_map_object(const char *, int, const struct stat *);
|
1999-11-07 03:21:12 +03:00
|
|
|
void _rtld_obj_free(Obj_Entry *);
|
|
|
|
Obj_Entry *_rtld_obj_new(void);
|
1996-12-16 23:37:55 +03:00
|
|
|
|
2002-07-10 19:12:33 +04:00
|
|
|
/* function descriptors */
|
|
|
|
#ifdef __HAVE_FUNCTION_DESCRIPTORS
|
2003-07-24 14:12:25 +04:00
|
|
|
Elf_Addr _rtld_function_descriptor_alloc(const Obj_Entry *,
|
|
|
|
const Elf_Sym *, Elf_Addr);
|
|
|
|
const void *_rtld_function_descriptor_function(const void *);
|
2002-07-10 19:12:33 +04:00
|
|
|
#endif /* __HAVE_FUNCTION_DESCRIPTORS */
|
|
|
|
|
1999-07-05 21:55:34 +04:00
|
|
|
#endif /* _RTLD_SOURCE */
|
|
|
|
|
|
|
|
#endif /* RTLD_H */
|