Home | History | Annotate | Line # | Download | only in ld.elf_so
rtld.h revision 1.148
      1 /*	$NetBSD: rtld.h,v 1.148 2025/04/18 17:56:49 riastradh Exp $	 */
      2 
      3 /*
      4  * Copyright 1996 John D. Polstra.
      5  * Copyright 1996 Matt Thomas <matt (at) 3am-software.com>
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. All advertising materials mentioning features or use of this software
     17  *    must display the following acknowledgement:
     18  *      This product includes software developed by John Polstra.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 #ifndef RTLD_H
     35 #define RTLD_H
     36 
     37 #include <dlfcn.h>
     38 #include <signal.h>
     39 #include <stdbool.h>
     40 #include <stddef.h>
     41 #include <sys/param.h>
     42 #include <sys/types.h>
     43 #include <sys/queue.h>
     44 #include <sys/exec_elf.h>
     45 #include <sys/tls.h>
     46 #include "rtldenv.h"
     47 #include "link.h"
     48 
     49 #if defined(_RTLD_SOURCE)
     50 
     51 #if defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
     52 #include "unwind.h"
     53 #endif
     54 
     55 #ifndef	RTLD_DEFAULT_LIBRARY_PATH
     56 #define	RTLD_DEFAULT_LIBRARY_PATH	"/usr/lib"
     57 #endif
     58 #define _PATH_LD_HINTS			"/etc/ld.so.conf"
     59 
     60 extern size_t _rtld_pagesz;
     61 
     62 #define round_down(x)	((x) & ~(_rtld_pagesz - 1))
     63 #define round_up(x)	round_down((x) + _rtld_pagesz - 1)
     64 
     65 #define NEW(type)	((type *) xmalloc(sizeof(type)))
     66 #define CNEW(type)	((type *) xcalloc(sizeof(type)))
     67 
     68 /*
     69  * Fill in a DoneList with an allocation large enough to hold all of
     70  * the currently-loaded objects. Keep this in a macro since it calls
     71  * alloca and we want that to occur within the scope of the caller.
     72  */
     73 #define _rtld_donelist_init(dlp)					\
     74     ((dlp)->num_alloc = _rtld_objcount,					\
     75     (dlp)->objs = alloca((dlp)->num_alloc * sizeof((dlp)->objs[0])),	\
     76     assert((dlp)->objs != NULL),					\
     77     (dlp)->num_used = 0)
     78 
     79 
     80 typedef struct Struct_Elf_Hash {
     81 	unsigned long sysv;
     82 	unsigned long gnu;
     83 } Elf_Hash;
     84 #endif /* _RTLD_SOURCE */
     85 
     86 /*
     87  * C++ has mandated the use of the following keywords for its new boolean
     88  * type.  We might as well follow their lead.
     89  */
     90 struct Struct_Obj_Entry;
     91 
     92 typedef struct Struct_Objlist_Entry {
     93 	SIMPLEQ_ENTRY(Struct_Objlist_Entry) link;
     94 	struct Struct_Obj_Entry *obj;
     95 } Objlist_Entry;
     96 
     97 typedef SIMPLEQ_HEAD(Struct_Objlist, Struct_Objlist_Entry) Objlist;
     98 
     99 typedef struct Struct_Name_Entry {
    100 	SIMPLEQ_ENTRY(Struct_Name_Entry) link;
    101 	char	name[1];
    102 } Name_Entry;
    103 
    104 typedef struct Struct_Needed_Entry {
    105 	struct Struct_Needed_Entry *next;
    106 	struct Struct_Obj_Entry *obj;
    107 	unsigned long   name;	/* Offset of name in string table */
    108 } Needed_Entry;
    109 
    110 typedef struct _rtld_search_path_t {
    111 	struct _rtld_search_path_t *sp_next;
    112 	const char     *sp_path;
    113 	size_t          sp_pathlen;
    114 } Search_Path;
    115 
    116 typedef struct Struct_Ver_Entry {
    117 	Elf_Word        hash;
    118 	u_int           flags;
    119 	const char     *name;
    120 	const char     *file;
    121 } Ver_Entry;
    122 
    123 /* Ver_Entry.flags */
    124 #define VER_INFO_HIDDEN	0x01
    125 
    126 #define RTLD_MAX_ENTRY 10
    127 #define RTLD_MAX_LIBRARY 4
    128 #define RTLD_MAX_CTL 2
    129 typedef struct _rtld_library_xform_t {
    130 	struct _rtld_library_xform_t *next;
    131 	char *name;
    132 	const char *ctlname;
    133 	struct {
    134 		char *value;
    135 		char *library[RTLD_MAX_LIBRARY];
    136 	} entry[RTLD_MAX_ENTRY];
    137 } Library_Xform;
    138 
    139 /*
    140  * Shared object descriptor.
    141  *
    142  * Items marked with "(%)" are dynamically allocated, and must be freed
    143  * when the structure is destroyed.
    144  */
    145 
    146 typedef void (*fptr_t)(void);
    147 
    148 typedef struct Struct_Obj_Entry {
    149 	struct Struct_Obj_Entry *next;
    150 	char           *path;		/* Pathname of underlying file (%) */
    151 	int             refcount;
    152 	int             dl_refcount;	/* Number of times loaded by dlopen */
    153 
    154 	/* These items are computed by map_object() or by digest_phdr(). */
    155 	caddr_t         mapbase;	/* Base address of mapped region */
    156 	size_t          mapsize;	/* Size of mapped region in bytes */
    157 	size_t          textsize;	/* Size of text segment in bytes */
    158 	Elf_Addr        vaddrbase;	/* Base address in shared object file */
    159 	caddr_t         relocbase;	/* Reloc const = mapbase - *vaddrbase */
    160 	Elf_Dyn        *dynamic;	/* Dynamic section */
    161 	caddr_t         entry;		/* Entry point */
    162 	const Elf_Phdr *phdr;		/* Program header (may be xmalloc'ed) */
    163 	size_t		phsize;		/* Size of program header in bytes */
    164 
    165 	/* Items from the dynamic section. */
    166 	Elf_Addr       *pltgot;		/* PLTGOT table */
    167 	const Elf_Rel  *rel;		/* Relocation entries */
    168 	const Elf_Rel  *rellim;		/* Limit of Relocation entries */
    169 	const Elf_Rela *rela;		/* Relocation entries */
    170 	const Elf_Rela *relalim;	/* Limit of Relocation entries */
    171 	const Elf_Rel  *pltrel;		/* PLT relocation entries */
    172 	const Elf_Rel  *pltrellim;	/* Limit of PLT relocation entries */
    173 	const Elf_Rela *pltrela;	/* PLT relocation entries */
    174 	const Elf_Rela *pltrelalim;	/* Limit of PLT relocation entries */
    175 	const Elf_Sym  *symtab;		/* Symbol table */
    176 	const char     *strtab;		/* String table */
    177 	unsigned long   strsize;	/* Size in bytes of string table */
    178 #if defined(__mips__) || defined(__riscv__)
    179 	Elf_Word        local_gotno;	/* Number of local GOT entries */
    180 	Elf_Word        symtabno;	/* Number of dynamic symbols */
    181 	Elf_Word        gotsym;		/* First dynamic symbol in GOT */
    182 #endif
    183 
    184 	/* SysV Hash fields */
    185 	const Elf_Symindx *buckets;	/* Hash table buckets array */
    186 	unsigned long	unused1;	/* Used to be nbuckets */
    187 	const Elf_Symindx *chains;	/* Hash table chain array */
    188 	unsigned long   nchains;	/* Number of chains */
    189 
    190 	Search_Path    *rpaths;		/* Search path specified in object */
    191 	Needed_Entry   *needed;		/* Shared objects needed by this (%) */
    192 
    193 	fptr_t		init;		/* Initialization function to call */
    194 	fptr_t		fini;		/* Termination function to call */
    195 
    196 	u_int32_t	mainprog:1,	/* True if this is the main program */
    197 	        	rtld:1,		/* True if this is the dynamic linker */
    198 			textrel:1,	/* True if there are relocations to
    199 					 * text seg */
    200 			symbolic:1,	/* True if generated with
    201 					 * "-Bsymbolic" */
    202 			printed:1,	/* True if ldd has printed it */
    203 			isdynamic:1,	/* True if this is a pure PIC object */
    204 			mainref:1,	/* True if on _rtld_list_main */
    205 			globalref:1,	/* True if on _rtld_list_global */
    206 			init_done:1,	/* True if .init has been added */
    207 			init_called:1,	/* True if .init function has been
    208 					 * called */
    209 			fini_called:1,	/* True if .fini function has been
    210 					 * called */
    211 			z_now:1,	/* True if object's symbols should be
    212 					   bound immediately */
    213 			z_nodelete:1,	/* True if object should never be
    214 					   unloaded */
    215 			z_initfirst:1,	/* True if object's .init/.fini take
    216 					 * priority over others */
    217 			z_noopen:1,	/* True if object should never be
    218 					   dlopen'ed */
    219 			phdr_loaded:1,	/* Phdr is loaded and doesn't need to
    220 					 * be freed. */
    221 #ifdef __alpha__
    222 			secureplt:1,	/* True if PLT is read-only format */
    223 #endif
    224 #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
    225 			tls_static:1,	/* True if static TLS offset
    226 					 * has been allocated */
    227 			tls_dynamic:1,	/* True if any non-static DTV entry
    228 					 * has been allocated */
    229 #endif
    230 			ref_nodel:1,	/* Refcount increased to prevent dlclose */
    231 			sysv_hash:1,	/* SysV Hash available */
    232 			gnu_hash:1;	/* GNU Hash available */
    233 
    234 	struct link_map linkmap;	/* for the debugger */
    235 
    236 	/* These items are computed by map_object() or by digest_phdr(). */
    237 	const char     *interp;	/* Pathname of the interpreter, if any */
    238 	Objlist         dldags;	/* Object belongs to these dlopened DAGs (%) */
    239 	Objlist         dagmembers;	/* DAG has these members (%) */
    240 	dev_t           dev;		/* Object's filesystem's device */
    241 	ino_t           ino;		/* Object's inode number */
    242 
    243 	void		*ehdr;
    244 
    245 	/* SysV Hash fields */
    246 	uint32_t        nbuckets;	/* Number of buckets */
    247 	uint32_t        nbuckets_m;	/* Precomputed for fast remainder */
    248 	uint8_t         nbuckets_s1;
    249 	uint8_t         nbuckets_s2;
    250 
    251 	/* GNU Hash fields */
    252 	const uint32_t *buckets_gnu;	/* Hash table buckets array */
    253 	uint32_t	nbuckets_gnu;	/* Number of GNU hash buckets */
    254 	uint32_t	nbuckets_m_gnu;	/* Precomputed for fast remainder */
    255 	uint8_t		nbuckets_s1_gnu;
    256 	uint8_t		nbuckets_s2_gnu;
    257 	const uint32_t *chains_gnu;	/* Hash table chain array */
    258 #define nchains_gnu	nchains		/* Number of symbols, shared with SysV Hash */
    259 	const Elf_Addr *bloom_gnu;
    260 	uint32_t	symndx_gnu;	/* First accessible symbol on dynsym table */
    261 	uint32_t	mask_bm_gnu;	/* Bloom filter words - 1 (bitmask) */
    262 	uint32_t	shift2_gnu;	/* Bloom filter shift count */
    263 
    264 	size_t		pathlen;	/* Pathname length */
    265 	SIMPLEQ_HEAD(, Struct_Name_Entry) names; /* List of names for this
    266 						  * object we know about. */
    267 
    268 #ifdef __powerpc__
    269 #ifdef _LP64
    270 	Elf_Addr	glink;		/* global linkage */
    271 #else
    272 	Elf_Addr       *gotptr;		/* GOT table (secure-plt only) */
    273 #endif
    274 #endif
    275 
    276 #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
    277 	/* Thread Local Storage support for this module */
    278 	size_t		tlsindex;	/* Index in DTV */
    279 	void		*tlsinit;	/* Base address of TLS init block */
    280 	size_t		tlsinitsize;	/* Size of TLS init block */
    281 	size_t		tlssize;	/* Size of TLS block */
    282 	size_t		tlsoffset;	/* Offset in the static TLS block */
    283 	size_t		tlsalign;	/* Needed alignment for static TLS */
    284 #endif
    285 
    286 #ifdef GNU_RELRO
    287 	/* relocation readonly */
    288 	void		*relro_page;
    289 	size_t		relro_size;
    290 #endif
    291 
    292 	/* symbol versioning */
    293 	const Elf_Verneed *verneed;	/* Required versions. */
    294 	Elf_Word	verneednum;	/* Number of entries in verneed table */
    295 	const Elf_Verdef  *verdef;	/* Provided versions. */
    296 	Elf_Word	verdefnum;	/* Number of entries in verdef table */
    297 	const Elf_Versym *versyms;	/* Symbol versions table */
    298 
    299 	Ver_Entry	*vertab;	/* Versions required/defined by this
    300 					 * object */
    301 	int		vertabnum;	/* Number of entries in vertab */
    302 
    303 	/* init_array/fini_array */
    304 	fptr_t		*init_array;	/* start of init array */
    305 	size_t		init_arraysz;	/* # of entries in it */
    306 	fptr_t		*fini_array;	/* start of fini array */
    307 	size_t		fini_arraysz;	/* # of entries in it */
    308 	/* IRELATIVE relocations */
    309 	size_t		ifunc_remaining;
    310 #if \
    311     defined(__aarch64__) || \
    312     defined(__arm__) || \
    313     defined(__i386__) || \
    314     defined(__powerpc__) || \
    315     defined(__sparc__) || \
    316     defined(__x86_64__)
    317 #define IFUNC_NONPLT
    318 	/* On SPARC, the PLT variant is called JMP_IREL and counted above. */
    319 	size_t		ifunc_remaining_nonplt;
    320 #endif
    321 	size_t		cxa_refcount;	/* For TLS destructors. */
    322 #ifdef __ARM_EABI__
    323 	void		*exidx_start;
    324 	size_t		exidx_sz;
    325 #endif
    326 } Obj_Entry;
    327 
    328 typedef struct Struct_DoneList {
    329 	const Obj_Entry **objs;		/* Array of object pointers */
    330 	unsigned int num_alloc;		/* Allocated size of the array */
    331 	unsigned int num_used;		/* Number of array slots used */
    332 } DoneList;
    333 
    334 
    335 #if defined(_RTLD_SOURCE)
    336 
    337 extern struct r_debug _rtld_debug;
    338 extern Search_Path *_rtld_default_paths;
    339 extern Obj_Entry *_rtld_objlist;
    340 extern Obj_Entry **_rtld_objtail;
    341 extern u_int _rtld_objcount;
    342 extern u_int _rtld_objloads;
    343 extern const uintptr_t _rtld_compat_obj[];
    344 extern Obj_Entry *_rtld_objmain;
    345 extern Obj_Entry _rtld_objself;
    346 extern Search_Path *_rtld_paths;
    347 extern Library_Xform *_rtld_xforms;
    348 extern bool _rtld_trust;
    349 extern Objlist _rtld_list_global;
    350 extern Objlist _rtld_list_main;
    351 extern Elf_Sym _rtld_sym_zero;
    352 extern u_int _rtld_objgen;
    353 
    354 #define	RTLD_MODEMASK 0x3
    355 
    356 /* Flags to be passed into _rtld_symlook_ family of functions. */
    357 #define SYMLOOK_IN_PLT	0x01	/* Lookup for PLT symbol */
    358 #define SYMLOOK_DLSYM	0x02	/* Return newest versioned symbol.
    359 				   Used by dlsym. */
    360 
    361 /* Flags for _rtld_load_object() and friends. */
    362 #define	_RTLD_GLOBAL	0x01	/* Add object to global DAG. */
    363 #define	_RTLD_MAIN	0x02
    364 #define	_RTLD_NOLOAD	0x04	/* dlopen() specified RTLD_NOLOAD. */
    365 #define	_RTLD_DLOPEN	0x08	/* Load_object() called from dlopen(). */
    366 
    367 /* Preallocation for static TLS model */
    368 #define	RTLD_STATIC_TLS_RESERVATION	64
    369 
    370 /* rtld.c */
    371 __dso_public char *dlerror(void);
    372 __dso_public void *dlopen(const char *, int);
    373 __dso_public void *dlsym(void *, const char *);
    374 __dso_public int dlclose(void *);
    375 __dso_public int dladdr(const void *, Dl_info *);
    376 __dso_public int dlinfo(void *, int, void *);
    377 __dso_public int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *),
    378     void *);
    379 
    380 __dso_public void *_dlauxinfo(void) __pure;
    381 __dso_public void __dl_cxa_refcount(void *addr, ssize_t delta);
    382 
    383 __dso_public pid_t __locked_fork(int *);
    384 
    385 #if defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__)
    386 /*
    387  * This is used by libgcc to find the start and length of the exception table
    388  * associated with a PC.
    389  */
    390 __dso_public _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr, int *);
    391 #endif
    392 
    393 /* These aren't exported */
    394 void _rtld_error(const char *, ...) __printflike(1,2);
    395 void _rtld_die(void) __dead;
    396 void *_rtld_objmain_sym(const char *);
    397 __dso_public void _rtld_debug_state(void) __noinline;
    398 void _rtld_linkmap_add(Obj_Entry *);
    399 void _rtld_linkmap_delete(Obj_Entry *);
    400 void _rtld_objlist_push_head(Objlist *, Obj_Entry *);
    401 void _rtld_objlist_push_tail(Objlist *, Obj_Entry *);
    402 Objlist_Entry *_rtld_objlist_find(Objlist *, const Obj_Entry *);
    403 void _rtld_ref_dag(Obj_Entry *);
    404 
    405 void _rtld_shared_enter(void);
    406 void _rtld_shared_exit(void);
    407 void _rtld_exclusive_enter(sigset_t *);
    408 void _rtld_exclusive_exit(sigset_t *);
    409 
    410 int _rtld_relro(const Obj_Entry *, bool);
    411 
    412 /* expand.c */
    413 size_t _rtld_expand_path(char *, size_t, const char *, const char *,\
    414     const char *);
    415 
    416 /* headers.c */
    417 void _rtld_digest_dynamic(const char *, Obj_Entry *);
    418 Obj_Entry *_rtld_digest_phdr(const Elf_Phdr *, int, caddr_t);
    419 
    420 /* load.c */
    421 Obj_Entry *_rtld_load_object(const char *, int);
    422 int _rtld_load_needed_objects(Obj_Entry *, int);
    423 int _rtld_preload(const char *);
    424 
    425 #define	OBJ_ERR	(Obj_Entry *)(-1)
    426 /* path.c */
    427 void _rtld_add_paths(const char *, Search_Path **, const char *);
    428 void _rtld_process_hints(const char *, Search_Path **, Library_Xform **,
    429     const char *);
    430 int _rtld_sysctl(const char *, void *, size_t *);
    431 
    432 /* reloc.c */
    433 int _rtld_do_copy_relocations(const Obj_Entry *);
    434 int _rtld_relocate_objects(Obj_Entry *, bool);
    435 int _rtld_relocate_nonplt_objects(Obj_Entry *);
    436 int _rtld_relocate_plt_lazy(Obj_Entry *);
    437 int _rtld_relocate_plt_objects(const Obj_Entry *);
    438 void _rtld_setup_pltgot(const Obj_Entry *);
    439 Elf_Addr _rtld_resolve_ifunc(const Obj_Entry *, const Elf_Sym *);
    440 Elf_Addr _rtld_resolve_ifunc2(const Obj_Entry *, Elf_Addr);
    441 
    442 void _rtld_call_ifunc(Obj_Entry *, sigset_t *, u_int);
    443 
    444 /* search.c */
    445 Obj_Entry *_rtld_load_library(const char *, const Obj_Entry *, int);
    446 
    447 /* symbol.c */
    448 const Elf_Sym *_rtld_symlook_obj(const char *, Elf_Hash *,
    449     const Obj_Entry *, u_int, const Ver_Entry *);
    450 const Elf_Sym *_rtld_find_symdef(unsigned long, const Obj_Entry *,
    451     const Obj_Entry **, u_int);
    452 const Elf_Sym *_rtld_find_plt_symdef(unsigned long, const Obj_Entry *,
    453     const Obj_Entry **, bool);
    454 
    455 const Elf_Sym *_rtld_symlook_list(const char *, Elf_Hash *,
    456     const Objlist *, const Obj_Entry **, u_int, const Ver_Entry *, DoneList *);
    457 const Elf_Sym *_rtld_symlook_default(const char *, Elf_Hash *,
    458     const Obj_Entry *, const Obj_Entry **, u_int, const Ver_Entry *);
    459 const Elf_Sym *_rtld_symlook_needed(const char *, Elf_Hash *,
    460     const Needed_Entry *, const Obj_Entry **, u_int, const Ver_Entry *,
    461     DoneList *, DoneList *);
    462 
    463 /* symver.c */
    464 void _rtld_object_add_name(Obj_Entry *, const char *);
    465 int _rtld_object_match_name(const Obj_Entry *, const char *);
    466 int _rtld_verify_object_versions(Obj_Entry *);
    467 
    468 static __inline const Ver_Entry *
    469 _rtld_fetch_ventry(const Obj_Entry *obj, unsigned long symnum)
    470 {
    471 	Elf_Half vernum;
    472 
    473 	if (obj->vertab) {
    474 		vernum = VER_NDX(obj->versyms[symnum].vs_vers);
    475 		if (vernum >= obj->vertabnum) {
    476 			_rtld_error("%s: symbol %s has wrong verneed value %d",
    477 			    obj->path, &obj->strtab[symnum], vernum);
    478 		} else if (obj->vertab[vernum].hash) {
    479 			return &obj->vertab[vernum];
    480 		}
    481 	}
    482 	return NULL;
    483 }
    484 
    485 #if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II)
    486 /* tls.c */
    487 void *_rtld_tls_get_addr(void *, size_t, size_t);
    488 void _rtld_tls_initial_allocation(void);
    489 int _rtld_tls_offset_allocate(Obj_Entry *);
    490 void _rtld_tls_offset_free(Obj_Entry *);
    491 
    492 extern size_t _rtld_tls_dtv_generation;
    493 extern size_t _rtld_tls_max_index;
    494 
    495 __dso_public extern void *__tls_get_addr(void *);
    496 #ifdef __i386__
    497 __dso_public extern void *___tls_get_addr(void *)
    498     __attribute__((__regparm__(1)));
    499 #endif
    500 #endif
    501 
    502 /* map_object.c */
    503 struct stat;
    504 Obj_Entry *_rtld_map_object(const char *, int, const struct stat *);
    505 void _rtld_obj_free(Obj_Entry *);
    506 Obj_Entry *_rtld_obj_new(void);
    507 
    508 #ifdef RTLD_LOADER
    509 /* function descriptors */
    510 #ifdef __HAVE_FUNCTION_DESCRIPTORS
    511 Elf_Addr _rtld_function_descriptor_alloc(const Obj_Entry *,
    512     const Elf_Sym *, Elf_Addr);
    513 const void *_rtld_function_descriptor_function(const void *);
    514 
    515 Elf_Addr _rtld_call_function_addr(const Obj_Entry *, Elf_Addr);
    516 #else
    517 static inline Elf_Addr
    518 _rtld_call_function_addr(const Obj_Entry *obj, Elf_Addr addr)
    519 {
    520 	return ((Elf_Addr(*)(void))addr)();
    521 }
    522 #endif /* __HAVE_FUNCTION_DESCRIPTORS */
    523 #endif /* RTLD_LOADER */
    524 
    525 #endif /* _RTLD_SOURCE */
    526 
    527 #endif /* RTLD_H */
    528