1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _RTLD_H 28*7c478bd9Sstevel@tonic-gate #define _RTLD_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Global include file for the runtime linker support library. 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate #include <time.h> 36*7c478bd9Sstevel@tonic-gate #include <sgs.h> 37*7c478bd9Sstevel@tonic-gate #include <thread.h> 38*7c478bd9Sstevel@tonic-gate #include <synch.h> 39*7c478bd9Sstevel@tonic-gate #include <machdep.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/avl.h> 41*7c478bd9Sstevel@tonic-gate #include <alist.h> 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 44*7c478bd9Sstevel@tonic-gate #include <inttypes.h> 45*7c478bd9Sstevel@tonic-gate #endif 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 48*7c478bd9Sstevel@tonic-gate extern "C" { 49*7c478bd9Sstevel@tonic-gate #endif 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate /* 53*7c478bd9Sstevel@tonic-gate * Linked list of directories or filenames (built from colon separated string). 54*7c478bd9Sstevel@tonic-gate */ 55*7c478bd9Sstevel@tonic-gate typedef struct pnode { 56*7c478bd9Sstevel@tonic-gate const char *p_name; 57*7c478bd9Sstevel@tonic-gate const char *p_oname; 58*7c478bd9Sstevel@tonic-gate size_t p_len; 59*7c478bd9Sstevel@tonic-gate uint_t p_orig; 60*7c478bd9Sstevel@tonic-gate void *p_info; 61*7c478bd9Sstevel@tonic-gate struct pnode *p_next; 62*7c478bd9Sstevel@tonic-gate } Pnode; 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate typedef struct rt_map Rt_map; 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate /* 67*7c478bd9Sstevel@tonic-gate * A binding descriptor. Establishes the binding relationship between two 68*7c478bd9Sstevel@tonic-gate * objects, the caller (originator and the dependency (destination). 69*7c478bd9Sstevel@tonic-gate */ 70*7c478bd9Sstevel@tonic-gate typedef struct { 71*7c478bd9Sstevel@tonic-gate Rt_map *b_caller; /* caller (originator) of a binding */ 72*7c478bd9Sstevel@tonic-gate Rt_map *b_depend; /* dependency (destination) of a */ 73*7c478bd9Sstevel@tonic-gate /* binding */ 74*7c478bd9Sstevel@tonic-gate uint_t b_flags; /* relationship of caller to the */ 75*7c478bd9Sstevel@tonic-gate /* dependency */ 76*7c478bd9Sstevel@tonic-gate } Bnd_desc; 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate #define BND_NEEDED 0x0001 /* caller NEEDED the dependency */ 79*7c478bd9Sstevel@tonic-gate #define BND_REFER 0x0002 /* caller relocation references the */ 80*7c478bd9Sstevel@tonic-gate /* dependency */ 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate /* 83*7c478bd9Sstevel@tonic-gate * Private structure for communication between rtld_db and rtld. 84*7c478bd9Sstevel@tonic-gate * 85*7c478bd9Sstevel@tonic-gate * We must bump the version number whenever a update in one of 86*7c478bd9Sstevel@tonic-gate * the structures/fields that rtld_db reads is updated. This hopefully 87*7c478bd9Sstevel@tonic-gate * permits rtld_db implementations of the future recognize corefiles 88*7c478bd9Sstevel@tonic-gate * produced on older system and deal accordingly. 89*7c478bd9Sstevel@tonic-gate * 90*7c478bd9Sstevel@tonic-gate * As of version 'RTLD_DB_VERSION <= 2' the following fields 91*7c478bd9Sstevel@tonic-gate * were valid for core file examination (basically the public 92*7c478bd9Sstevel@tonic-gate * Link_map): 93*7c478bd9Sstevel@tonic-gate * 94*7c478bd9Sstevel@tonic-gate * ADDR() 95*7c478bd9Sstevel@tonic-gate * NAME() 96*7c478bd9Sstevel@tonic-gate * DYN() 97*7c478bd9Sstevel@tonic-gate * NEXT() 98*7c478bd9Sstevel@tonic-gate * PREV() 99*7c478bd9Sstevel@tonic-gate * 100*7c478bd9Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION3 101*7c478bd9Sstevel@tonic-gate * 102*7c478bd9Sstevel@tonic-gate * PATHNAME() 103*7c478bd9Sstevel@tonic-gate * PADSTART() 104*7c478bd9Sstevel@tonic-gate * PADIMLEN() 105*7c478bd9Sstevel@tonic-gate * MSIZE() 106*7c478bd9Sstevel@tonic-gate * FLAGS() 107*7c478bd9Sstevel@tonic-gate * FLAGS1() 108*7c478bd9Sstevel@tonic-gate * 109*7c478bd9Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION4 110*7c478bd9Sstevel@tonic-gate * 111*7c478bd9Sstevel@tonic-gate * TLSMODID() 112*7c478bd9Sstevel@tonic-gate * 113*7c478bd9Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION5 114*7c478bd9Sstevel@tonic-gate * 115*7c478bd9Sstevel@tonic-gate * Added rtld_flags & FLG_RT_RELOCED to stable flags range 116*7c478bd9Sstevel@tonic-gate * 117*7c478bd9Sstevel@tonic-gate */ 118*7c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION1 1 /* base version level - used for core */ 119*7c478bd9Sstevel@tonic-gate /* file examination */ 120*7c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION2 2 /* minor revision - not relavant for */ 121*7c478bd9Sstevel@tonic-gate /* core files */ 122*7c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION3 3 123*7c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION4 4 124*7c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION5 5 125*7c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION R_RTLDDB_VERSION5 /* current version */ 126*7c478bd9Sstevel@tonic-gate 127*7c478bd9Sstevel@tonic-gate typedef struct rtld_db_priv { 128*7c478bd9Sstevel@tonic-gate struct r_debug rtd_rdebug; /* original r_debug structure */ 129*7c478bd9Sstevel@tonic-gate Word rtd_version; /* version no. */ 130*7c478bd9Sstevel@tonic-gate size_t rtd_objpad; /* padding around mmap()ed objects */ 131*7c478bd9Sstevel@tonic-gate List * rtd_dynlmlst; /* pointer to Dynlm_list */ 132*7c478bd9Sstevel@tonic-gate } Rtld_db_priv; 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 135*7c478bd9Sstevel@tonic-gate typedef struct rtld_db_priv32 { 136*7c478bd9Sstevel@tonic-gate struct r_debug32 rtd_rdebug; /* original r_debug structure */ 137*7c478bd9Sstevel@tonic-gate Elf32_Word rtd_version; /* version no. */ 138*7c478bd9Sstevel@tonic-gate Elf32_Word rtd_objpad; /* padding around mmap()ed objects */ 139*7c478bd9Sstevel@tonic-gate Elf32_Addr rtd_dynlmlst; /* pointer to Dynlm_list */ 140*7c478bd9Sstevel@tonic-gate } Rtld_db_priv32; 141*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate /* 145*7c478bd9Sstevel@tonic-gate * Link map list definition. Link-maps are used to describe each loaded object. 146*7c478bd9Sstevel@tonic-gate * Lists of these link-maps describe the various namespaces within a process. 147*7c478bd9Sstevel@tonic-gate * The process executable and its dependencies are maintained on the lml_main 148*7c478bd9Sstevel@tonic-gate * list. The runtime linker, and its dependencies are maintained on the 149*7c478bd9Sstevel@tonic-gate * lml_rtld list. Additional lists can be created (see dlmopen()) for such 150*7c478bd9Sstevel@tonic-gate * things as auditors and their dependencies. 151*7c478bd9Sstevel@tonic-gate * 152*7c478bd9Sstevel@tonic-gate * Each link-map list maintains an Alist of one, or more, linked lists of 153*7c478bd9Sstevel@tonic-gate * link-maps. For backward compatibility, the lm_head/lm_tail elements are 154*7c478bd9Sstevel@tonic-gate * initialized to the first linked-list of link-maps: 155*7c478bd9Sstevel@tonic-gate * 156*7c478bd9Sstevel@tonic-gate * Lm_list 157*7c478bd9Sstevel@tonic-gate * ---------- 158*7c478bd9Sstevel@tonic-gate * | lm_tail | ------------------------------------ 159*7c478bd9Sstevel@tonic-gate * | lm_head | -------------------- | 160*7c478bd9Sstevel@tonic-gate * | | | Rt_map | Rt_map 161*7c478bd9Sstevel@tonic-gate * | | | ------ | ------ 162*7c478bd9Sstevel@tonic-gate * | | Alist --> | | |--> | | 163*7c478bd9Sstevel@tonic-gate * | | --------- | | | -- | | 164*7c478bd9Sstevel@tonic-gate * | lm_lists | ----> | | | | | --> | | 165*7c478bd9Sstevel@tonic-gate * | | |---------| | | | | | | 166*7c478bd9Sstevel@tonic-gate * | | | lc_head | -- ------ | ------ 167*7c478bd9Sstevel@tonic-gate * | | | lc_tail | ------------------ 168*7c478bd9Sstevel@tonic-gate * | | |---------| 169*7c478bd9Sstevel@tonic-gate * | lc_head | 170*7c478bd9Sstevel@tonic-gate * | lc_tail | 171*7c478bd9Sstevel@tonic-gate * |---------| 172*7c478bd9Sstevel@tonic-gate * 173*7c478bd9Sstevel@tonic-gate * Multiple link-map lists exist to support the addition of lazy loaded 174*7c478bd9Sstevel@tonic-gate * families, filtee families, and dlopen() families. The intent of these 175*7c478bd9Sstevel@tonic-gate * lists is to insure that a family of objects that are to be loaded are 176*7c478bd9Sstevel@tonic-gate * fully relocatable, and hence usable, before they become part of the main 177*7c478bd9Sstevel@tonic-gate * (al_data[0]) link-map control list. This main link-map control list is 178*7c478bd9Sstevel@tonic-gate * the only list in existence when control is transferred to user code. 179*7c478bd9Sstevel@tonic-gate * 180*7c478bd9Sstevel@tonic-gate * During process initialization, the dynamic executable and its non-lazy 181*7c478bd9Sstevel@tonic-gate * dependencies are maintained on al_data[0]. If a new object is loaded, then 182*7c478bd9Sstevel@tonic-gate * this object is added to the next available control list [1], typically 183*7c478bd9Sstevel@tonic-gate * al_data[1]. Any dependencies of this object that have not already been 184*7c478bd9Sstevel@tonic-gate * loaded are added to the same control list. Once all of the objects on the 185*7c478bd9Sstevel@tonic-gate * new control list have been successfully relocated, the objects are moved from 186*7c478bd9Sstevel@tonic-gate * the new control list to the highest control list to which objects of the new 187*7c478bd9Sstevel@tonic-gate * control list bound to, typically al_data[1] to al_data[0]. 188*7c478bd9Sstevel@tonic-gate * 189*7c478bd9Sstevel@tonic-gate * Each loading scenario can be broken down as follows: 190*7c478bd9Sstevel@tonic-gate * 191*7c478bd9Sstevel@tonic-gate * setup() - only the initial link-map control list is used: 192*7c478bd9Sstevel@tonic-gate * i. create al_data[0] 193*7c478bd9Sstevel@tonic-gate * ii. add new link-map for main on al_data[0] 194*7c478bd9Sstevel@tonic-gate * iii. analyze al_data[0] to add all non-lazy dependencies 195*7c478bd9Sstevel@tonic-gate * iv. relocate al_data[0] dependencies. 196*7c478bd9Sstevel@tonic-gate * 197*7c478bd9Sstevel@tonic-gate * dlopen() - the initiator can only be the initial link-map control list: 198*7c478bd9Sstevel@tonic-gate * i. create al_data[1] from caller al_data[0] 199*7c478bd9Sstevel@tonic-gate * ii. add new link-map for the dlopen'ed object on al_data[1] 200*7c478bd9Sstevel@tonic-gate * iii. analyze al_data[1] to add all non-lazy dependencies 201*7c478bd9Sstevel@tonic-gate * iv. relocate al_data[1] dependencies, and move to al_data[0]. 202*7c478bd9Sstevel@tonic-gate * 203*7c478bd9Sstevel@tonic-gate * filtee and lazy loading processing - the initiator can be any link-map 204*7c478bd9Sstevel@tonic-gate * control list that is being relocated: 205*7c478bd9Sstevel@tonic-gate * i. create al_data[y] from caller al_data[x] 206*7c478bd9Sstevel@tonic-gate * ii. add new link-map for the new object on al_data[y] 207*7c478bd9Sstevel@tonic-gate * iii. analyze al_data[y] to add all non-lazy dependencies 208*7c478bd9Sstevel@tonic-gate * iv. relocate al_data[y] dependencies, and move to al_data[x]. 209*7c478bd9Sstevel@tonic-gate * 210*7c478bd9Sstevel@tonic-gate * This Alist therefore maintains a stack of link-map control lists. The newest 211*7c478bd9Sstevel@tonic-gate * link-map control list can locate symbols within any of the former lists, 212*7c478bd9Sstevel@tonic-gate * however, control is not passed to a former list until the newest lists 213*7c478bd9Sstevel@tonic-gate * processing is complete. Thus, objects can't bind to new objects until they 214*7c478bd9Sstevel@tonic-gate * have been fully analyzed and relocated. 215*7c478bd9Sstevel@tonic-gate * 216*7c478bd9Sstevel@tonic-gate * [1] Note, additional link-map control list creation occurs after the head 217*7c478bd9Sstevel@tonic-gate * link-map object (typically the dynamic executable) has been relocated. This 218*7c478bd9Sstevel@tonic-gate * staging is required to satisfy the binding requirements of copy relocations. 219*7c478bd9Sstevel@tonic-gate * Copy relocations, effectively, transfer the bindings of the copied data 220*7c478bd9Sstevel@tonic-gate * (say _iob in libc.so.1) to the copy location (_iob in the application). 221*7c478bd9Sstevel@tonic-gate * Thus an object that might bind to the original copy data must be redirected 222*7c478bd9Sstevel@tonic-gate * to the copy reference. As the knowledge of a copy relocation having taken 223*7c478bd9Sstevel@tonic-gate * place is only known after relocating the application, link-map control list 224*7c478bd9Sstevel@tonic-gate * additions are suspended until after this relocation has completed. 225*7c478bd9Sstevel@tonic-gate */ 226*7c478bd9Sstevel@tonic-gate typedef struct { 227*7c478bd9Sstevel@tonic-gate Rt_map *lc_head; 228*7c478bd9Sstevel@tonic-gate Rt_map *lc_tail; 229*7c478bd9Sstevel@tonic-gate Alist *lc_now; /* pending promoted bind-now objects */ 230*7c478bd9Sstevel@tonic-gate uint_t lc_flags; 231*7c478bd9Sstevel@tonic-gate } Lm_cntl; 232*7c478bd9Sstevel@tonic-gate 233*7c478bd9Sstevel@tonic-gate #define LMC_FLG_ANALYZING 0x01 /* control list is being analyzed */ 234*7c478bd9Sstevel@tonic-gate #define LMC_FLG_RELOCATING 0x02 /* control list is being relocated */ 235*7c478bd9Sstevel@tonic-gate #define LMC_FLG_REANALYZE 0x04 /* repeat analysis (established when */ 236*7c478bd9Sstevel@tonic-gate /* interposers are added */ 237*7c478bd9Sstevel@tonic-gate 238*7c478bd9Sstevel@tonic-gate typedef struct { 239*7c478bd9Sstevel@tonic-gate /* 240*7c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 241*7c478bd9Sstevel@tonic-gate */ 242*7c478bd9Sstevel@tonic-gate Rt_map *lm_head; /* linked list pointers to active */ 243*7c478bd9Sstevel@tonic-gate Rt_map *lm_tail; /* link-map list */ 244*7c478bd9Sstevel@tonic-gate Alist *lm_handle; /* not used by rtld_db - but spacing */ 245*7c478bd9Sstevel@tonic-gate /* is required for flags */ 246*7c478bd9Sstevel@tonic-gate Word lm_flags; 247*7c478bd9Sstevel@tonic-gate /* 248*7c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 249*7c478bd9Sstevel@tonic-gate */ 250*7c478bd9Sstevel@tonic-gate int (*lm_peh)(); /* atexit() preexec_exit_handlers */ 251*7c478bd9Sstevel@tonic-gate Rt_map *lm_peh_lmp; /* and object that contributed them */ 252*7c478bd9Sstevel@tonic-gate Rt_map *lm_info_lmp; /* the first object with rtld_info */ 253*7c478bd9Sstevel@tonic-gate Alist *lm_rtldinfo; /* list of RTLDINFO tables */ 254*7c478bd9Sstevel@tonic-gate Audit_list *lm_alp; /* audit list descripter */ 255*7c478bd9Sstevel@tonic-gate avl_tree_t *lm_fpavl; /* avl tree of objects loaded */ 256*7c478bd9Sstevel@tonic-gate Alist *lm_lists; /* active and pending link-map lists */ 257*7c478bd9Sstevel@tonic-gate Word lm_tflags; /* transferable flags */ 258*7c478bd9Sstevel@tonic-gate int lm_obj; /* total number of objs on link-map */ 259*7c478bd9Sstevel@tonic-gate int lm_init; /* new obj since last init processing */ 260*7c478bd9Sstevel@tonic-gate int lm_lazy; /* obj with pending lazy dependencies */ 261*7c478bd9Sstevel@tonic-gate } Lm_list; 262*7c478bd9Sstevel@tonic-gate 263*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 264*7c478bd9Sstevel@tonic-gate typedef struct { 265*7c478bd9Sstevel@tonic-gate /* 266*7c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 267*7c478bd9Sstevel@tonic-gate */ 268*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_head; 269*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_tail; 270*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_handle; 271*7c478bd9Sstevel@tonic-gate Elf32_Word lm_flags; 272*7c478bd9Sstevel@tonic-gate /* 273*7c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 274*7c478bd9Sstevel@tonic-gate */ 275*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_peh; 276*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_peh_lmp; 277*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_info_lmp; 278*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_alp; 279*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_fpavl; 280*7c478bd9Sstevel@tonic-gate Elf32_Addr lm_lists; 281*7c478bd9Sstevel@tonic-gate Elf32_Word lm_tflags; 282*7c478bd9Sstevel@tonic-gate int lm_obj; 283*7c478bd9Sstevel@tonic-gate int lm_init; 284*7c478bd9Sstevel@tonic-gate int lm_lazy; 285*7c478bd9Sstevel@tonic-gate } Lm_list32; 286*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 287*7c478bd9Sstevel@tonic-gate 288*7c478bd9Sstevel@tonic-gate /* 289*7c478bd9Sstevel@tonic-gate * Possible Link_map list flags (Lm_list.lm_flags) 290*7c478bd9Sstevel@tonic-gate */ 291*7c478bd9Sstevel@tonic-gate /* 292*7c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 293*7c478bd9Sstevel@tonic-gate */ 294*7c478bd9Sstevel@tonic-gate #define LML_FLG_BASELM 0x00000001 /* primary link-map */ 295*7c478bd9Sstevel@tonic-gate #define LML_FLG_RTLDLM 0x00000002 /* rtld link-map */ 296*7c478bd9Sstevel@tonic-gate /* 297*7c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 298*7c478bd9Sstevel@tonic-gate */ 299*7c478bd9Sstevel@tonic-gate #define LML_FLG_NOAUDIT 0x00000004 /* symbol auditing disabled */ 300*7c478bd9Sstevel@tonic-gate #define LML_FLG_PLTREL 0x00000008 /* deferred plt relocation */ 301*7c478bd9Sstevel@tonic-gate /* initialization */ 302*7c478bd9Sstevel@tonic-gate /* (ld.so.1 only) */ 303*7c478bd9Sstevel@tonic-gate #define LML_FLG_HOLDLOCK 0x00000010 /* hold the rtld mutex lock */ 304*7c478bd9Sstevel@tonic-gate #define LML_FLG_ENVIRON 0x00000020 /* environ var initialized */ 305*7c478bd9Sstevel@tonic-gate #define LML_FLG_INTRPOSE 0x00000040 /* interposing objs on list */ 306*7c478bd9Sstevel@tonic-gate #define LML_FLG_LOCAUDIT 0x00000080 /* local auditors exists for */ 307*7c478bd9Sstevel@tonic-gate /* this link-map list */ 308*7c478bd9Sstevel@tonic-gate #define LML_FLG_LOADAVAIL 0x00000100 /* load anything available */ 309*7c478bd9Sstevel@tonic-gate #define LML_FLG_IGNRELERR 0x00000200 /* ignore relocation errors - */ 310*7c478bd9Sstevel@tonic-gate /* internal for crle(1) */ 311*7c478bd9Sstevel@tonic-gate #define LML_FLG_DBNOTIF 0x00000400 /* binding activity going on */ 312*7c478bd9Sstevel@tonic-gate #define LML_FLG_BNDUNINIT 0x00000800 /* binding to a existing */ 313*7c478bd9Sstevel@tonic-gate /* uninit'd object */ 314*7c478bd9Sstevel@tonic-gate #define LML_FLG_STARTREL 0x00001000 /* relocation started */ 315*7c478bd9Sstevel@tonic-gate 316*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_LDDSTUB 0x00100000 /* identify lddstub */ 317*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_ENABLE 0x00200000 /* tracing enabled (ldd) */ 318*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_WARN 0x00400000 /* print warnings for undefs */ 319*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_VERBOSE 0x00800000 /* verbose (versioning) trace */ 320*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_SEARCH 0x01000000 /* trace search paths */ 321*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_UNREF 0x02000000 /* trace unreferenced */ 322*7c478bd9Sstevel@tonic-gate /* dependencies */ 323*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_UNUSED 0x04000000 /* trace unused dependencies */ 324*7c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_INIT 0x08000000 /* print .init order */ 325*7c478bd9Sstevel@tonic-gate 326*7c478bd9Sstevel@tonic-gate #define LML_MSK_TRC 0xfff00000 /* tracing mask */ 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate /* 329*7c478bd9Sstevel@tonic-gate * Possible Link_map transferable flags (Lm_list.lm_tflags), i.e., link-map 330*7c478bd9Sstevel@tonic-gate * list flags that can be propagated to any new link-map list created. 331*7c478bd9Sstevel@tonic-gate */ 332*7c478bd9Sstevel@tonic-gate #define LML_TFLG_NOLAZYLD 0x00000001 /* lazy loading disabled */ 333*7c478bd9Sstevel@tonic-gate #define LML_TFLG_NODIRECT 0x00000002 /* direct bindings disabled */ 334*7c478bd9Sstevel@tonic-gate 335*7c478bd9Sstevel@tonic-gate #define LML_TFLG_LOADFLTR 0x00000008 /* trigger filtee loading */ 336*7c478bd9Sstevel@tonic-gate 337*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_PREINIT 0x00100000 /* preinit (audit) exists */ 338*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJSEARCH 0x00200000 /* objsearch (audit) exists */ 339*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJOPEN 0x00400000 /* objopen (audit) exists */ 340*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJFILTER 0x00800000 /* objfilter (audit) exists */ 341*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJCLOSE 0x01000000 /* objclose (audit) exists */ 342*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_SYMBIND 0x02000000 /* symbind (audit) exists */ 343*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_PLTENTER 0x04000000 /* pltenter (audit) exists */ 344*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_PLTEXIT 0x08000000 /* pltexit (audit) exists */ 345*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_ACTIVITY 0x10000000 /* activity (audit) exists */ 346*7c478bd9Sstevel@tonic-gate 347*7c478bd9Sstevel@tonic-gate /* 348*7c478bd9Sstevel@tonic-gate * NOTE: Audit flags have duplicated FLAGS1() values. If more audit flags are 349*7c478bd9Sstevel@tonic-gate * added, update the FLAGS1() reservation FL1_AUD_RS_STR to FL1_AUD_RS_END 350*7c478bd9Sstevel@tonic-gate * defined later. 351*7c478bd9Sstevel@tonic-gate */ 352*7c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_MASK 0xfff00000 /* audit interfaces mask */ 353*7c478bd9Sstevel@tonic-gate 354*7c478bd9Sstevel@tonic-gate 355*7c478bd9Sstevel@tonic-gate /* 356*7c478bd9Sstevel@tonic-gate * Information for dlopen(), dlsym(), and dlclose() on libraries linked by rtld. 357*7c478bd9Sstevel@tonic-gate * Each shared object referred from a dlopen call has an associated group 358*7c478bd9Sstevel@tonic-gate * handle structure returned that describes a group of one or more objects. 359*7c478bd9Sstevel@tonic-gate */ 360*7c478bd9Sstevel@tonic-gate typedef struct { 361*7c478bd9Sstevel@tonic-gate Alist * gh_depends; /* handle dependency list */ 362*7c478bd9Sstevel@tonic-gate Rt_map * gh_owner; /* handle owner and the link-map */ 363*7c478bd9Sstevel@tonic-gate uint_t gh_refcnt; /* handle reference count */ 364*7c478bd9Sstevel@tonic-gate uint_t gh_flags; /* handle flags */ 365*7c478bd9Sstevel@tonic-gate } Grp_hdl; 366*7c478bd9Sstevel@tonic-gate 367*7c478bd9Sstevel@tonic-gate #define GPH_ZERO 0x0001 /* special handle for dlopen(0) */ 368*7c478bd9Sstevel@tonic-gate #define GPH_LDSO 0x0002 /* special handle for ld.so.1 */ 369*7c478bd9Sstevel@tonic-gate #define GPH_FIRST 0x0004 /* dlsym() can only use originating */ 370*7c478bd9Sstevel@tonic-gate /* dependency */ 371*7c478bd9Sstevel@tonic-gate #define GPH_PARENT 0x0008 /* assign caller as a parent */ 372*7c478bd9Sstevel@tonic-gate #define GPH_FILTEE 0x0010 /* handle used to specify a filtee */ 373*7c478bd9Sstevel@tonic-gate #define GPH_INITIAL 0x0020 /* handle is initialized */ 374*7c478bd9Sstevel@tonic-gate #define GPH_STICKY 0x0040 /* handle is unreferenced, but should */ 375*7c478bd9Sstevel@tonic-gate /* not trigger object removal */ 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate /* 378*7c478bd9Sstevel@tonic-gate * A group descriptor. A group handle (Grp_hdl) refers to a group of objects, 379*7c478bd9Sstevel@tonic-gate * each object, and its relationship to the handle, is maintained within a 380*7c478bd9Sstevel@tonic-gate * group descriptor. 381*7c478bd9Sstevel@tonic-gate */ 382*7c478bd9Sstevel@tonic-gate typedef struct { 383*7c478bd9Sstevel@tonic-gate Rt_map * gd_depend; /* dependency */ 384*7c478bd9Sstevel@tonic-gate uint_t gd_flags; /* dependency flags */ 385*7c478bd9Sstevel@tonic-gate } Grp_desc; 386*7c478bd9Sstevel@tonic-gate 387*7c478bd9Sstevel@tonic-gate #define GPD_AVAIL 0x0001 /* dependency available to dlsym() */ 388*7c478bd9Sstevel@tonic-gate #define GPD_ADDEPS 0x0002 /* dependencies of this dependency */ 389*7c478bd9Sstevel@tonic-gate /* should be added to handle */ 390*7c478bd9Sstevel@tonic-gate #define GPD_PARENT 0x0004 /* dependency is a parent */ 391*7c478bd9Sstevel@tonic-gate #define GPD_FILTER 0x0008 /* dependency is our filter */ 392*7c478bd9Sstevel@tonic-gate #define GPD_REMOVE 0x1000 /* descriptor is a candidate for */ 393*7c478bd9Sstevel@tonic-gate /* removal from the group */ 394*7c478bd9Sstevel@tonic-gate 395*7c478bd9Sstevel@tonic-gate /* 396*7c478bd9Sstevel@tonic-gate * Define threading structures. For compatibility with libthread (T1_VERSION 1 397*7c478bd9Sstevel@tonic-gate * and TI_VERSION 2) our locking structure is sufficient to hold a mutex or a 398*7c478bd9Sstevel@tonic-gate * readers/writers lock. 399*7c478bd9Sstevel@tonic-gate */ 400*7c478bd9Sstevel@tonic-gate typedef struct { 401*7c478bd9Sstevel@tonic-gate union { 402*7c478bd9Sstevel@tonic-gate mutex_t l_mutex; 403*7c478bd9Sstevel@tonic-gate rwlock_t l_rwlock; 404*7c478bd9Sstevel@tonic-gate } u; 405*7c478bd9Sstevel@tonic-gate } Rt_lock; 406*7c478bd9Sstevel@tonic-gate 407*7c478bd9Sstevel@tonic-gate typedef cond_t Rt_cond; 408*7c478bd9Sstevel@tonic-gate 409*7c478bd9Sstevel@tonic-gate /* 410*7c478bd9Sstevel@tonic-gate * Define a dynamic section information descriptor. This parallels the entries 411*7c478bd9Sstevel@tonic-gate * in the .dynamic section and holds auxiliary information to implement lazy 412*7c478bd9Sstevel@tonic-gate * loading and filtee processing. 413*7c478bd9Sstevel@tonic-gate */ 414*7c478bd9Sstevel@tonic-gate typedef struct { 415*7c478bd9Sstevel@tonic-gate uint_t di_flags; 416*7c478bd9Sstevel@tonic-gate void *di_info; 417*7c478bd9Sstevel@tonic-gate } Dyninfo; 418*7c478bd9Sstevel@tonic-gate 419*7c478bd9Sstevel@tonic-gate #define FLG_DI_STDFLTR 0x00001 /* .dynamic entry for DT_FILTER */ 420*7c478bd9Sstevel@tonic-gate #define FLG_DI_AUXFLTR 0x00002 /* .dynamic entry for DT_AUXILIARY */ 421*7c478bd9Sstevel@tonic-gate #define FLG_DI_SYMFLTR 0x00004 /* .dynamic entry for DT_SYMFILTER */ 422*7c478bd9Sstevel@tonic-gate /* and DT_SYMAUXILIARY */ 423*7c478bd9Sstevel@tonic-gate #define MSK_DI_FILTER 0x0000f /* mask for all filter possibilities */ 424*7c478bd9Sstevel@tonic-gate 425*7c478bd9Sstevel@tonic-gate #define FLG_DI_NEEDED 0x00010 /* entry represents a dependency */ 426*7c478bd9Sstevel@tonic-gate #define FLG_DI_GROUP 0x00020 /* open dependency as a group */ 427*7c478bd9Sstevel@tonic-gate #define FLG_DI_PROCESSD 0x00040 /* entry has been processed */ 428*7c478bd9Sstevel@tonic-gate 429*7c478bd9Sstevel@tonic-gate /* 430*7c478bd9Sstevel@tonic-gate * Data Structure to track AVL tree for pathnames of objects 431*7c478bd9Sstevel@tonic-gate * loaded into memory 432*7c478bd9Sstevel@tonic-gate */ 433*7c478bd9Sstevel@tonic-gate typedef struct { 434*7c478bd9Sstevel@tonic-gate const char *fpn_name; /* object name */ 435*7c478bd9Sstevel@tonic-gate Rt_map *fpn_lmp; /* object link-map */ 436*7c478bd9Sstevel@tonic-gate avl_node_t fpn_avl; /* avl book-keeping (see SGSOFFSETOF) */ 437*7c478bd9Sstevel@tonic-gate uint_t fpn_hash; /* object name hash value */ 438*7c478bd9Sstevel@tonic-gate } FullpathNode; 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate /* 441*7c478bd9Sstevel@tonic-gate * Define a mapping structure, which is maintained to describe each mapping 442*7c478bd9Sstevel@tonic-gate * of an object, ie. the text segment, data segment, bss segment, etc. 443*7c478bd9Sstevel@tonic-gate */ 444*7c478bd9Sstevel@tonic-gate typedef struct { 445*7c478bd9Sstevel@tonic-gate caddr_t m_vaddr; /* mapping address */ 446*7c478bd9Sstevel@tonic-gate size_t m_fsize; /* backing file size */ 447*7c478bd9Sstevel@tonic-gate size_t m_msize; /* mapping size */ 448*7c478bd9Sstevel@tonic-gate int m_perm; /* mapping permissions */ 449*7c478bd9Sstevel@tonic-gate } Mmap; 450*7c478bd9Sstevel@tonic-gate 451*7c478bd9Sstevel@tonic-gate /* 452*7c478bd9Sstevel@tonic-gate * Link-map definition. 453*7c478bd9Sstevel@tonic-gate */ 454*7c478bd9Sstevel@tonic-gate struct rt_map { 455*7c478bd9Sstevel@tonic-gate /* 456*7c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 457*7c478bd9Sstevel@tonic-gate */ 458*7c478bd9Sstevel@tonic-gate Link_map rt_public; /* public data */ 459*7c478bd9Sstevel@tonic-gate char *rt_pathname; /* full pathname of loaded object */ 460*7c478bd9Sstevel@tonic-gate ulong_t rt_padstart; /* start of image (including padding) */ 461*7c478bd9Sstevel@tonic-gate ulong_t rt_padimlen; /* size of image (including padding */ 462*7c478bd9Sstevel@tonic-gate ulong_t rt_msize; /* total memory mapped */ 463*7c478bd9Sstevel@tonic-gate uint_t rt_flags; /* state flags, see FLG below */ 464*7c478bd9Sstevel@tonic-gate uint_t rt_flags1; /* state flags1, see FL1 below */ 465*7c478bd9Sstevel@tonic-gate ulong_t rt_tlsmodid; /* TLS module id */ 466*7c478bd9Sstevel@tonic-gate /* 467*7c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 468*7c478bd9Sstevel@tonic-gate */ 469*7c478bd9Sstevel@tonic-gate Alist *rt_alias; /* list of linked file names */ 470*7c478bd9Sstevel@tonic-gate Alist *rt_fpnode; /* list of FullpathNode AVL nodes */ 471*7c478bd9Sstevel@tonic-gate void (*rt_init)(); /* address of _init */ 472*7c478bd9Sstevel@tonic-gate void (*rt_fini)(); /* address of _fini */ 473*7c478bd9Sstevel@tonic-gate char *rt_runpath; /* LD_RUN_PATH and its equivalent */ 474*7c478bd9Sstevel@tonic-gate Pnode *rt_runlist; /* Pnode structures */ 475*7c478bd9Sstevel@tonic-gate Alist *rt_depends; /* list of dependencies */ 476*7c478bd9Sstevel@tonic-gate Alist *rt_callers; /* list of callers */ 477*7c478bd9Sstevel@tonic-gate Alist *rt_handles; /* dlopen handles */ 478*7c478bd9Sstevel@tonic-gate Alist *rt_groups; /* groups we're a member of */ 479*7c478bd9Sstevel@tonic-gate ulong_t rt_etext; /* etext address */ 480*7c478bd9Sstevel@tonic-gate struct fct *rt_fct; /* file class table for this object */ 481*7c478bd9Sstevel@tonic-gate Sym *(*rt_symintp)(); /* link map symbol interpreter */ 482*7c478bd9Sstevel@tonic-gate void *rt_priv; /* private data, object type specific */ 483*7c478bd9Sstevel@tonic-gate Lm_list *rt_list; /* link map list we belong to */ 484*7c478bd9Sstevel@tonic-gate uint_t rt_objfltrndx; /* object filtees .dynamic index */ 485*7c478bd9Sstevel@tonic-gate uint_t rt_symsfltrcnt; /* number of standard symbol filtees */ 486*7c478bd9Sstevel@tonic-gate uint_t rt_symafltrcnt; /* number of auxiliary symbol filtees */ 487*7c478bd9Sstevel@tonic-gate int rt_mode; /* usage mode, see RTLD mode flags */ 488*7c478bd9Sstevel@tonic-gate uint_t rt_sortval; /* temporary buffer to traverse graph */ 489*7c478bd9Sstevel@tonic-gate uint_t rt_cycgroup; /* cyclic group */ 490*7c478bd9Sstevel@tonic-gate dev_t rt_stdev; /* device id and inode number for .so */ 491*7c478bd9Sstevel@tonic-gate ino_t rt_stino; /* multiple inclusion checks */ 492*7c478bd9Sstevel@tonic-gate char *rt_origname; /* original pathname of loaded object */ 493*7c478bd9Sstevel@tonic-gate size_t rt_dirsz; /* and its size */ 494*7c478bd9Sstevel@tonic-gate Alist *rt_copy; /* list of copy relocations */ 495*7c478bd9Sstevel@tonic-gate Audit_desc *rt_auditors; /* audit descriptor array */ 496*7c478bd9Sstevel@tonic-gate Audit_info *rt_audinfo; /* audit information descriptor */ 497*7c478bd9Sstevel@tonic-gate Syminfo *rt_syminfo; /* elf .syminfo section - here */ 498*7c478bd9Sstevel@tonic-gate /* because it is checked in */ 499*7c478bd9Sstevel@tonic-gate /* common code */ 500*7c478bd9Sstevel@tonic-gate Addr *rt_initarray; /* .initarray table */ 501*7c478bd9Sstevel@tonic-gate Addr *rt_finiarray; /* .finiarray table */ 502*7c478bd9Sstevel@tonic-gate Addr *rt_preinitarray; /* .preinitarray table */ 503*7c478bd9Sstevel@tonic-gate Mmap *rt_mmaps; /* array of mapping information */ 504*7c478bd9Sstevel@tonic-gate uint_t rt_mmapcnt; /* and associated number */ 505*7c478bd9Sstevel@tonic-gate uint_t rt_initarraysz; /* size of .initarray table */ 506*7c478bd9Sstevel@tonic-gate uint_t rt_finiarraysz; /* size of .finiarray table */ 507*7c478bd9Sstevel@tonic-gate uint_t rt_preinitarraysz; /* size of .preinitarray table */ 508*7c478bd9Sstevel@tonic-gate Dyninfo *rt_dyninfo; /* .dynamic information descriptors */ 509*7c478bd9Sstevel@tonic-gate uint_t rt_dyninfocnt; /* count of dyninfo entries */ 510*7c478bd9Sstevel@tonic-gate uint_t rt_relacount; /* no. of RELATIVE relocations */ 511*7c478bd9Sstevel@tonic-gate uint_t rt_idx; /* hold index within linkmap list */ 512*7c478bd9Sstevel@tonic-gate uint_t rt_lazy; /* lazy dependencies pending */ 513*7c478bd9Sstevel@tonic-gate Rt_cond *rt_condvar; /* variables */ 514*7c478bd9Sstevel@tonic-gate Xword rt_hwcap; /* hardware capabilities */ 515*7c478bd9Sstevel@tonic-gate Xword rt_sfcap; /* software capabilities */ 516*7c478bd9Sstevel@tonic-gate thread_t rt_threadid; /* thread init/fini synchronization */ 517*7c478bd9Sstevel@tonic-gate uint_t rt_cntl; /* link-map control list we belong to */ 518*7c478bd9Sstevel@tonic-gate }; 519*7c478bd9Sstevel@tonic-gate 520*7c478bd9Sstevel@tonic-gate 521*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 522*7c478bd9Sstevel@tonic-gate /* 523*7c478bd9Sstevel@tonic-gate * Structure to allow 64-bit rtld_db to read 32-bit processes out of procfs. 524*7c478bd9Sstevel@tonic-gate */ 525*7c478bd9Sstevel@tonic-gate typedef struct rt_map32 { 526*7c478bd9Sstevel@tonic-gate /* 527*7c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 528*7c478bd9Sstevel@tonic-gate */ 529*7c478bd9Sstevel@tonic-gate Link_map32 rt_public; 530*7c478bd9Sstevel@tonic-gate uint32_t rt_pathname; 531*7c478bd9Sstevel@tonic-gate uint32_t rt_padstart; 532*7c478bd9Sstevel@tonic-gate uint32_t rt_padimlen; 533*7c478bd9Sstevel@tonic-gate uint32_t rt_msize; 534*7c478bd9Sstevel@tonic-gate uint32_t rt_flags; 535*7c478bd9Sstevel@tonic-gate uint32_t rt_flags1; 536*7c478bd9Sstevel@tonic-gate uint32_t rt_tlsmodid; 537*7c478bd9Sstevel@tonic-gate /* 538*7c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 539*7c478bd9Sstevel@tonic-gate */ 540*7c478bd9Sstevel@tonic-gate uint32_t rt_alias; 541*7c478bd9Sstevel@tonic-gate uint32_t rt_fpnode; 542*7c478bd9Sstevel@tonic-gate uint32_t rt_init; 543*7c478bd9Sstevel@tonic-gate uint32_t rt_fini; 544*7c478bd9Sstevel@tonic-gate uint32_t rt_runpath; 545*7c478bd9Sstevel@tonic-gate uint32_t rt_runlist; 546*7c478bd9Sstevel@tonic-gate uint32_t rt_depends; 547*7c478bd9Sstevel@tonic-gate uint32_t rt_callers; 548*7c478bd9Sstevel@tonic-gate uint32_t rt_handles; 549*7c478bd9Sstevel@tonic-gate uint32_t rt_groups; 550*7c478bd9Sstevel@tonic-gate uint32_t rt_etext; 551*7c478bd9Sstevel@tonic-gate uint32_t rt_fct; 552*7c478bd9Sstevel@tonic-gate uint32_t rt_symintp; 553*7c478bd9Sstevel@tonic-gate uint32_t rt_priv; 554*7c478bd9Sstevel@tonic-gate uint32_t rt_list; 555*7c478bd9Sstevel@tonic-gate uint32_t rt_objfltrndx; 556*7c478bd9Sstevel@tonic-gate uint32_t rt_symsfltrcnt; 557*7c478bd9Sstevel@tonic-gate uint32_t rt_symafltrcnt; 558*7c478bd9Sstevel@tonic-gate uint32_t rt_mode; 559*7c478bd9Sstevel@tonic-gate uint32_t rt_sortval; 560*7c478bd9Sstevel@tonic-gate uint32_t rt_cycgroup; 561*7c478bd9Sstevel@tonic-gate uint32_t rt_stdev; 562*7c478bd9Sstevel@tonic-gate uint32_t rt_stino; 563*7c478bd9Sstevel@tonic-gate uint32_t rt_origname; 564*7c478bd9Sstevel@tonic-gate uint32_t rt_dirsz; 565*7c478bd9Sstevel@tonic-gate uint32_t rt_copy; 566*7c478bd9Sstevel@tonic-gate uint32_t rt_auditors; 567*7c478bd9Sstevel@tonic-gate uint32_t rt_audinfo; 568*7c478bd9Sstevel@tonic-gate uint32_t rt_syminfo; 569*7c478bd9Sstevel@tonic-gate uint32_t rt_initarray; 570*7c478bd9Sstevel@tonic-gate uint32_t rt_finiarray; 571*7c478bd9Sstevel@tonic-gate uint32_t rt_preinitarray; 572*7c478bd9Sstevel@tonic-gate uint32_t rt_mmaps; 573*7c478bd9Sstevel@tonic-gate uint32_t rt_mmapcnt; 574*7c478bd9Sstevel@tonic-gate uint32_t rt_initarraysz; 575*7c478bd9Sstevel@tonic-gate uint32_t rt_finiarraysz; 576*7c478bd9Sstevel@tonic-gate uint32_t rt_preinitarraysz; 577*7c478bd9Sstevel@tonic-gate uint32_t rt_dyninfo; 578*7c478bd9Sstevel@tonic-gate uint32_t rt_dyninfocnt; 579*7c478bd9Sstevel@tonic-gate uint32_t rt_relacount; 580*7c478bd9Sstevel@tonic-gate uint32_t rt_idx; 581*7c478bd9Sstevel@tonic-gate uint32_t rt_lazy; 582*7c478bd9Sstevel@tonic-gate uint32_t rt_condvar; 583*7c478bd9Sstevel@tonic-gate uint32_t rt_hwcap; 584*7c478bd9Sstevel@tonic-gate uint32_t rt_sfcap; 585*7c478bd9Sstevel@tonic-gate uint32_t rt_threadid; 586*7c478bd9Sstevel@tonic-gate uint32_t rt_cntl; 587*7c478bd9Sstevel@tonic-gate } Rt_map32; 588*7c478bd9Sstevel@tonic-gate 589*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 590*7c478bd9Sstevel@tonic-gate 591*7c478bd9Sstevel@tonic-gate /* 592*7c478bd9Sstevel@tonic-gate * Link map state flags. 593*7c478bd9Sstevel@tonic-gate */ 594*7c478bd9Sstevel@tonic-gate /* 595*7c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 596*7c478bd9Sstevel@tonic-gate */ 597*7c478bd9Sstevel@tonic-gate #define FLG_RT_ISMAIN 0x00000001 /* object represents main executable */ 598*7c478bd9Sstevel@tonic-gate #define FLG_RT_IMGALLOC 0x00000002 /* image is allocated (not mmap'ed) */ 599*7c478bd9Sstevel@tonic-gate /* 600*7c478bd9Sstevel@tonic-gate * Available for r_debug version >= RTLD_DB_VERSION5 601*7c478bd9Sstevel@tonic-gate */ 602*7c478bd9Sstevel@tonic-gate #define FLG_RT_RELOCED 0x00000004 /* object has been relocated */ 603*7c478bd9Sstevel@tonic-gate /* 604*7c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 605*7c478bd9Sstevel@tonic-gate */ 606*7c478bd9Sstevel@tonic-gate #define FLG_RT_SETGROUP 0x00000008 /* group establishment required */ 607*7c478bd9Sstevel@tonic-gate #define FLG_RT_HWCAP 0x00000010 /* process $HWCAP expansion */ 608*7c478bd9Sstevel@tonic-gate #define FLG_RT_OBJECT 0x00000020 /* object processing (ie. .o's) */ 609*7c478bd9Sstevel@tonic-gate 610*7c478bd9Sstevel@tonic-gate #define FLG_RT_NODUMP 0x00000080 /* object can't be dldump(3x)'ed */ 611*7c478bd9Sstevel@tonic-gate #define FLG_RT_DELETE 0x00000100 /* object can be deleted */ 612*7c478bd9Sstevel@tonic-gate #define FLG_RT_ANALYZED 0x00000200 /* object has been analyzed */ 613*7c478bd9Sstevel@tonic-gate #define FLG_RT_INITDONE 0x00000400 /* objects .init has been completed */ 614*7c478bd9Sstevel@tonic-gate #define FLG_RT_TRANS 0x00000800 /* object is acting as a translator */ 615*7c478bd9Sstevel@tonic-gate #define FLG_RT_FIXED 0x00001000 /* image location is fixed */ 616*7c478bd9Sstevel@tonic-gate #define FLG_RT_PRELOAD 0x00002000 /* object was preloaded */ 617*7c478bd9Sstevel@tonic-gate #define FLG_RT_ALTER 0x00004000 /* alternative object used */ 618*7c478bd9Sstevel@tonic-gate #define FLG_RT_LOADFLTR 0x00008000 /* trigger filtee loading */ 619*7c478bd9Sstevel@tonic-gate #define FLG_RT_AUDIT 0x00010000 /* object is an auditor */ 620*7c478bd9Sstevel@tonic-gate #define FLG_RT_MODESET 0x00020000 /* MODE() has been initialized */ 621*7c478bd9Sstevel@tonic-gate #define FLG_RT_ANALZING 0x00040000 /* object is being analyzed */ 622*7c478bd9Sstevel@tonic-gate #define FLG_RT_INITFRST 0x00080000 /* execute .init first */ 623*7c478bd9Sstevel@tonic-gate #define FLG_RT_NOOPEN 0x00100000 /* dlopen() not allowed */ 624*7c478bd9Sstevel@tonic-gate #define FLG_RT_FINICLCT 0x00200000 /* fini has been collected (tsort) */ 625*7c478bd9Sstevel@tonic-gate #define FLG_RT_INITCALL 0x00400000 /* objects .init has been called */ 626*7c478bd9Sstevel@tonic-gate #define FLG_RT_INTRPOSE 0x00800000 /* object is an INTERPOSER */ 627*7c478bd9Sstevel@tonic-gate #define FLG_RT_DIRECT 0x01000000 /* object has DIRECT bindings enabled */ 628*7c478bd9Sstevel@tonic-gate #define FLG_RT_SUNWBSS 0x02000000 /* object with PT_SUNWBSS, not mapped */ 629*7c478bd9Sstevel@tonic-gate #define FLG_RT_MOVE 0x04000000 /* object needs move operation */ 630*7c478bd9Sstevel@tonic-gate #define FLG_RT_DLSYM 0x08000000 /* dlsym in progress on object */ 631*7c478bd9Sstevel@tonic-gate #define FLG_RT_REGSYMS 0x10000000 /* object has DT_REGISTER entries */ 632*7c478bd9Sstevel@tonic-gate #define FLG_RT_INITCLCT 0x20000000 /* init has been collected (tsort) */ 633*7c478bd9Sstevel@tonic-gate #define FLG_RT_HANDLE 0x40000000 /* generate a handle for this object */ 634*7c478bd9Sstevel@tonic-gate #define FLG_RT_RELOCING 0x80000000 /* object is being relocated */ 635*7c478bd9Sstevel@tonic-gate 636*7c478bd9Sstevel@tonic-gate #define FL1_RT_COPYTOOK 0x00000001 /* copy relocation taken */ 637*7c478bd9Sstevel@tonic-gate #define FL1_RT_RELATIVE 0x00000002 /* relative path expansion required */ 638*7c478bd9Sstevel@tonic-gate #define FL1_RT_CONFSET 0x00000004 /* object was loaded by crle(1) */ 639*7c478bd9Sstevel@tonic-gate #define FL1_RT_NODEFLIB 0x00000008 /* ignore default library search */ 640*7c478bd9Sstevel@tonic-gate #define FL1_RT_ENDFILTE 0x00000010 /* filtee terminates filters search */ 641*7c478bd9Sstevel@tonic-gate #define FL1_RT_DISPREL 0x00000020 /* object has *disp* relocation */ 642*7c478bd9Sstevel@tonic-gate #define FL1_RT_TEXTREL 0x00000040 /* DT_TEXTREL set in object */ 643*7c478bd9Sstevel@tonic-gate #define FL1_RT_INITWAIT 0x00000080 /* threads are waiting on .init */ 644*7c478bd9Sstevel@tonic-gate #define FL1_RT_LDDSTUB 0x00000100 /* identify lddstub */ 645*7c478bd9Sstevel@tonic-gate #define FL1_RT_NOINIFIN 0x00000200 /* no .init or .fini exists */ 646*7c478bd9Sstevel@tonic-gate #define FL1_RT_USED 0x00000400 /* symbol referenced from this object */ 647*7c478bd9Sstevel@tonic-gate #define FL1_RT_SYMBOLIC 0x00000800 /* DF_SYMBOLIC was set - use */ 648*7c478bd9Sstevel@tonic-gate /* symbolic sym resolution */ 649*7c478bd9Sstevel@tonic-gate #define FL1_RT_OBJSFLTR 0x00001000 /* object is acting as a standard */ 650*7c478bd9Sstevel@tonic-gate #define FL1_RT_OBJAFLTR 0x00002000 /* or auxiliary filter */ 651*7c478bd9Sstevel@tonic-gate #define FL1_RT_SYMSFLTR 0x00004000 /* symbol is acting as a standard */ 652*7c478bd9Sstevel@tonic-gate #define FL1_RT_SYMAFLTR 0x00008000 /* or auxiliary filter */ 653*7c478bd9Sstevel@tonic-gate #define MSK_RT_FILTER 0x0000f000 /* mask for all filter possibilites */ 654*7c478bd9Sstevel@tonic-gate 655*7c478bd9Sstevel@tonic-gate /* 656*7c478bd9Sstevel@tonic-gate * The following range of bits are reserved to hold LML_TFLG_AUD_ values 657*7c478bd9Sstevel@tonic-gate * (although the definitions themselves aren't used anywhere). 658*7c478bd9Sstevel@tonic-gate */ 659*7c478bd9Sstevel@tonic-gate #define FL1_AUD_RS_STR 0x00100000 /* RESERVATION start for AU flags */ 660*7c478bd9Sstevel@tonic-gate #define FL1_AUD_RS_END 0x80000000 /* RESERVATION end for AU flags */ 661*7c478bd9Sstevel@tonic-gate 662*7c478bd9Sstevel@tonic-gate 663*7c478bd9Sstevel@tonic-gate /* 664*7c478bd9Sstevel@tonic-gate * Flags for the tls_modactivity() routine 665*7c478bd9Sstevel@tonic-gate */ 666*7c478bd9Sstevel@tonic-gate #define TM_FLG_MODADD 0x01 /* call tls_modadd() interface */ 667*7c478bd9Sstevel@tonic-gate #define TM_FLG_MODREM 0x02 /* call tls_modrem() interface */ 668*7c478bd9Sstevel@tonic-gate 669*7c478bd9Sstevel@tonic-gate /* 670*7c478bd9Sstevel@tonic-gate * Macros for getting to link_map data. 671*7c478bd9Sstevel@tonic-gate */ 672*7c478bd9Sstevel@tonic-gate #define ADDR(X) ((X)->rt_public.l_addr) 673*7c478bd9Sstevel@tonic-gate #define NAME(X) ((X)->rt_public.l_name) 674*7c478bd9Sstevel@tonic-gate #define DYN(X) ((X)->rt_public.l_ld) 675*7c478bd9Sstevel@tonic-gate #define NEXT(X) ((X)->rt_public.l_next) 676*7c478bd9Sstevel@tonic-gate #define PREV(X) ((X)->rt_public.l_prev) 677*7c478bd9Sstevel@tonic-gate #define REFNAME(X) ((X)->rt_public.l_refname) 678*7c478bd9Sstevel@tonic-gate 679*7c478bd9Sstevel@tonic-gate /* 680*7c478bd9Sstevel@tonic-gate * Macros for getting to linker private data. 681*7c478bd9Sstevel@tonic-gate */ 682*7c478bd9Sstevel@tonic-gate #define PATHNAME(X) ((X)->rt_pathname) 683*7c478bd9Sstevel@tonic-gate #define PADSTART(X) ((X)->rt_padstart) 684*7c478bd9Sstevel@tonic-gate #define PADIMLEN(X) ((X)->rt_padimlen) 685*7c478bd9Sstevel@tonic-gate #define MSIZE(X) ((X)->rt_msize) 686*7c478bd9Sstevel@tonic-gate #define FLAGS(X) ((X)->rt_flags) 687*7c478bd9Sstevel@tonic-gate #define FLAGS1(X) ((X)->rt_flags1) 688*7c478bd9Sstevel@tonic-gate #define TLSMODID(X) ((X)->rt_tlsmodid) 689*7c478bd9Sstevel@tonic-gate 690*7c478bd9Sstevel@tonic-gate #define ALIAS(X) ((X)->rt_alias) 691*7c478bd9Sstevel@tonic-gate #define FPNODE(X) ((X)->rt_fpnode) 692*7c478bd9Sstevel@tonic-gate #define INIT(X) ((X)->rt_init) 693*7c478bd9Sstevel@tonic-gate #define FINI(X) ((X)->rt_fini) 694*7c478bd9Sstevel@tonic-gate #define RPATH(X) ((X)->rt_runpath) 695*7c478bd9Sstevel@tonic-gate #define RLIST(X) ((X)->rt_runlist) 696*7c478bd9Sstevel@tonic-gate #define DEPENDS(X) ((X)->rt_depends) 697*7c478bd9Sstevel@tonic-gate #define CALLERS(X) ((X)->rt_callers) 698*7c478bd9Sstevel@tonic-gate #define HANDLES(X) ((X)->rt_handles) 699*7c478bd9Sstevel@tonic-gate #define GROUPS(X) ((X)->rt_groups) 700*7c478bd9Sstevel@tonic-gate #define ETEXT(X) ((X)->rt_etext) 701*7c478bd9Sstevel@tonic-gate #define FCT(X) ((X)->rt_fct) 702*7c478bd9Sstevel@tonic-gate #define SYMINTP(X) ((X)->rt_symintp) 703*7c478bd9Sstevel@tonic-gate #define LIST(X) ((X)->rt_list) 704*7c478bd9Sstevel@tonic-gate #define OBJFLTRNDX(X) ((X)->rt_objfltrndx) 705*7c478bd9Sstevel@tonic-gate #define SYMSFLTRCNT(X) ((X)->rt_symsfltrcnt) 706*7c478bd9Sstevel@tonic-gate #define SYMAFLTRCNT(X) ((X)->rt_symafltrcnt) 707*7c478bd9Sstevel@tonic-gate #define MODE(X) ((X)->rt_mode) 708*7c478bd9Sstevel@tonic-gate #define SORTVAL(X) ((X)->rt_sortval) 709*7c478bd9Sstevel@tonic-gate #define CYCGROUP(X) ((X)->rt_cycgroup) 710*7c478bd9Sstevel@tonic-gate #define STDEV(X) ((X)->rt_stdev) 711*7c478bd9Sstevel@tonic-gate #define STINO(X) ((X)->rt_stino) 712*7c478bd9Sstevel@tonic-gate #define ORIGNAME(X) ((X)->rt_origname) 713*7c478bd9Sstevel@tonic-gate #define DIRSZ(X) ((X)->rt_dirsz) 714*7c478bd9Sstevel@tonic-gate #define COPY(X) ((X)->rt_copy) 715*7c478bd9Sstevel@tonic-gate #define AUDITORS(X) ((X)->rt_auditors) 716*7c478bd9Sstevel@tonic-gate #define AUDINFO(X) ((X)->rt_audinfo) 717*7c478bd9Sstevel@tonic-gate #define SYMINFO(X) ((X)->rt_syminfo) 718*7c478bd9Sstevel@tonic-gate #define INITARRAY(X) ((X)->rt_initarray) 719*7c478bd9Sstevel@tonic-gate #define FINIARRAY(X) ((X)->rt_finiarray) 720*7c478bd9Sstevel@tonic-gate #define PREINITARRAY(X) ((X)->rt_preinitarray) 721*7c478bd9Sstevel@tonic-gate #define MMAPS(X) ((X)->rt_mmaps) 722*7c478bd9Sstevel@tonic-gate #define MMAPCNT(X) ((X)->rt_mmapcnt) 723*7c478bd9Sstevel@tonic-gate #define INITARRAYSZ(X) ((X)->rt_initarraysz) 724*7c478bd9Sstevel@tonic-gate #define FINIARRAYSZ(X) ((X)->rt_finiarraysz) 725*7c478bd9Sstevel@tonic-gate #define PREINITARRAYSZ(X) ((X)->rt_preinitarraysz) 726*7c478bd9Sstevel@tonic-gate #define DYNINFO(X) ((X)->rt_dyninfo) 727*7c478bd9Sstevel@tonic-gate #define DYNINFOCNT(X) ((X)->rt_dyninfocnt) 728*7c478bd9Sstevel@tonic-gate #define RELACOUNT(X) ((X)->rt_relacount) 729*7c478bd9Sstevel@tonic-gate #define IDX(X) ((X)->rt_idx) 730*7c478bd9Sstevel@tonic-gate #define LAZY(X) ((X)->rt_lazy) 731*7c478bd9Sstevel@tonic-gate #define CONDVAR(X) ((X)->rt_condvar) 732*7c478bd9Sstevel@tonic-gate #define CNTL(X) ((X)->rt_cntl) 733*7c478bd9Sstevel@tonic-gate #define HWCAP(X) ((X)->rt_hwcap) 734*7c478bd9Sstevel@tonic-gate #define SFCAP(X) ((X)->rt_sfcap) 735*7c478bd9Sstevel@tonic-gate #define THREADID(X) ((X)->rt_threadid) 736*7c478bd9Sstevel@tonic-gate 737*7c478bd9Sstevel@tonic-gate 738*7c478bd9Sstevel@tonic-gate /* 739*7c478bd9Sstevel@tonic-gate * Flags for lookup_sym (and hence find_sym) routines. 740*7c478bd9Sstevel@tonic-gate */ 741*7c478bd9Sstevel@tonic-gate #define LKUP_DEFT 0x0000 /* simple lookup request */ 742*7c478bd9Sstevel@tonic-gate #define LKUP_SPEC 0x0001 /* special ELF lookup (allows address */ 743*7c478bd9Sstevel@tonic-gate /* resolutions to plt[] entries) */ 744*7c478bd9Sstevel@tonic-gate #define LKUP_LDOT 0x0002 /* indicates the original A_OUT */ 745*7c478bd9Sstevel@tonic-gate /* symbol had a leading `.' */ 746*7c478bd9Sstevel@tonic-gate #define LKUP_FIRST 0x0004 /* lookup symbol in first link map */ 747*7c478bd9Sstevel@tonic-gate /* only */ 748*7c478bd9Sstevel@tonic-gate #define LKUP_COPY 0x0008 /* lookup symbol for a COPY reloc, do */ 749*7c478bd9Sstevel@tonic-gate /* not bind to symbol at head */ 750*7c478bd9Sstevel@tonic-gate #define LKUP_ALLCNTLIST 0x0010 /* lookup symbol in all control lists */ 751*7c478bd9Sstevel@tonic-gate #define LKUP_SELF 0x0020 /* lookup symbol in ourself - undef */ 752*7c478bd9Sstevel@tonic-gate /* is valid */ 753*7c478bd9Sstevel@tonic-gate #define LKUP_WEAK 0x0040 /* relocation reference is weak */ 754*7c478bd9Sstevel@tonic-gate #define LKUP_NEXT 0x0080 /* request originates from RTLD_NEXT */ 755*7c478bd9Sstevel@tonic-gate #define LKUP_NODESCENT 0x0100 /* don't descend through dependencies */ 756*7c478bd9Sstevel@tonic-gate #define LKUP_NOFALBACK 0x0200 /* don't fall back to loading */ 757*7c478bd9Sstevel@tonic-gate /* pending lazy dependencies */ 758*7c478bd9Sstevel@tonic-gate #define LKUP_DIRECT 0x0400 /* direct binding request */ 759*7c478bd9Sstevel@tonic-gate 760*7c478bd9Sstevel@tonic-gate /* 761*7c478bd9Sstevel@tonic-gate * Data structure for calling lookup_sym() 762*7c478bd9Sstevel@tonic-gate */ 763*7c478bd9Sstevel@tonic-gate typedef struct { 764*7c478bd9Sstevel@tonic-gate const char *sl_name; /* symbol name */ 765*7c478bd9Sstevel@tonic-gate Rt_map *sl_cmap; /* callers link-map */ 766*7c478bd9Sstevel@tonic-gate Rt_map *sl_imap; /* initial link-map to search */ 767*7c478bd9Sstevel@tonic-gate ulong_t sl_hash; /* symbol hash value */ 768*7c478bd9Sstevel@tonic-gate ulong_t sl_rsymndx; /* referencing reloc symndx */ 769*7c478bd9Sstevel@tonic-gate uint_t sl_flags; /* lookup flags */ 770*7c478bd9Sstevel@tonic-gate } Slookup; 771*7c478bd9Sstevel@tonic-gate 772*7c478bd9Sstevel@tonic-gate 773*7c478bd9Sstevel@tonic-gate typedef enum { 774*7c478bd9Sstevel@tonic-gate PLT_T_NONE = 0, 775*7c478bd9Sstevel@tonic-gate PLT_T_21D, 776*7c478bd9Sstevel@tonic-gate PLT_T_24D, 777*7c478bd9Sstevel@tonic-gate PLT_T_U32, 778*7c478bd9Sstevel@tonic-gate PLT_T_U44, 779*7c478bd9Sstevel@tonic-gate PLT_T_FULL, 780*7c478bd9Sstevel@tonic-gate PLT_T_FAR, 781*7c478bd9Sstevel@tonic-gate PLT_T_NUM /* Must be last */ 782*7c478bd9Sstevel@tonic-gate } Pltbindtype; 783*7c478bd9Sstevel@tonic-gate 784*7c478bd9Sstevel@tonic-gate /* 785*7c478bd9Sstevel@tonic-gate * Prototypes. 786*7c478bd9Sstevel@tonic-gate */ 787*7c478bd9Sstevel@tonic-gate extern Lm_list lml_main; /* main's link map list */ 788*7c478bd9Sstevel@tonic-gate extern Lm_list lml_rtld; /* rtld's link map list */ 789*7c478bd9Sstevel@tonic-gate extern Lm_list *lml_list[]; 790*7c478bd9Sstevel@tonic-gate 791*7c478bd9Sstevel@tonic-gate extern int do_reloc(uchar_t, uchar_t *, Xword *, const char *, 792*7c478bd9Sstevel@tonic-gate const char *); 793*7c478bd9Sstevel@tonic-gate extern Pltbindtype elf_plt_write(uintptr_t, uintptr_t, void *, uintptr_t, 794*7c478bd9Sstevel@tonic-gate Xword); 795*7c478bd9Sstevel@tonic-gate extern void eprintf(Error, const char *, ...); 796*7c478bd9Sstevel@tonic-gate extern Rt_map *is_so_loaded(Lm_list *, const char *, int); 797*7c478bd9Sstevel@tonic-gate extern Sym *lookup_sym(Slookup *, Rt_map **, uint_t *); 798*7c478bd9Sstevel@tonic-gate extern int rt_dldump(Rt_map *, const char *, int, Addr); 799*7c478bd9Sstevel@tonic-gate 800*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 801*7c478bd9Sstevel@tonic-gate } 802*7c478bd9Sstevel@tonic-gate #endif 803*7c478bd9Sstevel@tonic-gate 804*7c478bd9Sstevel@tonic-gate #endif /* _RTLD_H */ 805