10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1618Srie * Common Development and Distribution License (the "License"). 6*1618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21*1618Srie 220Sstevel@tonic-gate /* 23*1618Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _RTLD_H 280Sstevel@tonic-gate #define _RTLD_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 310Sstevel@tonic-gate 320Sstevel@tonic-gate /* 330Sstevel@tonic-gate * Global include file for the runtime linker support library. 340Sstevel@tonic-gate */ 350Sstevel@tonic-gate #include <time.h> 360Sstevel@tonic-gate #include <sgs.h> 370Sstevel@tonic-gate #include <thread.h> 380Sstevel@tonic-gate #include <synch.h> 390Sstevel@tonic-gate #include <machdep.h> 400Sstevel@tonic-gate #include <sys/avl.h> 410Sstevel@tonic-gate #include <alist.h> 420Sstevel@tonic-gate 430Sstevel@tonic-gate #ifdef _SYSCALL32 440Sstevel@tonic-gate #include <inttypes.h> 450Sstevel@tonic-gate #endif 460Sstevel@tonic-gate 470Sstevel@tonic-gate #ifdef __cplusplus 480Sstevel@tonic-gate extern "C" { 490Sstevel@tonic-gate #endif 500Sstevel@tonic-gate 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* 530Sstevel@tonic-gate * Linked list of directories or filenames (built from colon separated string). 540Sstevel@tonic-gate */ 550Sstevel@tonic-gate typedef struct pnode { 560Sstevel@tonic-gate const char *p_name; 570Sstevel@tonic-gate const char *p_oname; 580Sstevel@tonic-gate size_t p_len; 590Sstevel@tonic-gate uint_t p_orig; 600Sstevel@tonic-gate void *p_info; 610Sstevel@tonic-gate struct pnode *p_next; 620Sstevel@tonic-gate } Pnode; 630Sstevel@tonic-gate 640Sstevel@tonic-gate typedef struct rt_map Rt_map; 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 670Sstevel@tonic-gate * A binding descriptor. Establishes the binding relationship between two 68*1618Srie * objects, the caller (originator) and the dependency (destination). 690Sstevel@tonic-gate */ 700Sstevel@tonic-gate typedef struct { 710Sstevel@tonic-gate Rt_map *b_caller; /* caller (originator) of a binding */ 720Sstevel@tonic-gate Rt_map *b_depend; /* dependency (destination) of a */ 730Sstevel@tonic-gate /* binding */ 740Sstevel@tonic-gate uint_t b_flags; /* relationship of caller to the */ 750Sstevel@tonic-gate /* dependency */ 760Sstevel@tonic-gate } Bnd_desc; 770Sstevel@tonic-gate 780Sstevel@tonic-gate #define BND_NEEDED 0x0001 /* caller NEEDED the dependency */ 790Sstevel@tonic-gate #define BND_REFER 0x0002 /* caller relocation references the */ 800Sstevel@tonic-gate /* dependency */ 81280Srie #define BND_FILTER 0x0004 /* pseudo binding to identify filter */ 820Sstevel@tonic-gate 830Sstevel@tonic-gate /* 840Sstevel@tonic-gate * Private structure for communication between rtld_db and rtld. 850Sstevel@tonic-gate * 860Sstevel@tonic-gate * We must bump the version number whenever a update in one of 870Sstevel@tonic-gate * the structures/fields that rtld_db reads is updated. This hopefully 880Sstevel@tonic-gate * permits rtld_db implementations of the future recognize corefiles 890Sstevel@tonic-gate * produced on older system and deal accordingly. 900Sstevel@tonic-gate * 910Sstevel@tonic-gate * As of version 'RTLD_DB_VERSION <= 2' the following fields 920Sstevel@tonic-gate * were valid for core file examination (basically the public 930Sstevel@tonic-gate * Link_map): 940Sstevel@tonic-gate * 950Sstevel@tonic-gate * ADDR() 960Sstevel@tonic-gate * NAME() 970Sstevel@tonic-gate * DYN() 980Sstevel@tonic-gate * NEXT() 990Sstevel@tonic-gate * PREV() 1000Sstevel@tonic-gate * 1010Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION3 1020Sstevel@tonic-gate * 1030Sstevel@tonic-gate * PATHNAME() 1040Sstevel@tonic-gate * PADSTART() 1050Sstevel@tonic-gate * PADIMLEN() 1060Sstevel@tonic-gate * MSIZE() 1070Sstevel@tonic-gate * FLAGS() 1080Sstevel@tonic-gate * FLAGS1() 1090Sstevel@tonic-gate * 1100Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION4 1110Sstevel@tonic-gate * 1120Sstevel@tonic-gate * TLSMODID() 1130Sstevel@tonic-gate * 1140Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION5 1150Sstevel@tonic-gate * 1160Sstevel@tonic-gate * Added rtld_flags & FLG_RT_RELOCED to stable flags range 1170Sstevel@tonic-gate * 1180Sstevel@tonic-gate */ 1190Sstevel@tonic-gate #define R_RTLDDB_VERSION1 1 /* base version level - used for core */ 1200Sstevel@tonic-gate /* file examination */ 1210Sstevel@tonic-gate #define R_RTLDDB_VERSION2 2 /* minor revision - not relavant for */ 1220Sstevel@tonic-gate /* core files */ 1230Sstevel@tonic-gate #define R_RTLDDB_VERSION3 3 1240Sstevel@tonic-gate #define R_RTLDDB_VERSION4 4 1250Sstevel@tonic-gate #define R_RTLDDB_VERSION5 5 1260Sstevel@tonic-gate #define R_RTLDDB_VERSION R_RTLDDB_VERSION5 /* current version */ 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate typedef struct rtld_db_priv { 1290Sstevel@tonic-gate struct r_debug rtd_rdebug; /* original r_debug structure */ 1300Sstevel@tonic-gate Word rtd_version; /* version no. */ 1310Sstevel@tonic-gate size_t rtd_objpad; /* padding around mmap()ed objects */ 1320Sstevel@tonic-gate List * rtd_dynlmlst; /* pointer to Dynlm_list */ 1330Sstevel@tonic-gate } Rtld_db_priv; 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate #ifdef _SYSCALL32 1360Sstevel@tonic-gate typedef struct rtld_db_priv32 { 1370Sstevel@tonic-gate struct r_debug32 rtd_rdebug; /* original r_debug structure */ 1380Sstevel@tonic-gate Elf32_Word rtd_version; /* version no. */ 1390Sstevel@tonic-gate Elf32_Word rtd_objpad; /* padding around mmap()ed objects */ 1400Sstevel@tonic-gate Elf32_Addr rtd_dynlmlst; /* pointer to Dynlm_list */ 1410Sstevel@tonic-gate } Rtld_db_priv32; 1420Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* 1460Sstevel@tonic-gate * Link map list definition. Link-maps are used to describe each loaded object. 1470Sstevel@tonic-gate * Lists of these link-maps describe the various namespaces within a process. 1480Sstevel@tonic-gate * The process executable and its dependencies are maintained on the lml_main 1490Sstevel@tonic-gate * list. The runtime linker, and its dependencies are maintained on the 1500Sstevel@tonic-gate * lml_rtld list. Additional lists can be created (see dlmopen()) for such 1510Sstevel@tonic-gate * things as auditors and their dependencies. 1520Sstevel@tonic-gate * 1530Sstevel@tonic-gate * Each link-map list maintains an Alist of one, or more, linked lists of 1540Sstevel@tonic-gate * link-maps. For backward compatibility, the lm_head/lm_tail elements are 1550Sstevel@tonic-gate * initialized to the first linked-list of link-maps: 1560Sstevel@tonic-gate * 1570Sstevel@tonic-gate * Lm_list 1580Sstevel@tonic-gate * ---------- 1590Sstevel@tonic-gate * | lm_tail | ------------------------------------ 1600Sstevel@tonic-gate * | lm_head | -------------------- | 1610Sstevel@tonic-gate * | | | Rt_map | Rt_map 1620Sstevel@tonic-gate * | | | ------ | ------ 1630Sstevel@tonic-gate * | | Alist --> | | |--> | | 1640Sstevel@tonic-gate * | | --------- | | | -- | | 1650Sstevel@tonic-gate * | lm_lists | ----> | | | | | --> | | 1660Sstevel@tonic-gate * | | |---------| | | | | | | 1670Sstevel@tonic-gate * | | | lc_head | -- ------ | ------ 1680Sstevel@tonic-gate * | | | lc_tail | ------------------ 1690Sstevel@tonic-gate * | | |---------| 1700Sstevel@tonic-gate * | lc_head | 1710Sstevel@tonic-gate * | lc_tail | 1720Sstevel@tonic-gate * |---------| 1730Sstevel@tonic-gate * 1740Sstevel@tonic-gate * Multiple link-map lists exist to support the addition of lazy loaded 1750Sstevel@tonic-gate * families, filtee families, and dlopen() families. The intent of these 1760Sstevel@tonic-gate * lists is to insure that a family of objects that are to be loaded are 1770Sstevel@tonic-gate * fully relocatable, and hence usable, before they become part of the main 1780Sstevel@tonic-gate * (al_data[0]) link-map control list. This main link-map control list is 1790Sstevel@tonic-gate * the only list in existence when control is transferred to user code. 1800Sstevel@tonic-gate * 1810Sstevel@tonic-gate * During process initialization, the dynamic executable and its non-lazy 1820Sstevel@tonic-gate * dependencies are maintained on al_data[0]. If a new object is loaded, then 1830Sstevel@tonic-gate * this object is added to the next available control list [1], typically 1840Sstevel@tonic-gate * al_data[1]. Any dependencies of this object that have not already been 1850Sstevel@tonic-gate * loaded are added to the same control list. Once all of the objects on the 1860Sstevel@tonic-gate * new control list have been successfully relocated, the objects are moved from 1870Sstevel@tonic-gate * the new control list to the highest control list to which objects of the new 1880Sstevel@tonic-gate * control list bound to, typically al_data[1] to al_data[0]. 1890Sstevel@tonic-gate * 1900Sstevel@tonic-gate * Each loading scenario can be broken down as follows: 1910Sstevel@tonic-gate * 1920Sstevel@tonic-gate * setup() - only the initial link-map control list is used: 1930Sstevel@tonic-gate * i. create al_data[0] 1940Sstevel@tonic-gate * ii. add new link-map for main on al_data[0] 1950Sstevel@tonic-gate * iii. analyze al_data[0] to add all non-lazy dependencies 1960Sstevel@tonic-gate * iv. relocate al_data[0] dependencies. 1970Sstevel@tonic-gate * 1980Sstevel@tonic-gate * dlopen() - the initiator can only be the initial link-map control list: 1990Sstevel@tonic-gate * i. create al_data[1] from caller al_data[0] 2000Sstevel@tonic-gate * ii. add new link-map for the dlopen'ed object on al_data[1] 2010Sstevel@tonic-gate * iii. analyze al_data[1] to add all non-lazy dependencies 2020Sstevel@tonic-gate * iv. relocate al_data[1] dependencies, and move to al_data[0]. 2030Sstevel@tonic-gate * 2040Sstevel@tonic-gate * filtee and lazy loading processing - the initiator can be any link-map 2050Sstevel@tonic-gate * control list that is being relocated: 2060Sstevel@tonic-gate * i. create al_data[y] from caller al_data[x] 2070Sstevel@tonic-gate * ii. add new link-map for the new object on al_data[y] 2080Sstevel@tonic-gate * iii. analyze al_data[y] to add all non-lazy dependencies 2090Sstevel@tonic-gate * iv. relocate al_data[y] dependencies, and move to al_data[x]. 2100Sstevel@tonic-gate * 2110Sstevel@tonic-gate * This Alist therefore maintains a stack of link-map control lists. The newest 2120Sstevel@tonic-gate * link-map control list can locate symbols within any of the former lists, 2130Sstevel@tonic-gate * however, control is not passed to a former list until the newest lists 2140Sstevel@tonic-gate * processing is complete. Thus, objects can't bind to new objects until they 2150Sstevel@tonic-gate * have been fully analyzed and relocated. 2160Sstevel@tonic-gate * 2170Sstevel@tonic-gate * [1] Note, additional link-map control list creation occurs after the head 2180Sstevel@tonic-gate * link-map object (typically the dynamic executable) has been relocated. This 2190Sstevel@tonic-gate * staging is required to satisfy the binding requirements of copy relocations. 2200Sstevel@tonic-gate * Copy relocations, effectively, transfer the bindings of the copied data 2210Sstevel@tonic-gate * (say _iob in libc.so.1) to the copy location (_iob in the application). 2220Sstevel@tonic-gate * Thus an object that might bind to the original copy data must be redirected 2230Sstevel@tonic-gate * to the copy reference. As the knowledge of a copy relocation having taken 2240Sstevel@tonic-gate * place is only known after relocating the application, link-map control list 2250Sstevel@tonic-gate * additions are suspended until after this relocation has completed. 2260Sstevel@tonic-gate */ 2270Sstevel@tonic-gate typedef struct { 2280Sstevel@tonic-gate Rt_map *lc_head; 2290Sstevel@tonic-gate Rt_map *lc_tail; 2300Sstevel@tonic-gate Alist *lc_now; /* pending promoted bind-now objects */ 2310Sstevel@tonic-gate uint_t lc_flags; 2320Sstevel@tonic-gate } Lm_cntl; 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate #define LMC_FLG_ANALYZING 0x01 /* control list is being analyzed */ 2350Sstevel@tonic-gate #define LMC_FLG_RELOCATING 0x02 /* control list is being relocated */ 2360Sstevel@tonic-gate #define LMC_FLG_REANALYZE 0x04 /* repeat analysis (established when */ 2370Sstevel@tonic-gate /* interposers are added */ 2380Sstevel@tonic-gate 239*1618Srie struct lm_list { 2400Sstevel@tonic-gate /* 2410Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 2420Sstevel@tonic-gate */ 2430Sstevel@tonic-gate Rt_map *lm_head; /* linked list pointers to active */ 2440Sstevel@tonic-gate Rt_map *lm_tail; /* link-map list */ 2450Sstevel@tonic-gate Alist *lm_handle; /* not used by rtld_db - but spacing */ 2460Sstevel@tonic-gate /* is required for flags */ 2470Sstevel@tonic-gate Word lm_flags; 2480Sstevel@tonic-gate /* 2490Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 2500Sstevel@tonic-gate */ 2510Sstevel@tonic-gate int (*lm_peh)(); /* atexit() preexec_exit_handlers */ 2520Sstevel@tonic-gate Rt_map *lm_peh_lmp; /* and object that contributed them */ 2530Sstevel@tonic-gate Rt_map *lm_info_lmp; /* the first object with rtld_info */ 2540Sstevel@tonic-gate Alist *lm_rtldinfo; /* list of RTLDINFO tables */ 2550Sstevel@tonic-gate Audit_list *lm_alp; /* audit list descripter */ 2560Sstevel@tonic-gate avl_tree_t *lm_fpavl; /* avl tree of objects loaded */ 2570Sstevel@tonic-gate Alist *lm_lists; /* active and pending link-map lists */ 2586Srie char ***lm_environ; /* pointer to environment array */ 2590Sstevel@tonic-gate Word lm_tflags; /* transferable flags */ 260*1618Srie uint_t lm_obj; /* total number of objs on link-map */ 261*1618Srie uint_t lm_init; /* new obj since last init processing */ 262*1618Srie uint_t lm_lazy; /* obj with pending lazy dependencies */ 263*1618Srie uint_t lm_lmid; /* unique link-map list identifier, */ 264*1618Srie char *lm_lmidstr; /* and associated diagnostic string */ 265*1618Srie }; 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate #ifdef _SYSCALL32 268*1618Srie struct lm_list32 { 2690Sstevel@tonic-gate /* 2700Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 2710Sstevel@tonic-gate */ 2720Sstevel@tonic-gate Elf32_Addr lm_head; 2730Sstevel@tonic-gate Elf32_Addr lm_tail; 2740Sstevel@tonic-gate Elf32_Addr lm_handle; 2750Sstevel@tonic-gate Elf32_Word lm_flags; 2760Sstevel@tonic-gate /* 2770Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 2780Sstevel@tonic-gate */ 2790Sstevel@tonic-gate Elf32_Addr lm_peh; 2800Sstevel@tonic-gate Elf32_Addr lm_peh_lmp; 2810Sstevel@tonic-gate Elf32_Addr lm_info_lmp; 2820Sstevel@tonic-gate Elf32_Addr lm_alp; 2830Sstevel@tonic-gate Elf32_Addr lm_fpavl; 2840Sstevel@tonic-gate Elf32_Addr lm_lists; 2856Srie Elf32_Addr lm_environ; 2860Sstevel@tonic-gate Elf32_Word lm_tflags; 287*1618Srie uint_t lm_obj; 288*1618Srie uint_t lm_init; 289*1618Srie uint_t lm_lazy; 290*1618Srie uint_t lm_lmid; 291*1618Srie Elf32_Addr lm_lmidstr; 292*1618Srie }; 2930Sstevel@tonic-gate #endif /* _SYSCALL32 */ 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate * Possible Link_map list flags (Lm_list.lm_flags) 2970Sstevel@tonic-gate */ 2980Sstevel@tonic-gate /* 2990Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 3000Sstevel@tonic-gate */ 3010Sstevel@tonic-gate #define LML_FLG_BASELM 0x00000001 /* primary link-map */ 3020Sstevel@tonic-gate #define LML_FLG_RTLDLM 0x00000002 /* rtld link-map */ 3030Sstevel@tonic-gate /* 3040Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 3050Sstevel@tonic-gate */ 3060Sstevel@tonic-gate #define LML_FLG_NOAUDIT 0x00000004 /* symbol auditing disabled */ 3070Sstevel@tonic-gate #define LML_FLG_PLTREL 0x00000008 /* deferred plt relocation */ 3080Sstevel@tonic-gate /* initialization */ 3090Sstevel@tonic-gate /* (ld.so.1 only) */ 3100Sstevel@tonic-gate #define LML_FLG_HOLDLOCK 0x00000010 /* hold the rtld mutex lock */ 3110Sstevel@tonic-gate #define LML_FLG_ENVIRON 0x00000020 /* environ var initialized */ 3120Sstevel@tonic-gate #define LML_FLG_INTRPOSE 0x00000040 /* interposing objs on list */ 3130Sstevel@tonic-gate #define LML_FLG_LOCAUDIT 0x00000080 /* local auditors exists for */ 3140Sstevel@tonic-gate /* this link-map list */ 3150Sstevel@tonic-gate #define LML_FLG_LOADAVAIL 0x00000100 /* load anything available */ 3160Sstevel@tonic-gate #define LML_FLG_IGNRELERR 0x00000200 /* ignore relocation errors - */ 3170Sstevel@tonic-gate /* internal for crle(1) */ 3180Sstevel@tonic-gate #define LML_FLG_DBNOTIF 0x00000400 /* binding activity going on */ 319280Srie #define LML_FLG_STARTREL 0x00000800 /* relocation started */ 320280Srie #define LML_FLG_ATEXIT 0x00001000 /* atexit processing */ 321280Srie #define LML_FLG_OBJADDED 0x00002000 /* object(s) added */ 322280Srie #define LML_FLG_OBJDELETED 0x00004000 /* object(s) deleted */ 323280Srie #define LML_FLG_OBJREEVAL 0x00008000 /* existing object(s) needs */ 324280Srie /* tsort reevaluation */ 3250Sstevel@tonic-gate #define LML_FLG_TRC_LDDSTUB 0x00100000 /* identify lddstub */ 3260Sstevel@tonic-gate #define LML_FLG_TRC_ENABLE 0x00200000 /* tracing enabled (ldd) */ 3270Sstevel@tonic-gate #define LML_FLG_TRC_WARN 0x00400000 /* print warnings for undefs */ 3280Sstevel@tonic-gate #define LML_FLG_TRC_VERBOSE 0x00800000 /* verbose (versioning) trace */ 3290Sstevel@tonic-gate #define LML_FLG_TRC_SEARCH 0x01000000 /* trace search paths */ 3300Sstevel@tonic-gate #define LML_FLG_TRC_UNREF 0x02000000 /* trace unreferenced */ 3310Sstevel@tonic-gate /* dependencies */ 3320Sstevel@tonic-gate #define LML_FLG_TRC_UNUSED 0x04000000 /* trace unused dependencies */ 3330Sstevel@tonic-gate #define LML_FLG_TRC_INIT 0x08000000 /* print .init order */ 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate #define LML_MSK_TRC 0xfff00000 /* tracing mask */ 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate /* 3380Sstevel@tonic-gate * Possible Link_map transferable flags (Lm_list.lm_tflags), i.e., link-map 3390Sstevel@tonic-gate * list flags that can be propagated to any new link-map list created. 3400Sstevel@tonic-gate */ 3410Sstevel@tonic-gate #define LML_TFLG_NOLAZYLD 0x00000001 /* lazy loading disabled */ 3420Sstevel@tonic-gate #define LML_TFLG_NODIRECT 0x00000002 /* direct bindings disabled */ 3430Sstevel@tonic-gate 3440Sstevel@tonic-gate #define LML_TFLG_LOADFLTR 0x00000008 /* trigger filtee loading */ 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate #define LML_TFLG_AUD_PREINIT 0x00100000 /* preinit (audit) exists */ 3470Sstevel@tonic-gate #define LML_TFLG_AUD_OBJSEARCH 0x00200000 /* objsearch (audit) exists */ 3480Sstevel@tonic-gate #define LML_TFLG_AUD_OBJOPEN 0x00400000 /* objopen (audit) exists */ 3490Sstevel@tonic-gate #define LML_TFLG_AUD_OBJFILTER 0x00800000 /* objfilter (audit) exists */ 3500Sstevel@tonic-gate #define LML_TFLG_AUD_OBJCLOSE 0x01000000 /* objclose (audit) exists */ 3510Sstevel@tonic-gate #define LML_TFLG_AUD_SYMBIND 0x02000000 /* symbind (audit) exists */ 3520Sstevel@tonic-gate #define LML_TFLG_AUD_PLTENTER 0x04000000 /* pltenter (audit) exists */ 3530Sstevel@tonic-gate #define LML_TFLG_AUD_PLTEXIT 0x08000000 /* pltexit (audit) exists */ 3540Sstevel@tonic-gate #define LML_TFLG_AUD_ACTIVITY 0x10000000 /* activity (audit) exists */ 3550Sstevel@tonic-gate 3560Sstevel@tonic-gate /* 3570Sstevel@tonic-gate * NOTE: Audit flags have duplicated FLAGS1() values. If more audit flags are 3580Sstevel@tonic-gate * added, update the FLAGS1() reservation FL1_AUD_RS_STR to FL1_AUD_RS_END 3590Sstevel@tonic-gate * defined later. 3600Sstevel@tonic-gate */ 3610Sstevel@tonic-gate #define LML_TFLG_AUD_MASK 0xfff00000 /* audit interfaces mask */ 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate 3640Sstevel@tonic-gate /* 3650Sstevel@tonic-gate * Information for dlopen(), dlsym(), and dlclose() on libraries linked by rtld. 3660Sstevel@tonic-gate * Each shared object referred from a dlopen call has an associated group 3670Sstevel@tonic-gate * handle structure returned that describes a group of one or more objects. 3680Sstevel@tonic-gate */ 3690Sstevel@tonic-gate typedef struct { 370*1618Srie Alist *gh_depends; /* handle dependency list */ 371*1618Srie Rt_map *gh_ownlmp; /* handle owners link-map */ 372*1618Srie Lm_list *gh_ownlml; /* handle owners link-map list */ 3730Sstevel@tonic-gate uint_t gh_refcnt; /* handle reference count */ 3740Sstevel@tonic-gate uint_t gh_flags; /* handle flags */ 3750Sstevel@tonic-gate } Grp_hdl; 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate #define GPH_ZERO 0x0001 /* special handle for dlopen(0) */ 3780Sstevel@tonic-gate #define GPH_LDSO 0x0002 /* special handle for ld.so.1 */ 3790Sstevel@tonic-gate #define GPH_FIRST 0x0004 /* dlsym() can only use originating */ 3800Sstevel@tonic-gate /* dependency */ 3810Sstevel@tonic-gate #define GPH_PARENT 0x0008 /* assign caller as a parent */ 3820Sstevel@tonic-gate #define GPH_FILTEE 0x0010 /* handle used to specify a filtee */ 3830Sstevel@tonic-gate #define GPH_INITIAL 0x0020 /* handle is initialized */ 3840Sstevel@tonic-gate #define GPH_STICKY 0x0040 /* handle is unreferenced, but should */ 3850Sstevel@tonic-gate /* not trigger object removal */ 3860Sstevel@tonic-gate 3870Sstevel@tonic-gate /* 3880Sstevel@tonic-gate * A group descriptor. A group handle (Grp_hdl) refers to a group of objects, 3890Sstevel@tonic-gate * each object, and its relationship to the handle, is maintained within a 3900Sstevel@tonic-gate * group descriptor. 3910Sstevel@tonic-gate */ 3920Sstevel@tonic-gate typedef struct { 3930Sstevel@tonic-gate Rt_map * gd_depend; /* dependency */ 3940Sstevel@tonic-gate uint_t gd_flags; /* dependency flags */ 3950Sstevel@tonic-gate } Grp_desc; 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate #define GPD_AVAIL 0x0001 /* dependency available to dlsym() */ 3980Sstevel@tonic-gate #define GPD_ADDEPS 0x0002 /* dependencies of this dependency */ 3990Sstevel@tonic-gate /* should be added to handle */ 4000Sstevel@tonic-gate #define GPD_PARENT 0x0004 /* dependency is a parent */ 4010Sstevel@tonic-gate #define GPD_FILTER 0x0008 /* dependency is our filter */ 4020Sstevel@tonic-gate #define GPD_REMOVE 0x1000 /* descriptor is a candidate for */ 4030Sstevel@tonic-gate /* removal from the group */ 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate /* 4060Sstevel@tonic-gate * Define threading structures. For compatibility with libthread (T1_VERSION 1 4070Sstevel@tonic-gate * and TI_VERSION 2) our locking structure is sufficient to hold a mutex or a 4080Sstevel@tonic-gate * readers/writers lock. 4090Sstevel@tonic-gate */ 4100Sstevel@tonic-gate typedef struct { 4110Sstevel@tonic-gate union { 4120Sstevel@tonic-gate mutex_t l_mutex; 4130Sstevel@tonic-gate rwlock_t l_rwlock; 4140Sstevel@tonic-gate } u; 4150Sstevel@tonic-gate } Rt_lock; 4160Sstevel@tonic-gate 4170Sstevel@tonic-gate typedef cond_t Rt_cond; 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate /* 4200Sstevel@tonic-gate * Define a dynamic section information descriptor. This parallels the entries 4210Sstevel@tonic-gate * in the .dynamic section and holds auxiliary information to implement lazy 4220Sstevel@tonic-gate * loading and filtee processing. 4230Sstevel@tonic-gate */ 4240Sstevel@tonic-gate typedef struct { 4250Sstevel@tonic-gate uint_t di_flags; 4260Sstevel@tonic-gate void *di_info; 4270Sstevel@tonic-gate } Dyninfo; 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate #define FLG_DI_STDFLTR 0x00001 /* .dynamic entry for DT_FILTER */ 4300Sstevel@tonic-gate #define FLG_DI_AUXFLTR 0x00002 /* .dynamic entry for DT_AUXILIARY */ 4310Sstevel@tonic-gate #define FLG_DI_SYMFLTR 0x00004 /* .dynamic entry for DT_SYMFILTER */ 4320Sstevel@tonic-gate /* and DT_SYMAUXILIARY */ 4330Sstevel@tonic-gate #define MSK_DI_FILTER 0x0000f /* mask for all filter possibilities */ 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate #define FLG_DI_NEEDED 0x00010 /* entry represents a dependency */ 4360Sstevel@tonic-gate #define FLG_DI_GROUP 0x00020 /* open dependency as a group */ 4370Sstevel@tonic-gate #define FLG_DI_PROCESSD 0x00040 /* entry has been processed */ 4380Sstevel@tonic-gate 4390Sstevel@tonic-gate /* 4400Sstevel@tonic-gate * Data Structure to track AVL tree for pathnames of objects 4410Sstevel@tonic-gate * loaded into memory 4420Sstevel@tonic-gate */ 4430Sstevel@tonic-gate typedef struct { 4440Sstevel@tonic-gate const char *fpn_name; /* object name */ 4450Sstevel@tonic-gate Rt_map *fpn_lmp; /* object link-map */ 4460Sstevel@tonic-gate avl_node_t fpn_avl; /* avl book-keeping (see SGSOFFSETOF) */ 4470Sstevel@tonic-gate uint_t fpn_hash; /* object name hash value */ 4480Sstevel@tonic-gate } FullpathNode; 4490Sstevel@tonic-gate 4500Sstevel@tonic-gate /* 4510Sstevel@tonic-gate * Define a mapping structure, which is maintained to describe each mapping 4520Sstevel@tonic-gate * of an object, ie. the text segment, data segment, bss segment, etc. 4530Sstevel@tonic-gate */ 4540Sstevel@tonic-gate typedef struct { 4550Sstevel@tonic-gate caddr_t m_vaddr; /* mapping address */ 4560Sstevel@tonic-gate size_t m_fsize; /* backing file size */ 4570Sstevel@tonic-gate size_t m_msize; /* mapping size */ 4580Sstevel@tonic-gate int m_perm; /* mapping permissions */ 4590Sstevel@tonic-gate } Mmap; 4600Sstevel@tonic-gate 4610Sstevel@tonic-gate /* 4620Sstevel@tonic-gate * Link-map definition. 4630Sstevel@tonic-gate */ 4640Sstevel@tonic-gate struct rt_map { 4650Sstevel@tonic-gate /* 4660Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 4670Sstevel@tonic-gate */ 4680Sstevel@tonic-gate Link_map rt_public; /* public data */ 4690Sstevel@tonic-gate char *rt_pathname; /* full pathname of loaded object */ 4700Sstevel@tonic-gate ulong_t rt_padstart; /* start of image (including padding) */ 4710Sstevel@tonic-gate ulong_t rt_padimlen; /* size of image (including padding */ 4720Sstevel@tonic-gate ulong_t rt_msize; /* total memory mapped */ 4730Sstevel@tonic-gate uint_t rt_flags; /* state flags, see FLG below */ 4740Sstevel@tonic-gate uint_t rt_flags1; /* state flags1, see FL1 below */ 4750Sstevel@tonic-gate ulong_t rt_tlsmodid; /* TLS module id */ 4760Sstevel@tonic-gate /* 4770Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 4780Sstevel@tonic-gate */ 4790Sstevel@tonic-gate Alist *rt_alias; /* list of linked file names */ 4800Sstevel@tonic-gate Alist *rt_fpnode; /* list of FullpathNode AVL nodes */ 4810Sstevel@tonic-gate void (*rt_init)(); /* address of _init */ 4820Sstevel@tonic-gate void (*rt_fini)(); /* address of _fini */ 4830Sstevel@tonic-gate char *rt_runpath; /* LD_RUN_PATH and its equivalent */ 4840Sstevel@tonic-gate Pnode *rt_runlist; /* Pnode structures */ 4850Sstevel@tonic-gate Alist *rt_depends; /* list of dependencies */ 4860Sstevel@tonic-gate Alist *rt_callers; /* list of callers */ 4870Sstevel@tonic-gate Alist *rt_handles; /* dlopen handles */ 4880Sstevel@tonic-gate Alist *rt_groups; /* groups we're a member of */ 4890Sstevel@tonic-gate ulong_t rt_etext; /* etext address */ 4900Sstevel@tonic-gate struct fct *rt_fct; /* file class table for this object */ 4910Sstevel@tonic-gate Sym *(*rt_symintp)(); /* link map symbol interpreter */ 4920Sstevel@tonic-gate void *rt_priv; /* private data, object type specific */ 4930Sstevel@tonic-gate Lm_list *rt_list; /* link map list we belong to */ 4940Sstevel@tonic-gate uint_t rt_objfltrndx; /* object filtees .dynamic index */ 4950Sstevel@tonic-gate uint_t rt_symsfltrcnt; /* number of standard symbol filtees */ 4960Sstevel@tonic-gate uint_t rt_symafltrcnt; /* number of auxiliary symbol filtees */ 4970Sstevel@tonic-gate int rt_mode; /* usage mode, see RTLD mode flags */ 498280Srie int rt_sortval; /* temporary buffer to traverse graph */ 4990Sstevel@tonic-gate uint_t rt_cycgroup; /* cyclic group */ 5000Sstevel@tonic-gate dev_t rt_stdev; /* device id and inode number for .so */ 5010Sstevel@tonic-gate ino_t rt_stino; /* multiple inclusion checks */ 5020Sstevel@tonic-gate char *rt_origname; /* original pathname of loaded object */ 5030Sstevel@tonic-gate size_t rt_dirsz; /* and its size */ 5040Sstevel@tonic-gate Alist *rt_copy; /* list of copy relocations */ 5050Sstevel@tonic-gate Audit_desc *rt_auditors; /* audit descriptor array */ 5060Sstevel@tonic-gate Audit_info *rt_audinfo; /* audit information descriptor */ 5070Sstevel@tonic-gate Syminfo *rt_syminfo; /* elf .syminfo section - here */ 5080Sstevel@tonic-gate /* because it is checked in */ 5090Sstevel@tonic-gate /* common code */ 5100Sstevel@tonic-gate Addr *rt_initarray; /* .initarray table */ 5110Sstevel@tonic-gate Addr *rt_finiarray; /* .finiarray table */ 5120Sstevel@tonic-gate Addr *rt_preinitarray; /* .preinitarray table */ 5130Sstevel@tonic-gate Mmap *rt_mmaps; /* array of mapping information */ 5140Sstevel@tonic-gate uint_t rt_mmapcnt; /* and associated number */ 5150Sstevel@tonic-gate uint_t rt_initarraysz; /* size of .initarray table */ 5160Sstevel@tonic-gate uint_t rt_finiarraysz; /* size of .finiarray table */ 5170Sstevel@tonic-gate uint_t rt_preinitarraysz; /* size of .preinitarray table */ 5180Sstevel@tonic-gate Dyninfo *rt_dyninfo; /* .dynamic information descriptors */ 5190Sstevel@tonic-gate uint_t rt_dyninfocnt; /* count of dyninfo entries */ 5200Sstevel@tonic-gate uint_t rt_relacount; /* no. of RELATIVE relocations */ 5210Sstevel@tonic-gate uint_t rt_idx; /* hold index within linkmap list */ 5220Sstevel@tonic-gate uint_t rt_lazy; /* lazy dependencies pending */ 5230Sstevel@tonic-gate Rt_cond *rt_condvar; /* variables */ 5240Sstevel@tonic-gate Xword rt_hwcap; /* hardware capabilities */ 5250Sstevel@tonic-gate Xword rt_sfcap; /* software capabilities */ 5260Sstevel@tonic-gate thread_t rt_threadid; /* thread init/fini synchronization */ 5270Sstevel@tonic-gate uint_t rt_cntl; /* link-map control list we belong to */ 5280Sstevel@tonic-gate }; 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate 5310Sstevel@tonic-gate #ifdef _SYSCALL32 5320Sstevel@tonic-gate /* 5330Sstevel@tonic-gate * Structure to allow 64-bit rtld_db to read 32-bit processes out of procfs. 5340Sstevel@tonic-gate */ 5350Sstevel@tonic-gate typedef struct rt_map32 { 5360Sstevel@tonic-gate /* 5370Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 5380Sstevel@tonic-gate */ 5390Sstevel@tonic-gate Link_map32 rt_public; 5400Sstevel@tonic-gate uint32_t rt_pathname; 5410Sstevel@tonic-gate uint32_t rt_padstart; 5420Sstevel@tonic-gate uint32_t rt_padimlen; 5430Sstevel@tonic-gate uint32_t rt_msize; 5440Sstevel@tonic-gate uint32_t rt_flags; 5450Sstevel@tonic-gate uint32_t rt_flags1; 5460Sstevel@tonic-gate uint32_t rt_tlsmodid; 5470Sstevel@tonic-gate /* 5480Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 5490Sstevel@tonic-gate */ 5500Sstevel@tonic-gate uint32_t rt_alias; 5510Sstevel@tonic-gate uint32_t rt_fpnode; 5520Sstevel@tonic-gate uint32_t rt_init; 5530Sstevel@tonic-gate uint32_t rt_fini; 5540Sstevel@tonic-gate uint32_t rt_runpath; 5550Sstevel@tonic-gate uint32_t rt_runlist; 5560Sstevel@tonic-gate uint32_t rt_depends; 5570Sstevel@tonic-gate uint32_t rt_callers; 5580Sstevel@tonic-gate uint32_t rt_handles; 5590Sstevel@tonic-gate uint32_t rt_groups; 5600Sstevel@tonic-gate uint32_t rt_etext; 5610Sstevel@tonic-gate uint32_t rt_fct; 5620Sstevel@tonic-gate uint32_t rt_symintp; 5630Sstevel@tonic-gate uint32_t rt_priv; 5640Sstevel@tonic-gate uint32_t rt_list; 5650Sstevel@tonic-gate uint32_t rt_objfltrndx; 5660Sstevel@tonic-gate uint32_t rt_symsfltrcnt; 5670Sstevel@tonic-gate uint32_t rt_symafltrcnt; 568280Srie int32_t rt_mode; 569280Srie int32_t rt_sortval; 5700Sstevel@tonic-gate uint32_t rt_cycgroup; 5710Sstevel@tonic-gate uint32_t rt_stdev; 5720Sstevel@tonic-gate uint32_t rt_stino; 5730Sstevel@tonic-gate uint32_t rt_origname; 5740Sstevel@tonic-gate uint32_t rt_dirsz; 5750Sstevel@tonic-gate uint32_t rt_copy; 5760Sstevel@tonic-gate uint32_t rt_auditors; 5770Sstevel@tonic-gate uint32_t rt_audinfo; 5780Sstevel@tonic-gate uint32_t rt_syminfo; 5790Sstevel@tonic-gate uint32_t rt_initarray; 5800Sstevel@tonic-gate uint32_t rt_finiarray; 5810Sstevel@tonic-gate uint32_t rt_preinitarray; 5820Sstevel@tonic-gate uint32_t rt_mmaps; 5830Sstevel@tonic-gate uint32_t rt_mmapcnt; 5840Sstevel@tonic-gate uint32_t rt_initarraysz; 5850Sstevel@tonic-gate uint32_t rt_finiarraysz; 5860Sstevel@tonic-gate uint32_t rt_preinitarraysz; 5870Sstevel@tonic-gate uint32_t rt_dyninfo; 5880Sstevel@tonic-gate uint32_t rt_dyninfocnt; 5890Sstevel@tonic-gate uint32_t rt_relacount; 5900Sstevel@tonic-gate uint32_t rt_idx; 5910Sstevel@tonic-gate uint32_t rt_lazy; 5920Sstevel@tonic-gate uint32_t rt_condvar; 5930Sstevel@tonic-gate uint32_t rt_hwcap; 5940Sstevel@tonic-gate uint32_t rt_sfcap; 5950Sstevel@tonic-gate uint32_t rt_threadid; 5960Sstevel@tonic-gate uint32_t rt_cntl; 5970Sstevel@tonic-gate } Rt_map32; 5980Sstevel@tonic-gate 5990Sstevel@tonic-gate #endif /* _SYSCALL32 */ 6000Sstevel@tonic-gate 6010Sstevel@tonic-gate /* 6020Sstevel@tonic-gate * Link map state flags. 6030Sstevel@tonic-gate */ 6040Sstevel@tonic-gate /* 6050Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 6060Sstevel@tonic-gate */ 6070Sstevel@tonic-gate #define FLG_RT_ISMAIN 0x00000001 /* object represents main executable */ 6080Sstevel@tonic-gate #define FLG_RT_IMGALLOC 0x00000002 /* image is allocated (not mmap'ed) */ 6090Sstevel@tonic-gate /* 6100Sstevel@tonic-gate * Available for r_debug version >= RTLD_DB_VERSION5 6110Sstevel@tonic-gate */ 6120Sstevel@tonic-gate #define FLG_RT_RELOCED 0x00000004 /* object has been relocated */ 6130Sstevel@tonic-gate /* 6140Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 6150Sstevel@tonic-gate */ 6160Sstevel@tonic-gate #define FLG_RT_SETGROUP 0x00000008 /* group establishment required */ 6170Sstevel@tonic-gate #define FLG_RT_HWCAP 0x00000010 /* process $HWCAP expansion */ 6180Sstevel@tonic-gate #define FLG_RT_OBJECT 0x00000020 /* object processing (ie. .o's) */ 61964Srie #define FLG_RT_NEWLOAD 0x00000040 /* object is newly loaded */ 6200Sstevel@tonic-gate #define FLG_RT_NODUMP 0x00000080 /* object can't be dldump(3x)'ed */ 6210Sstevel@tonic-gate #define FLG_RT_DELETE 0x00000100 /* object can be deleted */ 6220Sstevel@tonic-gate #define FLG_RT_ANALYZED 0x00000200 /* object has been analyzed */ 6230Sstevel@tonic-gate #define FLG_RT_INITDONE 0x00000400 /* objects .init has been completed */ 6240Sstevel@tonic-gate #define FLG_RT_TRANS 0x00000800 /* object is acting as a translator */ 6250Sstevel@tonic-gate #define FLG_RT_FIXED 0x00001000 /* image location is fixed */ 6260Sstevel@tonic-gate #define FLG_RT_PRELOAD 0x00002000 /* object was preloaded */ 6270Sstevel@tonic-gate #define FLG_RT_ALTER 0x00004000 /* alternative object used */ 6280Sstevel@tonic-gate #define FLG_RT_LOADFLTR 0x00008000 /* trigger filtee loading */ 6290Sstevel@tonic-gate #define FLG_RT_AUDIT 0x00010000 /* object is an auditor */ 6300Sstevel@tonic-gate #define FLG_RT_MODESET 0x00020000 /* MODE() has been initialized */ 6310Sstevel@tonic-gate #define FLG_RT_ANALZING 0x00040000 /* object is being analyzed */ 6320Sstevel@tonic-gate #define FLG_RT_INITFRST 0x00080000 /* execute .init first */ 6330Sstevel@tonic-gate #define FLG_RT_NOOPEN 0x00100000 /* dlopen() not allowed */ 6340Sstevel@tonic-gate #define FLG_RT_FINICLCT 0x00200000 /* fini has been collected (tsort) */ 6350Sstevel@tonic-gate #define FLG_RT_INITCALL 0x00400000 /* objects .init has been called */ 6360Sstevel@tonic-gate #define FLG_RT_INTRPOSE 0x00800000 /* object is an INTERPOSER */ 6370Sstevel@tonic-gate #define FLG_RT_DIRECT 0x01000000 /* object has DIRECT bindings enabled */ 6380Sstevel@tonic-gate #define FLG_RT_SUNWBSS 0x02000000 /* object with PT_SUNWBSS, not mapped */ 6390Sstevel@tonic-gate #define FLG_RT_MOVE 0x04000000 /* object needs move operation */ 6400Sstevel@tonic-gate #define FLG_RT_DLSYM 0x08000000 /* dlsym in progress on object */ 6410Sstevel@tonic-gate #define FLG_RT_REGSYMS 0x10000000 /* object has DT_REGISTER entries */ 6420Sstevel@tonic-gate #define FLG_RT_INITCLCT 0x20000000 /* init has been collected (tsort) */ 6430Sstevel@tonic-gate #define FLG_RT_HANDLE 0x40000000 /* generate a handle for this object */ 6440Sstevel@tonic-gate #define FLG_RT_RELOCING 0x80000000 /* object is being relocated */ 6450Sstevel@tonic-gate 6460Sstevel@tonic-gate #define FL1_RT_COPYTOOK 0x00000001 /* copy relocation taken */ 6470Sstevel@tonic-gate #define FL1_RT_RELATIVE 0x00000002 /* relative path expansion required */ 6480Sstevel@tonic-gate #define FL1_RT_CONFSET 0x00000004 /* object was loaded by crle(1) */ 6490Sstevel@tonic-gate #define FL1_RT_NODEFLIB 0x00000008 /* ignore default library search */ 6500Sstevel@tonic-gate #define FL1_RT_ENDFILTE 0x00000010 /* filtee terminates filters search */ 6510Sstevel@tonic-gate #define FL1_RT_DISPREL 0x00000020 /* object has *disp* relocation */ 6520Sstevel@tonic-gate #define FL1_RT_TEXTREL 0x00000040 /* DT_TEXTREL set in object */ 6530Sstevel@tonic-gate #define FL1_RT_INITWAIT 0x00000080 /* threads are waiting on .init */ 6540Sstevel@tonic-gate #define FL1_RT_LDDSTUB 0x00000100 /* identify lddstub */ 6550Sstevel@tonic-gate #define FL1_RT_NOINIFIN 0x00000200 /* no .init or .fini exists */ 6560Sstevel@tonic-gate #define FL1_RT_USED 0x00000400 /* symbol referenced from this object */ 6570Sstevel@tonic-gate #define FL1_RT_SYMBOLIC 0x00000800 /* DF_SYMBOLIC was set - use */ 6580Sstevel@tonic-gate /* symbolic sym resolution */ 6590Sstevel@tonic-gate #define FL1_RT_OBJSFLTR 0x00001000 /* object is acting as a standard */ 6600Sstevel@tonic-gate #define FL1_RT_OBJAFLTR 0x00002000 /* or auxiliary filter */ 6610Sstevel@tonic-gate #define FL1_RT_SYMSFLTR 0x00004000 /* symbol is acting as a standard */ 6620Sstevel@tonic-gate #define FL1_RT_SYMAFLTR 0x00008000 /* or auxiliary filter */ 6630Sstevel@tonic-gate #define MSK_RT_FILTER 0x0000f000 /* mask for all filter possibilites */ 6640Sstevel@tonic-gate 6650Sstevel@tonic-gate /* 6660Sstevel@tonic-gate * The following range of bits are reserved to hold LML_TFLG_AUD_ values 6670Sstevel@tonic-gate * (although the definitions themselves aren't used anywhere). 6680Sstevel@tonic-gate */ 6690Sstevel@tonic-gate #define FL1_AUD_RS_STR 0x00100000 /* RESERVATION start for AU flags */ 6700Sstevel@tonic-gate #define FL1_AUD_RS_END 0x80000000 /* RESERVATION end for AU flags */ 6710Sstevel@tonic-gate 6720Sstevel@tonic-gate 6730Sstevel@tonic-gate /* 6740Sstevel@tonic-gate * Flags for the tls_modactivity() routine 6750Sstevel@tonic-gate */ 6760Sstevel@tonic-gate #define TM_FLG_MODADD 0x01 /* call tls_modadd() interface */ 6770Sstevel@tonic-gate #define TM_FLG_MODREM 0x02 /* call tls_modrem() interface */ 6780Sstevel@tonic-gate 6790Sstevel@tonic-gate /* 6800Sstevel@tonic-gate * Macros for getting to link_map data. 6810Sstevel@tonic-gate */ 6820Sstevel@tonic-gate #define ADDR(X) ((X)->rt_public.l_addr) 6830Sstevel@tonic-gate #define NAME(X) ((X)->rt_public.l_name) 6840Sstevel@tonic-gate #define DYN(X) ((X)->rt_public.l_ld) 6850Sstevel@tonic-gate #define NEXT(X) ((X)->rt_public.l_next) 6860Sstevel@tonic-gate #define PREV(X) ((X)->rt_public.l_prev) 6870Sstevel@tonic-gate #define REFNAME(X) ((X)->rt_public.l_refname) 6880Sstevel@tonic-gate 6890Sstevel@tonic-gate /* 6900Sstevel@tonic-gate * Macros for getting to linker private data. 6910Sstevel@tonic-gate */ 6920Sstevel@tonic-gate #define PATHNAME(X) ((X)->rt_pathname) 6930Sstevel@tonic-gate #define PADSTART(X) ((X)->rt_padstart) 6940Sstevel@tonic-gate #define PADIMLEN(X) ((X)->rt_padimlen) 6950Sstevel@tonic-gate #define MSIZE(X) ((X)->rt_msize) 6960Sstevel@tonic-gate #define FLAGS(X) ((X)->rt_flags) 6970Sstevel@tonic-gate #define FLAGS1(X) ((X)->rt_flags1) 6980Sstevel@tonic-gate #define TLSMODID(X) ((X)->rt_tlsmodid) 6990Sstevel@tonic-gate 7000Sstevel@tonic-gate #define ALIAS(X) ((X)->rt_alias) 7010Sstevel@tonic-gate #define FPNODE(X) ((X)->rt_fpnode) 7020Sstevel@tonic-gate #define INIT(X) ((X)->rt_init) 7030Sstevel@tonic-gate #define FINI(X) ((X)->rt_fini) 7040Sstevel@tonic-gate #define RPATH(X) ((X)->rt_runpath) 7050Sstevel@tonic-gate #define RLIST(X) ((X)->rt_runlist) 7060Sstevel@tonic-gate #define DEPENDS(X) ((X)->rt_depends) 7070Sstevel@tonic-gate #define CALLERS(X) ((X)->rt_callers) 7080Sstevel@tonic-gate #define HANDLES(X) ((X)->rt_handles) 7090Sstevel@tonic-gate #define GROUPS(X) ((X)->rt_groups) 7100Sstevel@tonic-gate #define ETEXT(X) ((X)->rt_etext) 7110Sstevel@tonic-gate #define FCT(X) ((X)->rt_fct) 7120Sstevel@tonic-gate #define SYMINTP(X) ((X)->rt_symintp) 7130Sstevel@tonic-gate #define LIST(X) ((X)->rt_list) 7140Sstevel@tonic-gate #define OBJFLTRNDX(X) ((X)->rt_objfltrndx) 7150Sstevel@tonic-gate #define SYMSFLTRCNT(X) ((X)->rt_symsfltrcnt) 7160Sstevel@tonic-gate #define SYMAFLTRCNT(X) ((X)->rt_symafltrcnt) 7170Sstevel@tonic-gate #define MODE(X) ((X)->rt_mode) 7180Sstevel@tonic-gate #define SORTVAL(X) ((X)->rt_sortval) 7190Sstevel@tonic-gate #define CYCGROUP(X) ((X)->rt_cycgroup) 7200Sstevel@tonic-gate #define STDEV(X) ((X)->rt_stdev) 7210Sstevel@tonic-gate #define STINO(X) ((X)->rt_stino) 7220Sstevel@tonic-gate #define ORIGNAME(X) ((X)->rt_origname) 7230Sstevel@tonic-gate #define DIRSZ(X) ((X)->rt_dirsz) 7240Sstevel@tonic-gate #define COPY(X) ((X)->rt_copy) 7250Sstevel@tonic-gate #define AUDITORS(X) ((X)->rt_auditors) 7260Sstevel@tonic-gate #define AUDINFO(X) ((X)->rt_audinfo) 7270Sstevel@tonic-gate #define SYMINFO(X) ((X)->rt_syminfo) 7280Sstevel@tonic-gate #define INITARRAY(X) ((X)->rt_initarray) 7290Sstevel@tonic-gate #define FINIARRAY(X) ((X)->rt_finiarray) 7300Sstevel@tonic-gate #define PREINITARRAY(X) ((X)->rt_preinitarray) 7310Sstevel@tonic-gate #define MMAPS(X) ((X)->rt_mmaps) 7320Sstevel@tonic-gate #define MMAPCNT(X) ((X)->rt_mmapcnt) 7330Sstevel@tonic-gate #define INITARRAYSZ(X) ((X)->rt_initarraysz) 7340Sstevel@tonic-gate #define FINIARRAYSZ(X) ((X)->rt_finiarraysz) 7350Sstevel@tonic-gate #define PREINITARRAYSZ(X) ((X)->rt_preinitarraysz) 7360Sstevel@tonic-gate #define DYNINFO(X) ((X)->rt_dyninfo) 7370Sstevel@tonic-gate #define DYNINFOCNT(X) ((X)->rt_dyninfocnt) 7380Sstevel@tonic-gate #define RELACOUNT(X) ((X)->rt_relacount) 7390Sstevel@tonic-gate #define IDX(X) ((X)->rt_idx) 7400Sstevel@tonic-gate #define LAZY(X) ((X)->rt_lazy) 7410Sstevel@tonic-gate #define CONDVAR(X) ((X)->rt_condvar) 7420Sstevel@tonic-gate #define CNTL(X) ((X)->rt_cntl) 7430Sstevel@tonic-gate #define HWCAP(X) ((X)->rt_hwcap) 7440Sstevel@tonic-gate #define SFCAP(X) ((X)->rt_sfcap) 7450Sstevel@tonic-gate #define THREADID(X) ((X)->rt_threadid) 7460Sstevel@tonic-gate 747280Srie /* 748280Srie * Flags for tsorting. 749280Srie */ 750280Srie #define RT_SORT_FWD 0x01 /* topological sort (.fini) */ 751280Srie #define RT_SORT_REV 0x02 /* reverse topological sort (.init) */ 752280Srie #define RT_SORT_DELETE 0x10 /* process FLG_RT_DELNEED objects */ 753280Srie /* only (called via dlclose()) */ 7540Sstevel@tonic-gate /* 7550Sstevel@tonic-gate * Flags for lookup_sym (and hence find_sym) routines. 7560Sstevel@tonic-gate */ 7570Sstevel@tonic-gate #define LKUP_DEFT 0x0000 /* simple lookup request */ 7580Sstevel@tonic-gate #define LKUP_SPEC 0x0001 /* special ELF lookup (allows address */ 7590Sstevel@tonic-gate /* resolutions to plt[] entries) */ 7600Sstevel@tonic-gate #define LKUP_LDOT 0x0002 /* indicates the original A_OUT */ 7610Sstevel@tonic-gate /* symbol had a leading `.' */ 7620Sstevel@tonic-gate #define LKUP_FIRST 0x0004 /* lookup symbol in first link map */ 7630Sstevel@tonic-gate /* only */ 7640Sstevel@tonic-gate #define LKUP_COPY 0x0008 /* lookup symbol for a COPY reloc, do */ 7650Sstevel@tonic-gate /* not bind to symbol at head */ 7660Sstevel@tonic-gate #define LKUP_ALLCNTLIST 0x0010 /* lookup symbol in all control lists */ 7670Sstevel@tonic-gate #define LKUP_SELF 0x0020 /* lookup symbol in ourself - undef */ 7680Sstevel@tonic-gate /* is valid */ 7690Sstevel@tonic-gate #define LKUP_WEAK 0x0040 /* relocation reference is weak */ 7700Sstevel@tonic-gate #define LKUP_NEXT 0x0080 /* request originates from RTLD_NEXT */ 7710Sstevel@tonic-gate #define LKUP_NODESCENT 0x0100 /* don't descend through dependencies */ 7720Sstevel@tonic-gate #define LKUP_NOFALBACK 0x0200 /* don't fall back to loading */ 7730Sstevel@tonic-gate /* pending lazy dependencies */ 7740Sstevel@tonic-gate #define LKUP_DIRECT 0x0400 /* direct binding request */ 775502Srie #define LKUP_SYMNDX 0x0800 /* establish symbol index */ 7760Sstevel@tonic-gate 7770Sstevel@tonic-gate /* 7780Sstevel@tonic-gate * Data structure for calling lookup_sym() 7790Sstevel@tonic-gate */ 7800Sstevel@tonic-gate typedef struct { 7810Sstevel@tonic-gate const char *sl_name; /* symbol name */ 7820Sstevel@tonic-gate Rt_map *sl_cmap; /* callers link-map */ 7830Sstevel@tonic-gate Rt_map *sl_imap; /* initial link-map to search */ 7840Sstevel@tonic-gate ulong_t sl_hash; /* symbol hash value */ 7850Sstevel@tonic-gate ulong_t sl_rsymndx; /* referencing reloc symndx */ 7860Sstevel@tonic-gate uint_t sl_flags; /* lookup flags */ 7870Sstevel@tonic-gate } Slookup; 7880Sstevel@tonic-gate 7890Sstevel@tonic-gate 7900Sstevel@tonic-gate typedef enum { 7910Sstevel@tonic-gate PLT_T_NONE = 0, 7920Sstevel@tonic-gate PLT_T_21D, 7930Sstevel@tonic-gate PLT_T_24D, 7940Sstevel@tonic-gate PLT_T_U32, 7950Sstevel@tonic-gate PLT_T_U44, 7960Sstevel@tonic-gate PLT_T_FULL, 7970Sstevel@tonic-gate PLT_T_FAR, 7980Sstevel@tonic-gate PLT_T_NUM /* Must be last */ 7990Sstevel@tonic-gate } Pltbindtype; 8000Sstevel@tonic-gate 8010Sstevel@tonic-gate /* 8020Sstevel@tonic-gate * Prototypes. 8030Sstevel@tonic-gate */ 8040Sstevel@tonic-gate extern Lm_list lml_main; /* main's link map list */ 8050Sstevel@tonic-gate extern Lm_list lml_rtld; /* rtld's link map list */ 8060Sstevel@tonic-gate extern Lm_list *lml_list[]; 8070Sstevel@tonic-gate 8080Sstevel@tonic-gate extern Pltbindtype elf_plt_write(uintptr_t, uintptr_t, void *, uintptr_t, 8090Sstevel@tonic-gate Xword); 8100Sstevel@tonic-gate extern Rt_map *is_so_loaded(Lm_list *, const char *, int); 8110Sstevel@tonic-gate extern Sym *lookup_sym(Slookup *, Rt_map **, uint_t *); 8120Sstevel@tonic-gate extern int rt_dldump(Rt_map *, const char *, int, Addr); 8130Sstevel@tonic-gate 8140Sstevel@tonic-gate #ifdef __cplusplus 8150Sstevel@tonic-gate } 8160Sstevel@tonic-gate #endif 8170Sstevel@tonic-gate 8180Sstevel@tonic-gate #endif /* _RTLD_H */ 819