1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright (c) 1988 AT&T 23 * All Rights Reserved 24 * 25 * 26 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 27 * Use is subject to license terms. 28 */ 29 30 #ifndef __RTLD_H 31 #define __RTLD_H 32 33 /* 34 * Common header for run-time linker. 35 */ 36 #include <sys/types.h> 37 #include <sys/stat.h> 38 #include <sys/avl.h> 39 #include <stdarg.h> 40 #include <synch.h> 41 #include <signal.h> 42 #include <errno.h> 43 #include <unistd.h> 44 #include <link.h> 45 #include <rtld.h> 46 #include <sgs.h> 47 #include <machdep.h> 48 #include <rtc.h> 49 #include <debug.h> 50 #include <msg.h> 51 #include <libc_int.h> 52 53 #ifdef __cplusplus 54 extern "C" { 55 #endif 56 57 /* 58 * Dependency search rule order. 59 */ 60 #define RPLENV 1 /* replaceable LD_LIBRARY_PATH */ 61 #define PRMENV 2 /* permanent LD_LIBRARY_PATH */ 62 #define RUNPATH 3 /* callers runpath */ 63 #define DEFAULT 4 /* default library path */ 64 65 66 /* 67 * Data structure for file class specific functions and data. 68 */ 69 typedef struct fct { 70 int (*fct_are_u_this)(Rej_desc *); /* determine type of object */ 71 ulong_t (*fct_entry_pt)(void); /* get entry point */ 72 Rt_map *(*fct_map_so)(Lm_list *, Aliste, const char *, const char *, 73 int, int *); /* map in a shared object */ 74 void (*fct_unmap_so)(Rt_map *); /* unmap a shared object */ 75 int (*fct_needed)(Lm_list *, Aliste, Rt_map *, int *); 76 /* determine needed objects */ 77 Sym *(*fct_lookup_sym)(Slookup *, Rt_map **, uint_t *, int *); 78 /* initialize symbol lookup */ 79 int (*fct_reloc)(Rt_map *, uint_t, int *); 80 /* relocate shared object */ 81 Pnode *fct_dflt_dirs; /* list of default dirs to */ 82 /* search */ 83 Pnode *fct_secure_dirs; /* list of secure dirs to */ 84 /* search (set[ug]id) */ 85 Pnode *(*fct_fix_name)(const char *, Rt_map *, uint_t); 86 /* transpose name */ 87 char *(*fct_get_so)(const char *, const char *); 88 /* get shared object */ 89 void (*fct_dladdr)(ulong_t, Rt_map *, Dl_info *, void **, int); 90 /* get symbolic address */ 91 Sym *(*fct_dlsym)(Grp_hdl *, Slookup *, Rt_map **, uint_t *, 92 int *); /* process dlsym request */ 93 int (*fct_verify_vers)(const char *, Rt_map *, Rt_map *); 94 /* verify versioning (ELF) */ 95 int (*fct_set_prot)(Rt_map *, int); 96 /* set protection */ 97 } Fct; 98 99 100 /* 101 * Return codes for util::anon_map(). 102 */ 103 typedef enum { 104 AM_OK, /* mmap(MAP_ANON) succeeded */ 105 AM_NOSUP, /* mmap(MAP_ANON) not supported (old OS) */ 106 AM_ERROR /* mmap(MAP_ANON) failed */ 107 } Am_ret; 108 109 110 /* 111 * Macros for getting to the file class table. 112 */ 113 #define LM_ENTRY_PT(X) ((X)->rt_fct->fct_entry_pt) 114 #define LM_UNMAP_SO(X) ((X)->rt_fct->fct_unmap_so) 115 #define LM_NEEDED(X) ((X)->rt_fct->fct_needed) 116 #define LM_LOOKUP_SYM(X) ((X)->rt_fct->fct_lookup_sym) 117 #define LM_RELOC(X) ((X)->rt_fct->fct_reloc) 118 #define LM_DFLT_DIRS(X) ((X)->rt_fct->fct_dflt_dirs) 119 #define LM_SECURE_DIRS(X) ((X)->rt_fct->fct_secure_dirs) 120 #define LM_FIX_NAME(X) ((X)->rt_fct->fct_fix_name) 121 #define LM_GET_SO(X) ((X)->rt_fct->fct_get_so) 122 #define LM_DLADDR(X) ((X)->rt_fct->fct_dladdr) 123 #define LM_DLSYM(X) ((X)->rt_fct->fct_dlsym) 124 #define LM_VERIFY_VERS(X) ((X)->rt_fct->fct_verify_vers) 125 #define LM_SET_PROT(X) ((X)->rt_fct->fct_set_prot) 126 127 128 /* 129 * Define Alist initialization sizes. 130 */ 131 #define AL_CNT_ALIAS 2 /* ALIAS() initial alist count */ 132 #define AL_CNT_DEPENDS 10 /* DEPENDS() initial alist count */ 133 #define AL_CNT_CALLERS 10 /* CALLERS() initial alist count */ 134 #define AL_CNT_GROUPS 4 /* GROUPS() initial alist count */ 135 #define AL_CNT_COPYREL 10 /* COPY() initial alist count */ 136 #define AL_CNT_LAZYFIND 10 /* elf_lazy_find_sym() initial alist */ 137 /* count */ 138 #define AL_CNT_GRPCLCT 10 /* gdp_collect() initial alist count */ 139 #define AL_CNT_DEPCLCT 10 /* load_so() initial alist count */ 140 #define AL_CNT_RTLDINFO 1 /* RTLDINFO() initial alist count */ 141 #define AL_CNT_FPNODE 2 /* FPNODE() initial alist count */ 142 #define AL_CNT_LMLISTS 8 /* lm_lists initial alist count */ 143 #define AL_CNT_LMNOW 8 /* lm_now initial alist count */ 144 #define AL_CNT_RELBIND 20 /* relocation binding alist count */ 145 #define AL_CNT_ACTAUDIT 2 /* lm_actaudit alist count */ 146 #define AL_CNT_MOVES 10 /* move_data alist count */ 147 148 149 /* 150 * Size of buffer for building error messages. 151 */ 152 #define ERRSIZE 2048 /* MAXPATHLEN * 2 */ 153 154 155 /* 156 * Configuration file information. 157 */ 158 typedef struct config { 159 const char *c_name; 160 Addr c_bgn; 161 Addr c_end; 162 Word *c_hashtbl; 163 Word *c_hashchain; 164 const char *c_strtbl; 165 Rtc_obj *c_objtbl; 166 Rtc_fltr *c_fltr; 167 Rtc_flte *c_flte; 168 } Config; 169 170 /* 171 * Register symbol list. 172 */ 173 typedef struct reglist { 174 Rt_map *rl_lmp; /* defining object */ 175 Sym *rl_sym; /* regsym */ 176 struct reglist *rl_next; /* next entry */ 177 } Reglist; 178 179 /* 180 * Data structure to hold interpreter information. 181 */ 182 typedef struct interp { 183 char *i_name; /* interpreter name */ 184 caddr_t i_faddr; /* address interpreter is mapped at */ 185 } Interp; 186 187 /* 188 * Data structure used to keep track of copy relocations. These relocations 189 * are collected during initial relocation processing and maintained on the 190 * COPY(lmp) list of the defining object. Each copy list is also added to the 191 * COPY(lmp) of the head object (normally the application dynamic executable) 192 * from which they will be processed after all relocations are done. 193 * 194 * The use of RTLD_GROUP will also reference individual objects COPY(lmp) lists 195 * in case a bound symbol must be assigned to it actual copy relocation. 196 */ 197 typedef struct { 198 const char *r_name; /* symbol name */ 199 Sym *r_rsym; /* reference symbol table entry */ 200 Rt_map *r_rlmp; /* reference link map */ 201 Rt_map *r_dlmp; /* definition link map */ 202 Sym *r_dsym; /* definition symbol table entry */ 203 void *r_radd; /* copy to address */ 204 const void *r_dadd; /* copy from address */ 205 ulong_t r_size; /* copy size bytes */ 206 } Rel_copy; 207 208 /* 209 * Data structure to hold initial file mapping information. Used to 210 * communicate during initial object mapping and provide for error recovery. 211 */ 212 typedef struct { 213 char *fm_maddr; /* address of initial mapping */ 214 size_t fm_msize; /* size of initial mapping */ 215 size_t fm_fsize; /* actual file size */ 216 ulong_t fm_etext; /* end of text segment */ 217 int fm_mflags; /* mapping flags */ 218 ulong_t fm_hwptr; /* hardware capabilities pointer */ 219 } Fmap; 220 221 #define FMAP_SIZE 0x8000 /* initial size to map from a file */ 222 /* big enough to capture standard */ 223 /* filters */ 224 /* 225 * Define a file descriptor, which maintains information regarding a pathname 226 * that has been opened and minimally inspected. 227 */ 228 typedef struct { 229 Rt_map *fd_lmp; /* existing link-map pointer */ 230 Fct *fd_ftp; /* file functions pointer */ 231 const char *fd_oname; /* original file name */ 232 const char *fd_odir; /* original directory name */ 233 const char *fd_nname; /* new file (expanded) name */ 234 const char *fd_pname; /* new path (resolved) name */ 235 dev_t fd_dev; /* file device number */ 236 rtld_ino_t fd_ino; /* file inode number */ 237 int fd_fd; /* open file descriptor */ 238 uint_t fd_flags; 239 avl_index_t fd_avlwhere; /* avl tree insertion index */ 240 Fmap fd_fmap; /* file mapping information */ 241 } Fdesc; 242 243 #define FLG_FD_ALTER 0x01 /* file is an alternate */ 244 #define FLG_FD_SLASH 0x02 /* file contains a "/" */ 245 246 /* 247 * File descriptor availability flag. 248 */ 249 #define FD_UNAVAIL -1 250 251 /* 252 * Disabled filter flag. Filter objects are referenced using their .dynamic 253 * index (DT_FILTER or DT_AUXILIARY). This index is saved and used to lookup 254 * the required filter. Note that 0 is a valid .dynamic index. The caller's 255 * OBJFLTRNDX() element is initialized using the following flag, and should 256 * the filter's initialization fail, is reset to this value to indicate the 257 * filter is disabled. UINT_MAX provides a convenient invalid .dynamic index. 258 */ 259 #define FLTR_DISABLED UINT_MAX 260 261 /* 262 * Status flags for rtld_flags 263 */ 264 #define RT_FL_THREADS 0x00000001 /* threads are enabled */ 265 #define RT_FL_WARNFLTR 0x00000002 /* warn of missing filtees (ldd) */ 266 #define RT_FL_DBNOTIF 0x00000004 /* binding activity going on */ 267 268 #ifdef SIEBEL_DISABLE 269 #define RT_FL_DISFIX_1 0x00000008 /* disable fix number 1 */ 270 #endif 271 272 #define RT_FL_NOBIND 0x00000010 /* don't carry out plt binding */ 273 #define RT_FL_NOVERSION 0x00000020 /* disable version checking */ 274 #define RT_FL_SECURE 0x00000040 /* setuid/segid flag */ 275 #define RT_FL_APPLIC 0x00000080 /* are we executing user code */ 276 #define RT_FL_CONCUR 0x00000100 /* thread concurrency checks required */ 277 #define RT_FL_CONFGEN 0x00000200 /* don't relocate initiating object */ 278 /* set by crle(1). */ 279 #define RT_FL_CONFAPP 0x00000400 /* application specific configuration */ 280 /* cache required */ 281 #define RT_FL_DEBUGGER 0x00000800 /* a debugger is monitoring us */ 282 #define RT_FL_OPERATION 0x00001000 /* start recording operations */ 283 #define RT_FL_NEWLOCALE 0x00002000 /* message locale has changed */ 284 #define RT_FL_NOBAPLT 0x00004000 /* sparc: don't use ba plt's */ 285 #define RT_FL_NOAUXFLTR 0x00008000 /* disable auxiliary filters */ 286 #define RT_FL_NOCONCUR 0x00010000 /* disable thread concurrency checks */ 287 #define RT_FL_NOAUDIT 0x00020000 /* disable auditing */ 288 #define RT_FL_ATEXIT 0x00040000 /* we're shutting down */ 289 #define RT_FL_SILENCERR 0x00080000 /* silence error messages */ 290 #define RT_FL_BREADTH 0x00100000 /* use breadth-first for .init/.fini */ 291 #define RT_FL_INITFIRST 0x00200000 /* processing a DT_INITFIRST object */ 292 #define RT_FL_RELATIVE 0x00400000 /* relative path expansion required */ 293 #define RT_FL_EXECNAME 0x00800000 /* AT_SUN_EXECNAME vector is avail */ 294 #define RT_FL_DEMANGLE 0x01000000 /* demangle C++ symbol names */ 295 #define RT_FL_NOCFG 0x02000000 /* disable config file use */ 296 #define RT_FL_NODIRCFG 0x04000000 /* disable directory config use */ 297 #define RT_FL_NOOBJALT 0x08000000 /* disable object alternative use */ 298 #define RT_FL_NOENVCFG 0x10000000 /* disable config envars use */ 299 #define RT_FL_DIRCFG 0x20000000 /* directory config info available */ 300 #define RT_FL_OBJALT 0x40000000 /* object alternatives are available */ 301 #define RT_FL_MEMRESV 0x80000000 /* memory reservation established */ 302 303 /* 304 * Status flags for rtld_flags2 305 */ 306 #define RT_FL2_HASAUDIT 0x00000001 /* auditing lm_list is present */ 307 #define RT_FL2_RTLDSEEN 0x00000002 /* rtldinfo has been set */ 308 #define RT_FL2_UNIFPROC 0x00000004 /* libc/libthread unified environment */ 309 #define RT_FL2_NOMALIGN 0x00000008 /* mmap MAP_ALIGN isn't available */ 310 #define RT_FL2_NOFLTCFG 0x00000010 /* disable config filter use */ 311 #define RT_FL2_FLTCFG 0x00000020 /* filter config info available */ 312 #define RT_FL2_HWCAP 0x00000040 /* hardware capabilities available */ 313 #define RT_FL2_FTL2WARN 0x00000080 /* convert fatal to warning messages */ 314 #define RT_FL2_BINDNOW 0x00000100 /* LD_BIND_NOW in effect */ 315 #define RT_FL2_BINDLAZY 0x00000200 /* disable RTLD_NOW (and LD_BIND_NOW) */ 316 #define RT_FL2_PLMSETUP 0x00000400 /* primary link-map set up complete */ 317 #define RT_FL2_BRANDED 0x00000800 /* process is branded */ 318 #define RT_FL2_NOPLM 0x00001000 /* process has no primary link map */ 319 #define RT_FL2_SETUID 0x00002000 /* ld.so.1 is setuid root */ 320 #define RT_FL2_ADDR32 0x00004000 /* 32-bit address space requirement */ 321 322 /* 323 * Information flags for env_info. 324 */ 325 #define ENV_INF_PATHCFG 0x00000001 /* replaceable LD_LIBRARY_PATH */ 326 /* originates from configuration */ 327 /* file */ 328 #define ENV_INF_FLAGCFG 0x00000002 /* replaceable LD_FLAGS originates */ 329 /* from configuration file */ 330 331 /* 332 * RTLDINFO descriptor. 333 */ 334 typedef struct { 335 Rt_map *rti_lmp; /* RTLDINFO provider */ 336 Lc_interface *rti_info; /* RTLDINFO data */ 337 } Rti_desc; 338 339 /* 340 * Binding flags for the bindguard routines. 341 * These are defined in usr/src/lib/libc/inc/libc_int.h in the 342 * latest version of the libc/rtld runtime interface (CI_V_FIVE). 343 */ 344 #if !defined(CI_V_FIVE) 345 #define THR_FLG_RTLD 0x00000001 /* rtldlock bind_guard() flag */ 346 #define THR_FLG_NOLOCK 0x00000000 /* no-op before CI_V_FIVE */ 347 #define THR_FLG_REENTER 0x00000000 /* no-op before CI_V_FIVE */ 348 #endif 349 350 #define ROUND(x, a) (((int)(x) + ((int)(a) - 1)) & ~((int)(a) - 1)) 351 352 /* 353 * Print buffer. 354 */ 355 typedef struct { 356 char *pr_buf; /* pointer to beginning of buffer */ 357 char *pr_cur; /* pointer to next free char in buffer */ 358 size_t pr_len; /* buffer size */ 359 int pr_fd; /* output fd */ 360 } Prfbuf; 361 362 /* 363 * dlopen() handle list size. 364 */ 365 #define HDLIST_SZ 101 /* prime no. for hashing */ 366 #define HDLIST_ORP 102 /* orphan handle list */ 367 368 /* 369 * Define expansion path information. Search paths, i.e., LD_LIBRARY_PATH, 370 * RPATHS, etc. are defined using la_objsearch() information (see LA_SER flags 371 * in link.h). Definitions here extend the path information to other uses of 372 * pathname expansion, and are or'd together with any LA_SER_* flags. 373 */ 374 #define PN_FLG_EXTLOAD 0x00001000 /* path defines extra loaded objects */ 375 /* (preload, audit etc.) */ 376 #define PN_FLG_UNIQUE 0x00002000 /* ensure path is unique */ 377 #define PN_FLG_USED 0x00004000 /* indicate that path is used */ 378 #define PN_FLG_DUPLICAT 0x00008000 /* path is a duplicate */ 379 #define PN_FLG_FULLPATH 0x00010000 /* ensure path is a full path */ 380 381 #define PN_FLG_MASK 0x000ff000 /* mask for p_orig incorporation */ 382 383 /* 384 * Define reserved path tokens. These are used to prevent various expansions 385 * from occurring, and record those expansions that do. Note that any expansion 386 * information is also recorded in the p_orig field of a Pnode, and thus is 387 * or'd together with any LA_SER, and PN_FLG flags. 388 */ 389 #define PN_TKN_ORIGIN 0x00100000 /* $ORIGIN expansion has occurred */ 390 #define PN_TKN_PLATFORM 0x00200000 /* $PLATFORM expansion has occurred */ 391 #define PN_TKN_OSNAME 0x00400000 /* $OSNAME expansion has occurred */ 392 #define PN_TKN_OSREL 0x00800000 /* $OSREL expansion has occurred */ 393 #define PN_TKN_ISALIST 0x01000000 /* $ISALIST expansion has occurred */ 394 #define PN_TKN_HWCAP 0x02000000 /* $HWCAP expansion has occurred */ 395 396 #define PN_TKN_MASK 0xfff00000 /* mask for p_orig incorporation */ 397 398 /* 399 * Additional token expansion information. Although these flags may be set 400 * within a token data item they are masked off with PN_TKN_MASK prior to any 401 * expansion information being recorded in a Pnode for later diagnostics. 402 */ 403 #define TKN_NONE 0x00000001 /* no token expansion has occurred */ 404 #define TKN_DOTSLASH 0x00000002 /* path contains a "./" */ 405 406 /* 407 * Define _caller flags. 408 */ 409 #define CL_NONE 0 410 #define CL_EXECDEF 1 /* supply the executable as a default */ 411 /* if the caller can't be determined */ 412 413 /* 414 * Binding information flags. These flags are passed up from low level binding 415 * routines to indicate "additional" information, such as why a binding has been 416 * rejected. These flags use the same data element as is used to record any 417 * DBG_BINFO flags. The DBG_BINFO flags are used to define the final bindings 418 * information and are used to provide better binding diagnostics. 419 */ 420 #define BINFO_REJDIRECT 0x010000 /* reject a direct binding */ 421 #define BINFO_REJSINGLE 0x100000 /* reject a singleton binding */ 422 #define BINFO_REJGROUP 0x200000 /* reject a group binding */ 423 424 #define BINFO_MSK_TRYAGAIN 0xf00000 /* a mask of bindings that */ 425 /* should be retried */ 426 #define BINFO_MSK_REJECTED 0xff0000 /* a mask of bindings that */ 427 /* have been rejected */ 428 429 /* 430 * The 32-bit version of rtld uses special stat() wrapper functions 431 * that preserve the non-largefile semantics of stat()/fstat() while 432 * allowing for large inode values. The 64-bit rtld uses stat() directly. 433 */ 434 #ifdef _LP64 435 #define rtld_fstat fstat 436 #define rtld_stat stat 437 typedef struct stat rtld_stat_t; 438 #else 439 typedef struct { 440 dev_t st_dev; 441 rtld_ino_t st_ino; 442 mode_t st_mode; 443 uid_t st_uid; 444 off_t st_size; 445 timestruc_t st_mtim; 446 #ifdef sparc 447 blksize_t st_blksize; 448 #endif 449 } rtld_stat_t; 450 #endif 451 452 453 /* 454 * Data declarations. 455 */ 456 extern Lc_desc glcs[]; /* global external interfaces */ 457 458 extern Rt_lock rtldlock; /* rtld lock */ 459 extern int thr_flg_nolock; 460 extern int thr_flg_reenter; 461 462 extern List dynlm_list; /* dynamic list of link-maps */ 463 extern char **environ; /* environ pointer */ 464 465 extern int dyn_plt_ent_size; /* Size of dynamic plt's */ 466 extern ulong_t at_flags; /* machine specific file flags */ 467 extern const char *procname; /* file name of executing process */ 468 extern Rtld_db_priv r_debug; /* debugging information */ 469 extern char *lasterr; /* string describing last error */ 470 extern Interp *interp; /* ELF executable interpreter info */ 471 extern const char *rtldname; /* name of the dynamic linker */ 472 extern List hdl_list[]; /* dlopen() handle list */ 473 extern size_t syspagsz; /* system page size */ 474 extern char *platform; /* platform name */ 475 extern size_t platform_sz; /* platform name string size */ 476 extern Isa_desc *isa; /* isalist descriptor */ 477 extern Uts_desc *uts; /* utsname descriptor */ 478 extern uint_t rtld_flags; /* status flags for RTLD */ 479 extern uint_t rtld_flags2; /* additional status flags for RTLD */ 480 extern Fmap *fmap; /* Initial file mapping info */ 481 extern uint32_t pltcnt21d; /* cnt of 21d PLTs */ 482 extern uint32_t pltcnt24d; /* cnt of 24d PLTs */ 483 extern uint32_t pltcntu32; /* cnt of u32 PLTs */ 484 extern uint32_t pltcntu44; /* cnt of u44 PLTs */ 485 extern uint32_t pltcntfull; /* cnt of full PLTs */ 486 extern uint32_t pltcntfar; /* cnt of far PLTs */ 487 extern uchar_t search_rules[]; /* dependency search rules */ 488 489 extern Fct elf_fct; /* ELF file class dependent data */ 490 491 #if defined(__sparc) && !defined(__sparcv9) 492 extern Fct aout_fct; /* a.out (4.x) file class dependent */ 493 /* data */ 494 #endif 495 496 extern const char *locale; /* locale environment setting */ 497 498 extern Config *config; /* configuration structure */ 499 extern const char *locale; /* locale environment setting */ 500 501 extern const char *rpl_audit; /* replaceable LD_AUDIT string */ 502 extern const char *rpl_debug; /* replaceable LD_DEBUG string */ 503 extern const char *rpl_ldflags; /* replaceable LD_FLAGS string */ 504 extern const char *rpl_libpath; /* replaceable LD_LIBRARY string */ 505 extern Pnode *rpl_libdirs; /* and its associated Pnode list */ 506 extern const char *rpl_preload; /* replaceable LD_PRELOAD string */ 507 508 extern const char *prm_audit; /* permanent LD_AUDIT string */ 509 extern const char *prm_debug; /* permanent LD_DEBUG string */ 510 extern const char *prm_ldflags; /* permanent LD_FLAGS string */ 511 extern const char *prm_libpath; /* permanent LD_LIBRARY string */ 512 extern Pnode *prm_libdirs; /* and its associated Pnode list */ 513 extern const char *prm_preload; /* permanent LD_PRELOAD string */ 514 515 extern uint_t env_info; /* information regarding environment */ 516 /* variables */ 517 extern int killsig; /* signal sent on fatal exit */ 518 519 extern uint_t audit_argcnt; /* no. of stack args to copy */ 520 extern Audit_desc *auditors; /* global auditors */ 521 522 extern char **_environ; 523 524 extern const char *dbg_file; /* debugging directed to a file */ 525 526 extern Reglist *reglist; /* list of register symbols */ 527 528 extern const Msg err_reject[]; /* rejection error message tables */ 529 extern const Msg ldd_reject[]; 530 531 extern const char *profile_name; /* object being profiled */ 532 extern const char *profile_out; /* profile output file */ 533 extern const char *profile_lib; /* audit library to perform profile */ 534 535 extern Dl_argsinfo argsinfo; /* process argument, environment and */ 536 /* auxv information */ 537 538 extern const char *err_strs[]; /* diagnostic error string headers */ 539 extern const char *nosym_str; /* MSG_GEN_NOSYM message cache */ 540 541 extern ulong_t hwcap; /* hardware capabilities */ 542 extern ulong_t sfcap; /* software capabilities */ 543 544 extern avl_tree_t *nfavl; /* not-found AVL path name tree */ 545 546 /* 547 * Function declarations. 548 */ 549 extern void addfree(void *, size_t); 550 extern int append_alias(Rt_map *, const char *, int *); 551 extern int analyze_lmc(Lm_list *, Aliste, Rt_map *, int *); 552 extern Am_ret anon_map(Lm_list *, caddr_t *, size_t, int, int); 553 extern Fct *are_u_this(Rej_desc *, int, rtld_stat_t *, 554 const char *); 555 extern void atexit_fini(void); 556 extern int bind_one(Rt_map *, Rt_map *, uint_t); 557 extern int bufprint(Prfbuf *, const char *, ...); 558 extern void call_array(Addr *, uint_t, Rt_map *, Word); 559 extern void call_fini(Lm_list *, Rt_map **); 560 extern void call_init(Rt_map **, int); 561 extern int callable(Rt_map *, Rt_map *, Grp_hdl *, uint_t); 562 extern Rt_map *_caller(caddr_t, int); 563 extern caddr_t caller(void); 564 extern void *calloc(size_t, size_t); 565 extern void cap_assign(Cap *, Rt_map *); 566 extern int cap_check(Rej_desc *, Ehdr *); 567 extern const char *_conv_reloc_type(uint_t rel); 568 extern uintptr_t dbg_setup(const char *, Dbg_desc *); 569 extern const char *demangle(const char *); 570 extern int dlclose_intn(Grp_hdl *, Rt_map *); 571 extern int dlclose_core(Grp_hdl *, Rt_map *, Lm_list *); 572 extern Sym *dlsym_handle(Grp_hdl *, Slookup *, Rt_map **, 573 uint_t *, int *); 574 extern void *dlsym_intn(void *, const char *, Rt_map *, Rt_map **); 575 extern Grp_hdl *dlmopen_intn(Lm_list *, const char *, int, Rt_map *, 576 uint_t, uint_t); 577 extern size_t doprf(const char *, va_list, Prfbuf *); 578 extern int dowrite(Prfbuf *); 579 extern void dz_init(int); 580 extern caddr_t dz_map(Lm_list *, caddr_t, size_t, int, int); 581 extern int elf_config(Rt_map *, int); 582 extern int elf_mach_flags_check(Rej_desc *, Ehdr *); 583 extern Rtc_obj *elf_config_ent(const char *, Word, int, const char **); 584 extern Pnode *elf_config_flt(Lm_list *, const char *, const char *); 585 extern ulong_t elf_hash(const char *); 586 extern void elf_reloc_bad(Rt_map *, void *, uchar_t, ulong_t, 587 ulong_t); 588 extern ulong_t elf_reloc_relative(ulong_t, ulong_t, ulong_t, 589 ulong_t, ulong_t, ulong_t); 590 extern ulong_t elf_reloc_relacount(ulong_t, ulong_t, 591 ulong_t, ulong_t); 592 extern long elf_static_tls(Rt_map *, Sym *, void *, uchar_t, char *, 593 ulong_t, long); 594 extern int enter(int); 595 extern uint_t expand(char **, size_t *, char **, uint_t, uint_t, 596 Rt_map *); 597 extern Pnode *expand_paths(Rt_map *, const char *, uint_t, uint_t); 598 extern void free_hdl(Grp_hdl *, Rt_map *, uint_t); 599 extern void file_notfound(Lm_list *, const char *, Rt_map *, 600 uint_t, Rej_desc *); 601 extern int find_path(Lm_list *, const char *, Rt_map *, uint_t, 602 Fdesc *, Rej_desc *, int *); 603 extern int fpavl_insert(Lm_list *, Rt_map *, const char *, 604 avl_index_t); 605 extern Rt_map *fpavl_recorded(Lm_list *, const char *, avl_index_t *); 606 extern void fpavl_remove(Rt_map *); 607 extern size_t fullpath(Rt_map *, const char *); 608 extern void fmap_setup(); 609 extern void get_lcinterface(Rt_map *, Lc_interface *); 610 extern Lmid_t get_linkmap_id(Lm_list *); 611 extern Pnode *get_next_dir(Pnode **, Rt_map *, uint_t); 612 extern int hdl_add(Grp_hdl *, Rt_map *, uint_t); 613 extern Grp_hdl *hdl_create(Lm_list *, Rt_map *, Rt_map *, uint_t, 614 uint_t, uint_t); 615 extern int hdl_initialize(Grp_hdl *, Rt_map *, int, int); 616 extern Pnode *hwcap_filtees(Pnode **, Aliste, Lm_cntl *, Dyninfo *, 617 Rt_map *, const char *, int, uint_t, int *); 618 extern void is_dep_ready(Rt_map *, Rt_map *, int); 619 extern void is_dep_init(Rt_map *, Rt_map *); 620 extern int is_move_data(caddr_t); 621 extern int is_path_secure(char *, Rt_map *, uint_t, uint_t); 622 extern int is_rtld_setuid(); 623 extern int is_sym_interposer(Rt_map *, Sym *); 624 extern void ldso_plt_init(Rt_map *); 625 extern Listnode *list_append(List *, const void *); 626 extern Listnode *list_insert(List *, const void *, Listnode *); 627 extern Listnode *list_prepend(List *, const void *); 628 extern void list_delete(List *, void *); 629 extern void leave(Lm_list *, int); 630 extern void lm_append(Lm_list *, Aliste, Rt_map *); 631 extern void lm_delete(Lm_list *, Rt_map *); 632 extern void lm_move(Lm_list *, Aliste, Aliste, Lm_cntl *, 633 Lm_cntl *); 634 extern void load_completion(Rt_map *); 635 extern Rt_map *load_hwcap(Lm_list *, Aliste, const char *, Rt_map *, 636 uint_t, uint_t, Grp_hdl **, Rej_desc *, int *); 637 extern Rt_map *load_path(Lm_list *, Aliste, const char **, Rt_map *, 638 int, uint_t, Grp_hdl **, Fdesc *, Rej_desc *, 639 int *); 640 extern Rt_map *load_one(Lm_list *, Aliste, Pnode *, Rt_map *, int, 641 uint_t, Grp_hdl **, int *); 642 extern int load_trace(Lm_list *, const char **, Rt_map *); 643 extern void nfavl_insert(const char *, avl_index_t); 644 extern int nfavl_recorded(const char *, avl_index_t *); 645 extern caddr_t nu_map(Lm_list *, caddr_t, size_t, int, int); 646 extern void *malloc(size_t); 647 extern int move_data(Rt_map *); 648 extern int pr_open(Lm_list *); 649 extern void rd_event(Lm_list *, rd_event_e, r_state_e); 650 extern int readenv_user(const char **, Word *, Word *, int); 651 extern int readenv_config(Rtc_env *, Addr, int); 652 extern void rejection_inherit(Rej_desc *, Rej_desc *); 653 extern int relocate_lmc(Lm_list *, Aliste, Rt_map *, Rt_map *, 654 int *); 655 extern int relocate_finish(Rt_map *, APlist *, int, int); 656 extern void remove_cntl(Lm_list *, Aliste); 657 extern int remove_hdl(Grp_hdl *, Rt_map *, int *); 658 extern void remove_lmc(Lm_list *, Rt_map *, Lm_cntl *, Aliste, 659 const char *); 660 extern void remove_incomplete(Lm_list *, Aliste); 661 extern void remove_lists(Rt_map *, int); 662 extern void remove_lml(Lm_list *); 663 extern void remove_pnode(Pnode *); 664 extern void remove_rej(Rej_desc *); 665 extern void remove_so(Lm_list *, Rt_map *); 666 extern int rt_cond_broadcast(Rt_cond *); 667 extern Rt_cond *rt_cond_create(void); 668 extern int rt_cond_wait(Rt_cond *, Rt_lock *); 669 extern int rt_bind_guard(int); 670 extern int rt_bind_clear(int); 671 extern int rt_get_extern(Lm_list *, Rt_map *); 672 extern int rt_mutex_lock(Rt_lock *); 673 extern int rt_mutex_unlock(Rt_lock *); 674 extern void rt_thr_init(Lm_list *); 675 extern thread_t rt_thr_self(void); 676 extern void rtld_db_dlactivity(Lm_list *); 677 extern void rtld_db_preinit(Lm_list *); 678 extern void rtld_db_postinit(Lm_list *); 679 extern void rtldexit(Lm_list *, int); 680 #ifndef _LP64 681 extern int rtld_fstat(int, rtld_stat_t *restrict); 682 extern int rtld_stat(const char *restrict, rtld_stat_t *restrict); 683 #endif 684 extern int rtld_getopt(char **, char ***, auxv_t **, Word *, 685 Word *, int); 686 extern void security(uid_t, uid_t, gid_t, gid_t, int); 687 extern void set_environ(Lm_list *); 688 extern Rt_map *setup(char **, auxv_t *, Word, char *, int, char *, 689 Dyn *, ulong_t, ulong_t, int fd, Phdr *, char *, 690 char **, int, uid_t, uid_t, gid_t, gid_t, void *, 691 int, uint_t); 692 extern void spavl_insert(const char *); 693 extern int spavl_recorded(const char *, avl_index_t *); 694 extern int tls_assign(Lm_list *, Rt_map *, Phdr *); 695 extern void tls_modaddrem(Rt_map *, uint_t); 696 extern int tls_statmod(Lm_list *, Rt_map *); 697 extern Rt_map **tsort(Rt_map *, int, int); 698 extern void unused(Lm_list *); 699 extern int update_mode(Rt_map *, int, int); 700 extern void zero(caddr_t, size_t); 701 702 #if defined(__sparc) 703 /* 704 * SPARC Register symbol support. 705 */ 706 extern int elf_regsyms(Rt_map *); 707 extern void set_sparc_g1(ulong_t); 708 extern void set_sparc_g2(ulong_t); 709 extern void set_sparc_g3(ulong_t); 710 extern void set_sparc_g4(ulong_t); 711 extern void set_sparc_g5(ulong_t); 712 extern void set_sparc_g6(ulong_t); 713 extern void set_sparc_g7(ulong_t); 714 #endif 715 716 extern long _sysconfig(int); 717 718 #ifdef __cplusplus 719 } 720 #endif 721 722 #endif /* __RTLD_H */ 723