17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _RTLD_H 287c478bd9Sstevel@tonic-gate #define _RTLD_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate /* 337c478bd9Sstevel@tonic-gate * Global include file for the runtime linker support library. 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate #include <time.h> 367c478bd9Sstevel@tonic-gate #include <sgs.h> 377c478bd9Sstevel@tonic-gate #include <thread.h> 387c478bd9Sstevel@tonic-gate #include <synch.h> 397c478bd9Sstevel@tonic-gate #include <machdep.h> 407c478bd9Sstevel@tonic-gate #include <sys/avl.h> 417c478bd9Sstevel@tonic-gate #include <alist.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 447c478bd9Sstevel@tonic-gate #include <inttypes.h> 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #ifdef __cplusplus 487c478bd9Sstevel@tonic-gate extern "C" { 497c478bd9Sstevel@tonic-gate #endif 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* 537c478bd9Sstevel@tonic-gate * Linked list of directories or filenames (built from colon separated string). 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate typedef struct pnode { 567c478bd9Sstevel@tonic-gate const char *p_name; 577c478bd9Sstevel@tonic-gate const char *p_oname; 587c478bd9Sstevel@tonic-gate size_t p_len; 597c478bd9Sstevel@tonic-gate uint_t p_orig; 607c478bd9Sstevel@tonic-gate void *p_info; 617c478bd9Sstevel@tonic-gate struct pnode *p_next; 627c478bd9Sstevel@tonic-gate } Pnode; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef struct rt_map Rt_map; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 677c478bd9Sstevel@tonic-gate * A binding descriptor. Establishes the binding relationship between two 687c478bd9Sstevel@tonic-gate * objects, the caller (originator and the dependency (destination). 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate typedef struct { 717c478bd9Sstevel@tonic-gate Rt_map *b_caller; /* caller (originator) of a binding */ 727c478bd9Sstevel@tonic-gate Rt_map *b_depend; /* dependency (destination) of a */ 737c478bd9Sstevel@tonic-gate /* binding */ 747c478bd9Sstevel@tonic-gate uint_t b_flags; /* relationship of caller to the */ 757c478bd9Sstevel@tonic-gate /* dependency */ 767c478bd9Sstevel@tonic-gate } Bnd_desc; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate #define BND_NEEDED 0x0001 /* caller NEEDED the dependency */ 797c478bd9Sstevel@tonic-gate #define BND_REFER 0x0002 /* caller relocation references the */ 807c478bd9Sstevel@tonic-gate /* dependency */ 81dffec89cSrie #define BND_FILTER 0x0004 /* pseudo binding to identify filter */ 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * Private structure for communication between rtld_db and rtld. 857c478bd9Sstevel@tonic-gate * 867c478bd9Sstevel@tonic-gate * We must bump the version number whenever a update in one of 877c478bd9Sstevel@tonic-gate * the structures/fields that rtld_db reads is updated. This hopefully 887c478bd9Sstevel@tonic-gate * permits rtld_db implementations of the future recognize corefiles 897c478bd9Sstevel@tonic-gate * produced on older system and deal accordingly. 907c478bd9Sstevel@tonic-gate * 917c478bd9Sstevel@tonic-gate * As of version 'RTLD_DB_VERSION <= 2' the following fields 927c478bd9Sstevel@tonic-gate * were valid for core file examination (basically the public 937c478bd9Sstevel@tonic-gate * Link_map): 947c478bd9Sstevel@tonic-gate * 957c478bd9Sstevel@tonic-gate * ADDR() 967c478bd9Sstevel@tonic-gate * NAME() 977c478bd9Sstevel@tonic-gate * DYN() 987c478bd9Sstevel@tonic-gate * NEXT() 997c478bd9Sstevel@tonic-gate * PREV() 1007c478bd9Sstevel@tonic-gate * 1017c478bd9Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION3 1027c478bd9Sstevel@tonic-gate * 1037c478bd9Sstevel@tonic-gate * PATHNAME() 1047c478bd9Sstevel@tonic-gate * PADSTART() 1057c478bd9Sstevel@tonic-gate * PADIMLEN() 1067c478bd9Sstevel@tonic-gate * MSIZE() 1077c478bd9Sstevel@tonic-gate * FLAGS() 1087c478bd9Sstevel@tonic-gate * FLAGS1() 1097c478bd9Sstevel@tonic-gate * 1107c478bd9Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION4 1117c478bd9Sstevel@tonic-gate * 1127c478bd9Sstevel@tonic-gate * TLSMODID() 1137c478bd9Sstevel@tonic-gate * 1147c478bd9Sstevel@tonic-gate * Valid fields for RTLD_DB_VERSION5 1157c478bd9Sstevel@tonic-gate * 1167c478bd9Sstevel@tonic-gate * Added rtld_flags & FLG_RT_RELOCED to stable flags range 1177c478bd9Sstevel@tonic-gate * 1187c478bd9Sstevel@tonic-gate */ 1197c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION1 1 /* base version level - used for core */ 1207c478bd9Sstevel@tonic-gate /* file examination */ 1217c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION2 2 /* minor revision - not relavant for */ 1227c478bd9Sstevel@tonic-gate /* core files */ 1237c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION3 3 1247c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION4 4 1257c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION5 5 1267c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION R_RTLDDB_VERSION5 /* current version */ 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate typedef struct rtld_db_priv { 1297c478bd9Sstevel@tonic-gate struct r_debug rtd_rdebug; /* original r_debug structure */ 1307c478bd9Sstevel@tonic-gate Word rtd_version; /* version no. */ 1317c478bd9Sstevel@tonic-gate size_t rtd_objpad; /* padding around mmap()ed objects */ 1327c478bd9Sstevel@tonic-gate List * rtd_dynlmlst; /* pointer to Dynlm_list */ 1337c478bd9Sstevel@tonic-gate } Rtld_db_priv; 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 1367c478bd9Sstevel@tonic-gate typedef struct rtld_db_priv32 { 1377c478bd9Sstevel@tonic-gate struct r_debug32 rtd_rdebug; /* original r_debug structure */ 1387c478bd9Sstevel@tonic-gate Elf32_Word rtd_version; /* version no. */ 1397c478bd9Sstevel@tonic-gate Elf32_Word rtd_objpad; /* padding around mmap()ed objects */ 1407c478bd9Sstevel@tonic-gate Elf32_Addr rtd_dynlmlst; /* pointer to Dynlm_list */ 1417c478bd9Sstevel@tonic-gate } Rtld_db_priv32; 1427c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * Link map list definition. Link-maps are used to describe each loaded object. 1477c478bd9Sstevel@tonic-gate * Lists of these link-maps describe the various namespaces within a process. 1487c478bd9Sstevel@tonic-gate * The process executable and its dependencies are maintained on the lml_main 1497c478bd9Sstevel@tonic-gate * list. The runtime linker, and its dependencies are maintained on the 1507c478bd9Sstevel@tonic-gate * lml_rtld list. Additional lists can be created (see dlmopen()) for such 1517c478bd9Sstevel@tonic-gate * things as auditors and their dependencies. 1527c478bd9Sstevel@tonic-gate * 1537c478bd9Sstevel@tonic-gate * Each link-map list maintains an Alist of one, or more, linked lists of 1547c478bd9Sstevel@tonic-gate * link-maps. For backward compatibility, the lm_head/lm_tail elements are 1557c478bd9Sstevel@tonic-gate * initialized to the first linked-list of link-maps: 1567c478bd9Sstevel@tonic-gate * 1577c478bd9Sstevel@tonic-gate * Lm_list 1587c478bd9Sstevel@tonic-gate * ---------- 1597c478bd9Sstevel@tonic-gate * | lm_tail | ------------------------------------ 1607c478bd9Sstevel@tonic-gate * | lm_head | -------------------- | 1617c478bd9Sstevel@tonic-gate * | | | Rt_map | Rt_map 1627c478bd9Sstevel@tonic-gate * | | | ------ | ------ 1637c478bd9Sstevel@tonic-gate * | | Alist --> | | |--> | | 1647c478bd9Sstevel@tonic-gate * | | --------- | | | -- | | 1657c478bd9Sstevel@tonic-gate * | lm_lists | ----> | | | | | --> | | 1667c478bd9Sstevel@tonic-gate * | | |---------| | | | | | | 1677c478bd9Sstevel@tonic-gate * | | | lc_head | -- ------ | ------ 1687c478bd9Sstevel@tonic-gate * | | | lc_tail | ------------------ 1697c478bd9Sstevel@tonic-gate * | | |---------| 1707c478bd9Sstevel@tonic-gate * | lc_head | 1717c478bd9Sstevel@tonic-gate * | lc_tail | 1727c478bd9Sstevel@tonic-gate * |---------| 1737c478bd9Sstevel@tonic-gate * 1747c478bd9Sstevel@tonic-gate * Multiple link-map lists exist to support the addition of lazy loaded 1757c478bd9Sstevel@tonic-gate * families, filtee families, and dlopen() families. The intent of these 1767c478bd9Sstevel@tonic-gate * lists is to insure that a family of objects that are to be loaded are 1777c478bd9Sstevel@tonic-gate * fully relocatable, and hence usable, before they become part of the main 1787c478bd9Sstevel@tonic-gate * (al_data[0]) link-map control list. This main link-map control list is 1797c478bd9Sstevel@tonic-gate * the only list in existence when control is transferred to user code. 1807c478bd9Sstevel@tonic-gate * 1817c478bd9Sstevel@tonic-gate * During process initialization, the dynamic executable and its non-lazy 1827c478bd9Sstevel@tonic-gate * dependencies are maintained on al_data[0]. If a new object is loaded, then 1837c478bd9Sstevel@tonic-gate * this object is added to the next available control list [1], typically 1847c478bd9Sstevel@tonic-gate * al_data[1]. Any dependencies of this object that have not already been 1857c478bd9Sstevel@tonic-gate * loaded are added to the same control list. Once all of the objects on the 1867c478bd9Sstevel@tonic-gate * new control list have been successfully relocated, the objects are moved from 1877c478bd9Sstevel@tonic-gate * the new control list to the highest control list to which objects of the new 1887c478bd9Sstevel@tonic-gate * control list bound to, typically al_data[1] to al_data[0]. 1897c478bd9Sstevel@tonic-gate * 1907c478bd9Sstevel@tonic-gate * Each loading scenario can be broken down as follows: 1917c478bd9Sstevel@tonic-gate * 1927c478bd9Sstevel@tonic-gate * setup() - only the initial link-map control list is used: 1937c478bd9Sstevel@tonic-gate * i. create al_data[0] 1947c478bd9Sstevel@tonic-gate * ii. add new link-map for main on al_data[0] 1957c478bd9Sstevel@tonic-gate * iii. analyze al_data[0] to add all non-lazy dependencies 1967c478bd9Sstevel@tonic-gate * iv. relocate al_data[0] dependencies. 1977c478bd9Sstevel@tonic-gate * 1987c478bd9Sstevel@tonic-gate * dlopen() - the initiator can only be the initial link-map control list: 1997c478bd9Sstevel@tonic-gate * i. create al_data[1] from caller al_data[0] 2007c478bd9Sstevel@tonic-gate * ii. add new link-map for the dlopen'ed object on al_data[1] 2017c478bd9Sstevel@tonic-gate * iii. analyze al_data[1] to add all non-lazy dependencies 2027c478bd9Sstevel@tonic-gate * iv. relocate al_data[1] dependencies, and move to al_data[0]. 2037c478bd9Sstevel@tonic-gate * 2047c478bd9Sstevel@tonic-gate * filtee and lazy loading processing - the initiator can be any link-map 2057c478bd9Sstevel@tonic-gate * control list that is being relocated: 2067c478bd9Sstevel@tonic-gate * i. create al_data[y] from caller al_data[x] 2077c478bd9Sstevel@tonic-gate * ii. add new link-map for the new object on al_data[y] 2087c478bd9Sstevel@tonic-gate * iii. analyze al_data[y] to add all non-lazy dependencies 2097c478bd9Sstevel@tonic-gate * iv. relocate al_data[y] dependencies, and move to al_data[x]. 2107c478bd9Sstevel@tonic-gate * 2117c478bd9Sstevel@tonic-gate * This Alist therefore maintains a stack of link-map control lists. The newest 2127c478bd9Sstevel@tonic-gate * link-map control list can locate symbols within any of the former lists, 2137c478bd9Sstevel@tonic-gate * however, control is not passed to a former list until the newest lists 2147c478bd9Sstevel@tonic-gate * processing is complete. Thus, objects can't bind to new objects until they 2157c478bd9Sstevel@tonic-gate * have been fully analyzed and relocated. 2167c478bd9Sstevel@tonic-gate * 2177c478bd9Sstevel@tonic-gate * [1] Note, additional link-map control list creation occurs after the head 2187c478bd9Sstevel@tonic-gate * link-map object (typically the dynamic executable) has been relocated. This 2197c478bd9Sstevel@tonic-gate * staging is required to satisfy the binding requirements of copy relocations. 2207c478bd9Sstevel@tonic-gate * Copy relocations, effectively, transfer the bindings of the copied data 2217c478bd9Sstevel@tonic-gate * (say _iob in libc.so.1) to the copy location (_iob in the application). 2227c478bd9Sstevel@tonic-gate * Thus an object that might bind to the original copy data must be redirected 2237c478bd9Sstevel@tonic-gate * to the copy reference. As the knowledge of a copy relocation having taken 2247c478bd9Sstevel@tonic-gate * place is only known after relocating the application, link-map control list 2257c478bd9Sstevel@tonic-gate * additions are suspended until after this relocation has completed. 2267c478bd9Sstevel@tonic-gate */ 2277c478bd9Sstevel@tonic-gate typedef struct { 2287c478bd9Sstevel@tonic-gate Rt_map *lc_head; 2297c478bd9Sstevel@tonic-gate Rt_map *lc_tail; 2307c478bd9Sstevel@tonic-gate Alist *lc_now; /* pending promoted bind-now objects */ 2317c478bd9Sstevel@tonic-gate uint_t lc_flags; 2327c478bd9Sstevel@tonic-gate } Lm_cntl; 2337c478bd9Sstevel@tonic-gate 2347c478bd9Sstevel@tonic-gate #define LMC_FLG_ANALYZING 0x01 /* control list is being analyzed */ 2357c478bd9Sstevel@tonic-gate #define LMC_FLG_RELOCATING 0x02 /* control list is being relocated */ 2367c478bd9Sstevel@tonic-gate #define LMC_FLG_REANALYZE 0x04 /* repeat analysis (established when */ 2377c478bd9Sstevel@tonic-gate /* interposers are added */ 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate typedef struct { 2407c478bd9Sstevel@tonic-gate /* 2417c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 2427c478bd9Sstevel@tonic-gate */ 2437c478bd9Sstevel@tonic-gate Rt_map *lm_head; /* linked list pointers to active */ 2447c478bd9Sstevel@tonic-gate Rt_map *lm_tail; /* link-map list */ 2457c478bd9Sstevel@tonic-gate Alist *lm_handle; /* not used by rtld_db - but spacing */ 2467c478bd9Sstevel@tonic-gate /* is required for flags */ 2477c478bd9Sstevel@tonic-gate Word lm_flags; 2487c478bd9Sstevel@tonic-gate /* 2497c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 2507c478bd9Sstevel@tonic-gate */ 2517c478bd9Sstevel@tonic-gate int (*lm_peh)(); /* atexit() preexec_exit_handlers */ 2527c478bd9Sstevel@tonic-gate Rt_map *lm_peh_lmp; /* and object that contributed them */ 2537c478bd9Sstevel@tonic-gate Rt_map *lm_info_lmp; /* the first object with rtld_info */ 2547c478bd9Sstevel@tonic-gate Alist *lm_rtldinfo; /* list of RTLDINFO tables */ 2557c478bd9Sstevel@tonic-gate Audit_list *lm_alp; /* audit list descripter */ 2567c478bd9Sstevel@tonic-gate avl_tree_t *lm_fpavl; /* avl tree of objects loaded */ 2577c478bd9Sstevel@tonic-gate Alist *lm_lists; /* active and pending link-map lists */ 25841072f3cSrie char ***lm_environ; /* pointer to environment array */ 2597c478bd9Sstevel@tonic-gate Word lm_tflags; /* transferable flags */ 2607c478bd9Sstevel@tonic-gate int lm_obj; /* total number of objs on link-map */ 2617c478bd9Sstevel@tonic-gate int lm_init; /* new obj since last init processing */ 2627c478bd9Sstevel@tonic-gate int lm_lazy; /* obj with pending lazy dependencies */ 2637c478bd9Sstevel@tonic-gate } Lm_list; 2647c478bd9Sstevel@tonic-gate 2657c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 2667c478bd9Sstevel@tonic-gate typedef struct { 2677c478bd9Sstevel@tonic-gate /* 2687c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 2697c478bd9Sstevel@tonic-gate */ 2707c478bd9Sstevel@tonic-gate Elf32_Addr lm_head; 2717c478bd9Sstevel@tonic-gate Elf32_Addr lm_tail; 2727c478bd9Sstevel@tonic-gate Elf32_Addr lm_handle; 2737c478bd9Sstevel@tonic-gate Elf32_Word lm_flags; 2747c478bd9Sstevel@tonic-gate /* 2757c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 2767c478bd9Sstevel@tonic-gate */ 2777c478bd9Sstevel@tonic-gate Elf32_Addr lm_peh; 2787c478bd9Sstevel@tonic-gate Elf32_Addr lm_peh_lmp; 2797c478bd9Sstevel@tonic-gate Elf32_Addr lm_info_lmp; 2807c478bd9Sstevel@tonic-gate Elf32_Addr lm_alp; 2817c478bd9Sstevel@tonic-gate Elf32_Addr lm_fpavl; 2827c478bd9Sstevel@tonic-gate Elf32_Addr lm_lists; 28341072f3cSrie Elf32_Addr lm_environ; 2847c478bd9Sstevel@tonic-gate Elf32_Word lm_tflags; 2857c478bd9Sstevel@tonic-gate int lm_obj; 2867c478bd9Sstevel@tonic-gate int lm_init; 2877c478bd9Sstevel@tonic-gate int lm_lazy; 2887c478bd9Sstevel@tonic-gate } Lm_list32; 2897c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 2907c478bd9Sstevel@tonic-gate 2917c478bd9Sstevel@tonic-gate /* 2927c478bd9Sstevel@tonic-gate * Possible Link_map list flags (Lm_list.lm_flags) 2937c478bd9Sstevel@tonic-gate */ 2947c478bd9Sstevel@tonic-gate /* 2957c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 2967c478bd9Sstevel@tonic-gate */ 2977c478bd9Sstevel@tonic-gate #define LML_FLG_BASELM 0x00000001 /* primary link-map */ 2987c478bd9Sstevel@tonic-gate #define LML_FLG_RTLDLM 0x00000002 /* rtld link-map */ 2997c478bd9Sstevel@tonic-gate /* 3007c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 3017c478bd9Sstevel@tonic-gate */ 3027c478bd9Sstevel@tonic-gate #define LML_FLG_NOAUDIT 0x00000004 /* symbol auditing disabled */ 3037c478bd9Sstevel@tonic-gate #define LML_FLG_PLTREL 0x00000008 /* deferred plt relocation */ 3047c478bd9Sstevel@tonic-gate /* initialization */ 3057c478bd9Sstevel@tonic-gate /* (ld.so.1 only) */ 3067c478bd9Sstevel@tonic-gate #define LML_FLG_HOLDLOCK 0x00000010 /* hold the rtld mutex lock */ 3077c478bd9Sstevel@tonic-gate #define LML_FLG_ENVIRON 0x00000020 /* environ var initialized */ 3087c478bd9Sstevel@tonic-gate #define LML_FLG_INTRPOSE 0x00000040 /* interposing objs on list */ 3097c478bd9Sstevel@tonic-gate #define LML_FLG_LOCAUDIT 0x00000080 /* local auditors exists for */ 3107c478bd9Sstevel@tonic-gate /* this link-map list */ 3117c478bd9Sstevel@tonic-gate #define LML_FLG_LOADAVAIL 0x00000100 /* load anything available */ 3127c478bd9Sstevel@tonic-gate #define LML_FLG_IGNRELERR 0x00000200 /* ignore relocation errors - */ 3137c478bd9Sstevel@tonic-gate /* internal for crle(1) */ 3147c478bd9Sstevel@tonic-gate #define LML_FLG_DBNOTIF 0x00000400 /* binding activity going on */ 315dffec89cSrie #define LML_FLG_STARTREL 0x00000800 /* relocation started */ 316dffec89cSrie #define LML_FLG_ATEXIT 0x00001000 /* atexit processing */ 317dffec89cSrie #define LML_FLG_OBJADDED 0x00002000 /* object(s) added */ 318dffec89cSrie #define LML_FLG_OBJDELETED 0x00004000 /* object(s) deleted */ 319dffec89cSrie #define LML_FLG_OBJREEVAL 0x00008000 /* existing object(s) needs */ 320dffec89cSrie /* tsort reevaluation */ 3217c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_LDDSTUB 0x00100000 /* identify lddstub */ 3227c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_ENABLE 0x00200000 /* tracing enabled (ldd) */ 3237c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_WARN 0x00400000 /* print warnings for undefs */ 3247c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_VERBOSE 0x00800000 /* verbose (versioning) trace */ 3257c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_SEARCH 0x01000000 /* trace search paths */ 3267c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_UNREF 0x02000000 /* trace unreferenced */ 3277c478bd9Sstevel@tonic-gate /* dependencies */ 3287c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_UNUSED 0x04000000 /* trace unused dependencies */ 3297c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_INIT 0x08000000 /* print .init order */ 3307c478bd9Sstevel@tonic-gate 3317c478bd9Sstevel@tonic-gate #define LML_MSK_TRC 0xfff00000 /* tracing mask */ 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate /* 3347c478bd9Sstevel@tonic-gate * Possible Link_map transferable flags (Lm_list.lm_tflags), i.e., link-map 3357c478bd9Sstevel@tonic-gate * list flags that can be propagated to any new link-map list created. 3367c478bd9Sstevel@tonic-gate */ 3377c478bd9Sstevel@tonic-gate #define LML_TFLG_NOLAZYLD 0x00000001 /* lazy loading disabled */ 3387c478bd9Sstevel@tonic-gate #define LML_TFLG_NODIRECT 0x00000002 /* direct bindings disabled */ 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate #define LML_TFLG_LOADFLTR 0x00000008 /* trigger filtee loading */ 3417c478bd9Sstevel@tonic-gate 3427c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_PREINIT 0x00100000 /* preinit (audit) exists */ 3437c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJSEARCH 0x00200000 /* objsearch (audit) exists */ 3447c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJOPEN 0x00400000 /* objopen (audit) exists */ 3457c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJFILTER 0x00800000 /* objfilter (audit) exists */ 3467c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_OBJCLOSE 0x01000000 /* objclose (audit) exists */ 3477c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_SYMBIND 0x02000000 /* symbind (audit) exists */ 3487c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_PLTENTER 0x04000000 /* pltenter (audit) exists */ 3497c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_PLTEXIT 0x08000000 /* pltexit (audit) exists */ 3507c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_ACTIVITY 0x10000000 /* activity (audit) exists */ 3517c478bd9Sstevel@tonic-gate 3527c478bd9Sstevel@tonic-gate /* 3537c478bd9Sstevel@tonic-gate * NOTE: Audit flags have duplicated FLAGS1() values. If more audit flags are 3547c478bd9Sstevel@tonic-gate * added, update the FLAGS1() reservation FL1_AUD_RS_STR to FL1_AUD_RS_END 3557c478bd9Sstevel@tonic-gate * defined later. 3567c478bd9Sstevel@tonic-gate */ 3577c478bd9Sstevel@tonic-gate #define LML_TFLG_AUD_MASK 0xfff00000 /* audit interfaces mask */ 3587c478bd9Sstevel@tonic-gate 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate /* 3617c478bd9Sstevel@tonic-gate * Information for dlopen(), dlsym(), and dlclose() on libraries linked by rtld. 3627c478bd9Sstevel@tonic-gate * Each shared object referred from a dlopen call has an associated group 3637c478bd9Sstevel@tonic-gate * handle structure returned that describes a group of one or more objects. 3647c478bd9Sstevel@tonic-gate */ 3657c478bd9Sstevel@tonic-gate typedef struct { 3667c478bd9Sstevel@tonic-gate Alist * gh_depends; /* handle dependency list */ 3677c478bd9Sstevel@tonic-gate Rt_map * gh_owner; /* handle owner and the link-map */ 3687c478bd9Sstevel@tonic-gate uint_t gh_refcnt; /* handle reference count */ 3697c478bd9Sstevel@tonic-gate uint_t gh_flags; /* handle flags */ 3707c478bd9Sstevel@tonic-gate } Grp_hdl; 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate #define GPH_ZERO 0x0001 /* special handle for dlopen(0) */ 3737c478bd9Sstevel@tonic-gate #define GPH_LDSO 0x0002 /* special handle for ld.so.1 */ 3747c478bd9Sstevel@tonic-gate #define GPH_FIRST 0x0004 /* dlsym() can only use originating */ 3757c478bd9Sstevel@tonic-gate /* dependency */ 3767c478bd9Sstevel@tonic-gate #define GPH_PARENT 0x0008 /* assign caller as a parent */ 3777c478bd9Sstevel@tonic-gate #define GPH_FILTEE 0x0010 /* handle used to specify a filtee */ 3787c478bd9Sstevel@tonic-gate #define GPH_INITIAL 0x0020 /* handle is initialized */ 3797c478bd9Sstevel@tonic-gate #define GPH_STICKY 0x0040 /* handle is unreferenced, but should */ 3807c478bd9Sstevel@tonic-gate /* not trigger object removal */ 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate /* 3837c478bd9Sstevel@tonic-gate * A group descriptor. A group handle (Grp_hdl) refers to a group of objects, 3847c478bd9Sstevel@tonic-gate * each object, and its relationship to the handle, is maintained within a 3857c478bd9Sstevel@tonic-gate * group descriptor. 3867c478bd9Sstevel@tonic-gate */ 3877c478bd9Sstevel@tonic-gate typedef struct { 3887c478bd9Sstevel@tonic-gate Rt_map * gd_depend; /* dependency */ 3897c478bd9Sstevel@tonic-gate uint_t gd_flags; /* dependency flags */ 3907c478bd9Sstevel@tonic-gate } Grp_desc; 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate #define GPD_AVAIL 0x0001 /* dependency available to dlsym() */ 3937c478bd9Sstevel@tonic-gate #define GPD_ADDEPS 0x0002 /* dependencies of this dependency */ 3947c478bd9Sstevel@tonic-gate /* should be added to handle */ 3957c478bd9Sstevel@tonic-gate #define GPD_PARENT 0x0004 /* dependency is a parent */ 3967c478bd9Sstevel@tonic-gate #define GPD_FILTER 0x0008 /* dependency is our filter */ 3977c478bd9Sstevel@tonic-gate #define GPD_REMOVE 0x1000 /* descriptor is a candidate for */ 3987c478bd9Sstevel@tonic-gate /* removal from the group */ 3997c478bd9Sstevel@tonic-gate 4007c478bd9Sstevel@tonic-gate /* 4017c478bd9Sstevel@tonic-gate * Define threading structures. For compatibility with libthread (T1_VERSION 1 4027c478bd9Sstevel@tonic-gate * and TI_VERSION 2) our locking structure is sufficient to hold a mutex or a 4037c478bd9Sstevel@tonic-gate * readers/writers lock. 4047c478bd9Sstevel@tonic-gate */ 4057c478bd9Sstevel@tonic-gate typedef struct { 4067c478bd9Sstevel@tonic-gate union { 4077c478bd9Sstevel@tonic-gate mutex_t l_mutex; 4087c478bd9Sstevel@tonic-gate rwlock_t l_rwlock; 4097c478bd9Sstevel@tonic-gate } u; 4107c478bd9Sstevel@tonic-gate } Rt_lock; 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate typedef cond_t Rt_cond; 4137c478bd9Sstevel@tonic-gate 4147c478bd9Sstevel@tonic-gate /* 4157c478bd9Sstevel@tonic-gate * Define a dynamic section information descriptor. This parallels the entries 4167c478bd9Sstevel@tonic-gate * in the .dynamic section and holds auxiliary information to implement lazy 4177c478bd9Sstevel@tonic-gate * loading and filtee processing. 4187c478bd9Sstevel@tonic-gate */ 4197c478bd9Sstevel@tonic-gate typedef struct { 4207c478bd9Sstevel@tonic-gate uint_t di_flags; 4217c478bd9Sstevel@tonic-gate void *di_info; 4227c478bd9Sstevel@tonic-gate } Dyninfo; 4237c478bd9Sstevel@tonic-gate 4247c478bd9Sstevel@tonic-gate #define FLG_DI_STDFLTR 0x00001 /* .dynamic entry for DT_FILTER */ 4257c478bd9Sstevel@tonic-gate #define FLG_DI_AUXFLTR 0x00002 /* .dynamic entry for DT_AUXILIARY */ 4267c478bd9Sstevel@tonic-gate #define FLG_DI_SYMFLTR 0x00004 /* .dynamic entry for DT_SYMFILTER */ 4277c478bd9Sstevel@tonic-gate /* and DT_SYMAUXILIARY */ 4287c478bd9Sstevel@tonic-gate #define MSK_DI_FILTER 0x0000f /* mask for all filter possibilities */ 4297c478bd9Sstevel@tonic-gate 4307c478bd9Sstevel@tonic-gate #define FLG_DI_NEEDED 0x00010 /* entry represents a dependency */ 4317c478bd9Sstevel@tonic-gate #define FLG_DI_GROUP 0x00020 /* open dependency as a group */ 4327c478bd9Sstevel@tonic-gate #define FLG_DI_PROCESSD 0x00040 /* entry has been processed */ 4337c478bd9Sstevel@tonic-gate 4347c478bd9Sstevel@tonic-gate /* 4357c478bd9Sstevel@tonic-gate * Data Structure to track AVL tree for pathnames of objects 4367c478bd9Sstevel@tonic-gate * loaded into memory 4377c478bd9Sstevel@tonic-gate */ 4387c478bd9Sstevel@tonic-gate typedef struct { 4397c478bd9Sstevel@tonic-gate const char *fpn_name; /* object name */ 4407c478bd9Sstevel@tonic-gate Rt_map *fpn_lmp; /* object link-map */ 4417c478bd9Sstevel@tonic-gate avl_node_t fpn_avl; /* avl book-keeping (see SGSOFFSETOF) */ 4427c478bd9Sstevel@tonic-gate uint_t fpn_hash; /* object name hash value */ 4437c478bd9Sstevel@tonic-gate } FullpathNode; 4447c478bd9Sstevel@tonic-gate 4457c478bd9Sstevel@tonic-gate /* 4467c478bd9Sstevel@tonic-gate * Define a mapping structure, which is maintained to describe each mapping 4477c478bd9Sstevel@tonic-gate * of an object, ie. the text segment, data segment, bss segment, etc. 4487c478bd9Sstevel@tonic-gate */ 4497c478bd9Sstevel@tonic-gate typedef struct { 4507c478bd9Sstevel@tonic-gate caddr_t m_vaddr; /* mapping address */ 4517c478bd9Sstevel@tonic-gate size_t m_fsize; /* backing file size */ 4527c478bd9Sstevel@tonic-gate size_t m_msize; /* mapping size */ 4537c478bd9Sstevel@tonic-gate int m_perm; /* mapping permissions */ 4547c478bd9Sstevel@tonic-gate } Mmap; 4557c478bd9Sstevel@tonic-gate 4567c478bd9Sstevel@tonic-gate /* 4577c478bd9Sstevel@tonic-gate * Link-map definition. 4587c478bd9Sstevel@tonic-gate */ 4597c478bd9Sstevel@tonic-gate struct rt_map { 4607c478bd9Sstevel@tonic-gate /* 4617c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 4627c478bd9Sstevel@tonic-gate */ 4637c478bd9Sstevel@tonic-gate Link_map rt_public; /* public data */ 4647c478bd9Sstevel@tonic-gate char *rt_pathname; /* full pathname of loaded object */ 4657c478bd9Sstevel@tonic-gate ulong_t rt_padstart; /* start of image (including padding) */ 4667c478bd9Sstevel@tonic-gate ulong_t rt_padimlen; /* size of image (including padding */ 4677c478bd9Sstevel@tonic-gate ulong_t rt_msize; /* total memory mapped */ 4687c478bd9Sstevel@tonic-gate uint_t rt_flags; /* state flags, see FLG below */ 4697c478bd9Sstevel@tonic-gate uint_t rt_flags1; /* state flags1, see FL1 below */ 4707c478bd9Sstevel@tonic-gate ulong_t rt_tlsmodid; /* TLS module id */ 4717c478bd9Sstevel@tonic-gate /* 4727c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 4737c478bd9Sstevel@tonic-gate */ 4747c478bd9Sstevel@tonic-gate Alist *rt_alias; /* list of linked file names */ 4757c478bd9Sstevel@tonic-gate Alist *rt_fpnode; /* list of FullpathNode AVL nodes */ 4767c478bd9Sstevel@tonic-gate void (*rt_init)(); /* address of _init */ 4777c478bd9Sstevel@tonic-gate void (*rt_fini)(); /* address of _fini */ 4787c478bd9Sstevel@tonic-gate char *rt_runpath; /* LD_RUN_PATH and its equivalent */ 4797c478bd9Sstevel@tonic-gate Pnode *rt_runlist; /* Pnode structures */ 4807c478bd9Sstevel@tonic-gate Alist *rt_depends; /* list of dependencies */ 4817c478bd9Sstevel@tonic-gate Alist *rt_callers; /* list of callers */ 4827c478bd9Sstevel@tonic-gate Alist *rt_handles; /* dlopen handles */ 4837c478bd9Sstevel@tonic-gate Alist *rt_groups; /* groups we're a member of */ 4847c478bd9Sstevel@tonic-gate ulong_t rt_etext; /* etext address */ 4857c478bd9Sstevel@tonic-gate struct fct *rt_fct; /* file class table for this object */ 4867c478bd9Sstevel@tonic-gate Sym *(*rt_symintp)(); /* link map symbol interpreter */ 4877c478bd9Sstevel@tonic-gate void *rt_priv; /* private data, object type specific */ 4887c478bd9Sstevel@tonic-gate Lm_list *rt_list; /* link map list we belong to */ 4897c478bd9Sstevel@tonic-gate uint_t rt_objfltrndx; /* object filtees .dynamic index */ 4907c478bd9Sstevel@tonic-gate uint_t rt_symsfltrcnt; /* number of standard symbol filtees */ 4917c478bd9Sstevel@tonic-gate uint_t rt_symafltrcnt; /* number of auxiliary symbol filtees */ 4927c478bd9Sstevel@tonic-gate int rt_mode; /* usage mode, see RTLD mode flags */ 493dffec89cSrie int rt_sortval; /* temporary buffer to traverse graph */ 4947c478bd9Sstevel@tonic-gate uint_t rt_cycgroup; /* cyclic group */ 4957c478bd9Sstevel@tonic-gate dev_t rt_stdev; /* device id and inode number for .so */ 4967c478bd9Sstevel@tonic-gate ino_t rt_stino; /* multiple inclusion checks */ 4977c478bd9Sstevel@tonic-gate char *rt_origname; /* original pathname of loaded object */ 4987c478bd9Sstevel@tonic-gate size_t rt_dirsz; /* and its size */ 4997c478bd9Sstevel@tonic-gate Alist *rt_copy; /* list of copy relocations */ 5007c478bd9Sstevel@tonic-gate Audit_desc *rt_auditors; /* audit descriptor array */ 5017c478bd9Sstevel@tonic-gate Audit_info *rt_audinfo; /* audit information descriptor */ 5027c478bd9Sstevel@tonic-gate Syminfo *rt_syminfo; /* elf .syminfo section - here */ 5037c478bd9Sstevel@tonic-gate /* because it is checked in */ 5047c478bd9Sstevel@tonic-gate /* common code */ 5057c478bd9Sstevel@tonic-gate Addr *rt_initarray; /* .initarray table */ 5067c478bd9Sstevel@tonic-gate Addr *rt_finiarray; /* .finiarray table */ 5077c478bd9Sstevel@tonic-gate Addr *rt_preinitarray; /* .preinitarray table */ 5087c478bd9Sstevel@tonic-gate Mmap *rt_mmaps; /* array of mapping information */ 5097c478bd9Sstevel@tonic-gate uint_t rt_mmapcnt; /* and associated number */ 5107c478bd9Sstevel@tonic-gate uint_t rt_initarraysz; /* size of .initarray table */ 5117c478bd9Sstevel@tonic-gate uint_t rt_finiarraysz; /* size of .finiarray table */ 5127c478bd9Sstevel@tonic-gate uint_t rt_preinitarraysz; /* size of .preinitarray table */ 5137c478bd9Sstevel@tonic-gate Dyninfo *rt_dyninfo; /* .dynamic information descriptors */ 5147c478bd9Sstevel@tonic-gate uint_t rt_dyninfocnt; /* count of dyninfo entries */ 5157c478bd9Sstevel@tonic-gate uint_t rt_relacount; /* no. of RELATIVE relocations */ 5167c478bd9Sstevel@tonic-gate uint_t rt_idx; /* hold index within linkmap list */ 5177c478bd9Sstevel@tonic-gate uint_t rt_lazy; /* lazy dependencies pending */ 5187c478bd9Sstevel@tonic-gate Rt_cond *rt_condvar; /* variables */ 5197c478bd9Sstevel@tonic-gate Xword rt_hwcap; /* hardware capabilities */ 5207c478bd9Sstevel@tonic-gate Xword rt_sfcap; /* software capabilities */ 5217c478bd9Sstevel@tonic-gate thread_t rt_threadid; /* thread init/fini synchronization */ 5227c478bd9Sstevel@tonic-gate uint_t rt_cntl; /* link-map control list we belong to */ 5237c478bd9Sstevel@tonic-gate }; 5247c478bd9Sstevel@tonic-gate 5257c478bd9Sstevel@tonic-gate 5267c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 5277c478bd9Sstevel@tonic-gate /* 5287c478bd9Sstevel@tonic-gate * Structure to allow 64-bit rtld_db to read 32-bit processes out of procfs. 5297c478bd9Sstevel@tonic-gate */ 5307c478bd9Sstevel@tonic-gate typedef struct rt_map32 { 5317c478bd9Sstevel@tonic-gate /* 5327c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 5337c478bd9Sstevel@tonic-gate */ 5347c478bd9Sstevel@tonic-gate Link_map32 rt_public; 5357c478bd9Sstevel@tonic-gate uint32_t rt_pathname; 5367c478bd9Sstevel@tonic-gate uint32_t rt_padstart; 5377c478bd9Sstevel@tonic-gate uint32_t rt_padimlen; 5387c478bd9Sstevel@tonic-gate uint32_t rt_msize; 5397c478bd9Sstevel@tonic-gate uint32_t rt_flags; 5407c478bd9Sstevel@tonic-gate uint32_t rt_flags1; 5417c478bd9Sstevel@tonic-gate uint32_t rt_tlsmodid; 5427c478bd9Sstevel@tonic-gate /* 5437c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 5447c478bd9Sstevel@tonic-gate */ 5457c478bd9Sstevel@tonic-gate uint32_t rt_alias; 5467c478bd9Sstevel@tonic-gate uint32_t rt_fpnode; 5477c478bd9Sstevel@tonic-gate uint32_t rt_init; 5487c478bd9Sstevel@tonic-gate uint32_t rt_fini; 5497c478bd9Sstevel@tonic-gate uint32_t rt_runpath; 5507c478bd9Sstevel@tonic-gate uint32_t rt_runlist; 5517c478bd9Sstevel@tonic-gate uint32_t rt_depends; 5527c478bd9Sstevel@tonic-gate uint32_t rt_callers; 5537c478bd9Sstevel@tonic-gate uint32_t rt_handles; 5547c478bd9Sstevel@tonic-gate uint32_t rt_groups; 5557c478bd9Sstevel@tonic-gate uint32_t rt_etext; 5567c478bd9Sstevel@tonic-gate uint32_t rt_fct; 5577c478bd9Sstevel@tonic-gate uint32_t rt_symintp; 5587c478bd9Sstevel@tonic-gate uint32_t rt_priv; 5597c478bd9Sstevel@tonic-gate uint32_t rt_list; 5607c478bd9Sstevel@tonic-gate uint32_t rt_objfltrndx; 5617c478bd9Sstevel@tonic-gate uint32_t rt_symsfltrcnt; 5627c478bd9Sstevel@tonic-gate uint32_t rt_symafltrcnt; 563dffec89cSrie int32_t rt_mode; 564dffec89cSrie int32_t rt_sortval; 5657c478bd9Sstevel@tonic-gate uint32_t rt_cycgroup; 5667c478bd9Sstevel@tonic-gate uint32_t rt_stdev; 5677c478bd9Sstevel@tonic-gate uint32_t rt_stino; 5687c478bd9Sstevel@tonic-gate uint32_t rt_origname; 5697c478bd9Sstevel@tonic-gate uint32_t rt_dirsz; 5707c478bd9Sstevel@tonic-gate uint32_t rt_copy; 5717c478bd9Sstevel@tonic-gate uint32_t rt_auditors; 5727c478bd9Sstevel@tonic-gate uint32_t rt_audinfo; 5737c478bd9Sstevel@tonic-gate uint32_t rt_syminfo; 5747c478bd9Sstevel@tonic-gate uint32_t rt_initarray; 5757c478bd9Sstevel@tonic-gate uint32_t rt_finiarray; 5767c478bd9Sstevel@tonic-gate uint32_t rt_preinitarray; 5777c478bd9Sstevel@tonic-gate uint32_t rt_mmaps; 5787c478bd9Sstevel@tonic-gate uint32_t rt_mmapcnt; 5797c478bd9Sstevel@tonic-gate uint32_t rt_initarraysz; 5807c478bd9Sstevel@tonic-gate uint32_t rt_finiarraysz; 5817c478bd9Sstevel@tonic-gate uint32_t rt_preinitarraysz; 5827c478bd9Sstevel@tonic-gate uint32_t rt_dyninfo; 5837c478bd9Sstevel@tonic-gate uint32_t rt_dyninfocnt; 5847c478bd9Sstevel@tonic-gate uint32_t rt_relacount; 5857c478bd9Sstevel@tonic-gate uint32_t rt_idx; 5867c478bd9Sstevel@tonic-gate uint32_t rt_lazy; 5877c478bd9Sstevel@tonic-gate uint32_t rt_condvar; 5887c478bd9Sstevel@tonic-gate uint32_t rt_hwcap; 5897c478bd9Sstevel@tonic-gate uint32_t rt_sfcap; 5907c478bd9Sstevel@tonic-gate uint32_t rt_threadid; 5917c478bd9Sstevel@tonic-gate uint32_t rt_cntl; 5927c478bd9Sstevel@tonic-gate } Rt_map32; 5937c478bd9Sstevel@tonic-gate 5947c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 5957c478bd9Sstevel@tonic-gate 5967c478bd9Sstevel@tonic-gate /* 5977c478bd9Sstevel@tonic-gate * Link map state flags. 5987c478bd9Sstevel@tonic-gate */ 5997c478bd9Sstevel@tonic-gate /* 6007c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 6017c478bd9Sstevel@tonic-gate */ 6027c478bd9Sstevel@tonic-gate #define FLG_RT_ISMAIN 0x00000001 /* object represents main executable */ 6037c478bd9Sstevel@tonic-gate #define FLG_RT_IMGALLOC 0x00000002 /* image is allocated (not mmap'ed) */ 6047c478bd9Sstevel@tonic-gate /* 6057c478bd9Sstevel@tonic-gate * Available for r_debug version >= RTLD_DB_VERSION5 6067c478bd9Sstevel@tonic-gate */ 6077c478bd9Sstevel@tonic-gate #define FLG_RT_RELOCED 0x00000004 /* object has been relocated */ 6087c478bd9Sstevel@tonic-gate /* 6097c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 6107c478bd9Sstevel@tonic-gate */ 6117c478bd9Sstevel@tonic-gate #define FLG_RT_SETGROUP 0x00000008 /* group establishment required */ 6127c478bd9Sstevel@tonic-gate #define FLG_RT_HWCAP 0x00000010 /* process $HWCAP expansion */ 6137c478bd9Sstevel@tonic-gate #define FLG_RT_OBJECT 0x00000020 /* object processing (ie. .o's) */ 614390b98b5Srie #define FLG_RT_NEWLOAD 0x00000040 /* object is newly loaded */ 6157c478bd9Sstevel@tonic-gate #define FLG_RT_NODUMP 0x00000080 /* object can't be dldump(3x)'ed */ 6167c478bd9Sstevel@tonic-gate #define FLG_RT_DELETE 0x00000100 /* object can be deleted */ 6177c478bd9Sstevel@tonic-gate #define FLG_RT_ANALYZED 0x00000200 /* object has been analyzed */ 6187c478bd9Sstevel@tonic-gate #define FLG_RT_INITDONE 0x00000400 /* objects .init has been completed */ 6197c478bd9Sstevel@tonic-gate #define FLG_RT_TRANS 0x00000800 /* object is acting as a translator */ 6207c478bd9Sstevel@tonic-gate #define FLG_RT_FIXED 0x00001000 /* image location is fixed */ 6217c478bd9Sstevel@tonic-gate #define FLG_RT_PRELOAD 0x00002000 /* object was preloaded */ 6227c478bd9Sstevel@tonic-gate #define FLG_RT_ALTER 0x00004000 /* alternative object used */ 6237c478bd9Sstevel@tonic-gate #define FLG_RT_LOADFLTR 0x00008000 /* trigger filtee loading */ 6247c478bd9Sstevel@tonic-gate #define FLG_RT_AUDIT 0x00010000 /* object is an auditor */ 6257c478bd9Sstevel@tonic-gate #define FLG_RT_MODESET 0x00020000 /* MODE() has been initialized */ 6267c478bd9Sstevel@tonic-gate #define FLG_RT_ANALZING 0x00040000 /* object is being analyzed */ 6277c478bd9Sstevel@tonic-gate #define FLG_RT_INITFRST 0x00080000 /* execute .init first */ 6287c478bd9Sstevel@tonic-gate #define FLG_RT_NOOPEN 0x00100000 /* dlopen() not allowed */ 6297c478bd9Sstevel@tonic-gate #define FLG_RT_FINICLCT 0x00200000 /* fini has been collected (tsort) */ 6307c478bd9Sstevel@tonic-gate #define FLG_RT_INITCALL 0x00400000 /* objects .init has been called */ 6317c478bd9Sstevel@tonic-gate #define FLG_RT_INTRPOSE 0x00800000 /* object is an INTERPOSER */ 6327c478bd9Sstevel@tonic-gate #define FLG_RT_DIRECT 0x01000000 /* object has DIRECT bindings enabled */ 6337c478bd9Sstevel@tonic-gate #define FLG_RT_SUNWBSS 0x02000000 /* object with PT_SUNWBSS, not mapped */ 6347c478bd9Sstevel@tonic-gate #define FLG_RT_MOVE 0x04000000 /* object needs move operation */ 6357c478bd9Sstevel@tonic-gate #define FLG_RT_DLSYM 0x08000000 /* dlsym in progress on object */ 6367c478bd9Sstevel@tonic-gate #define FLG_RT_REGSYMS 0x10000000 /* object has DT_REGISTER entries */ 6377c478bd9Sstevel@tonic-gate #define FLG_RT_INITCLCT 0x20000000 /* init has been collected (tsort) */ 6387c478bd9Sstevel@tonic-gate #define FLG_RT_HANDLE 0x40000000 /* generate a handle for this object */ 6397c478bd9Sstevel@tonic-gate #define FLG_RT_RELOCING 0x80000000 /* object is being relocated */ 6407c478bd9Sstevel@tonic-gate 6417c478bd9Sstevel@tonic-gate #define FL1_RT_COPYTOOK 0x00000001 /* copy relocation taken */ 6427c478bd9Sstevel@tonic-gate #define FL1_RT_RELATIVE 0x00000002 /* relative path expansion required */ 6437c478bd9Sstevel@tonic-gate #define FL1_RT_CONFSET 0x00000004 /* object was loaded by crle(1) */ 6447c478bd9Sstevel@tonic-gate #define FL1_RT_NODEFLIB 0x00000008 /* ignore default library search */ 6457c478bd9Sstevel@tonic-gate #define FL1_RT_ENDFILTE 0x00000010 /* filtee terminates filters search */ 6467c478bd9Sstevel@tonic-gate #define FL1_RT_DISPREL 0x00000020 /* object has *disp* relocation */ 6477c478bd9Sstevel@tonic-gate #define FL1_RT_TEXTREL 0x00000040 /* DT_TEXTREL set in object */ 6487c478bd9Sstevel@tonic-gate #define FL1_RT_INITWAIT 0x00000080 /* threads are waiting on .init */ 6497c478bd9Sstevel@tonic-gate #define FL1_RT_LDDSTUB 0x00000100 /* identify lddstub */ 6507c478bd9Sstevel@tonic-gate #define FL1_RT_NOINIFIN 0x00000200 /* no .init or .fini exists */ 6517c478bd9Sstevel@tonic-gate #define FL1_RT_USED 0x00000400 /* symbol referenced from this object */ 6527c478bd9Sstevel@tonic-gate #define FL1_RT_SYMBOLIC 0x00000800 /* DF_SYMBOLIC was set - use */ 6537c478bd9Sstevel@tonic-gate /* symbolic sym resolution */ 6547c478bd9Sstevel@tonic-gate #define FL1_RT_OBJSFLTR 0x00001000 /* object is acting as a standard */ 6557c478bd9Sstevel@tonic-gate #define FL1_RT_OBJAFLTR 0x00002000 /* or auxiliary filter */ 6567c478bd9Sstevel@tonic-gate #define FL1_RT_SYMSFLTR 0x00004000 /* symbol is acting as a standard */ 6577c478bd9Sstevel@tonic-gate #define FL1_RT_SYMAFLTR 0x00008000 /* or auxiliary filter */ 6587c478bd9Sstevel@tonic-gate #define MSK_RT_FILTER 0x0000f000 /* mask for all filter possibilites */ 6597c478bd9Sstevel@tonic-gate 6607c478bd9Sstevel@tonic-gate /* 6617c478bd9Sstevel@tonic-gate * The following range of bits are reserved to hold LML_TFLG_AUD_ values 6627c478bd9Sstevel@tonic-gate * (although the definitions themselves aren't used anywhere). 6637c478bd9Sstevel@tonic-gate */ 6647c478bd9Sstevel@tonic-gate #define FL1_AUD_RS_STR 0x00100000 /* RESERVATION start for AU flags */ 6657c478bd9Sstevel@tonic-gate #define FL1_AUD_RS_END 0x80000000 /* RESERVATION end for AU flags */ 6667c478bd9Sstevel@tonic-gate 6677c478bd9Sstevel@tonic-gate 6687c478bd9Sstevel@tonic-gate /* 6697c478bd9Sstevel@tonic-gate * Flags for the tls_modactivity() routine 6707c478bd9Sstevel@tonic-gate */ 6717c478bd9Sstevel@tonic-gate #define TM_FLG_MODADD 0x01 /* call tls_modadd() interface */ 6727c478bd9Sstevel@tonic-gate #define TM_FLG_MODREM 0x02 /* call tls_modrem() interface */ 6737c478bd9Sstevel@tonic-gate 6747c478bd9Sstevel@tonic-gate /* 6757c478bd9Sstevel@tonic-gate * Macros for getting to link_map data. 6767c478bd9Sstevel@tonic-gate */ 6777c478bd9Sstevel@tonic-gate #define ADDR(X) ((X)->rt_public.l_addr) 6787c478bd9Sstevel@tonic-gate #define NAME(X) ((X)->rt_public.l_name) 6797c478bd9Sstevel@tonic-gate #define DYN(X) ((X)->rt_public.l_ld) 6807c478bd9Sstevel@tonic-gate #define NEXT(X) ((X)->rt_public.l_next) 6817c478bd9Sstevel@tonic-gate #define PREV(X) ((X)->rt_public.l_prev) 6827c478bd9Sstevel@tonic-gate #define REFNAME(X) ((X)->rt_public.l_refname) 6837c478bd9Sstevel@tonic-gate 6847c478bd9Sstevel@tonic-gate /* 6857c478bd9Sstevel@tonic-gate * Macros for getting to linker private data. 6867c478bd9Sstevel@tonic-gate */ 6877c478bd9Sstevel@tonic-gate #define PATHNAME(X) ((X)->rt_pathname) 6887c478bd9Sstevel@tonic-gate #define PADSTART(X) ((X)->rt_padstart) 6897c478bd9Sstevel@tonic-gate #define PADIMLEN(X) ((X)->rt_padimlen) 6907c478bd9Sstevel@tonic-gate #define MSIZE(X) ((X)->rt_msize) 6917c478bd9Sstevel@tonic-gate #define FLAGS(X) ((X)->rt_flags) 6927c478bd9Sstevel@tonic-gate #define FLAGS1(X) ((X)->rt_flags1) 6937c478bd9Sstevel@tonic-gate #define TLSMODID(X) ((X)->rt_tlsmodid) 6947c478bd9Sstevel@tonic-gate 6957c478bd9Sstevel@tonic-gate #define ALIAS(X) ((X)->rt_alias) 6967c478bd9Sstevel@tonic-gate #define FPNODE(X) ((X)->rt_fpnode) 6977c478bd9Sstevel@tonic-gate #define INIT(X) ((X)->rt_init) 6987c478bd9Sstevel@tonic-gate #define FINI(X) ((X)->rt_fini) 6997c478bd9Sstevel@tonic-gate #define RPATH(X) ((X)->rt_runpath) 7007c478bd9Sstevel@tonic-gate #define RLIST(X) ((X)->rt_runlist) 7017c478bd9Sstevel@tonic-gate #define DEPENDS(X) ((X)->rt_depends) 7027c478bd9Sstevel@tonic-gate #define CALLERS(X) ((X)->rt_callers) 7037c478bd9Sstevel@tonic-gate #define HANDLES(X) ((X)->rt_handles) 7047c478bd9Sstevel@tonic-gate #define GROUPS(X) ((X)->rt_groups) 7057c478bd9Sstevel@tonic-gate #define ETEXT(X) ((X)->rt_etext) 7067c478bd9Sstevel@tonic-gate #define FCT(X) ((X)->rt_fct) 7077c478bd9Sstevel@tonic-gate #define SYMINTP(X) ((X)->rt_symintp) 7087c478bd9Sstevel@tonic-gate #define LIST(X) ((X)->rt_list) 7097c478bd9Sstevel@tonic-gate #define OBJFLTRNDX(X) ((X)->rt_objfltrndx) 7107c478bd9Sstevel@tonic-gate #define SYMSFLTRCNT(X) ((X)->rt_symsfltrcnt) 7117c478bd9Sstevel@tonic-gate #define SYMAFLTRCNT(X) ((X)->rt_symafltrcnt) 7127c478bd9Sstevel@tonic-gate #define MODE(X) ((X)->rt_mode) 7137c478bd9Sstevel@tonic-gate #define SORTVAL(X) ((X)->rt_sortval) 7147c478bd9Sstevel@tonic-gate #define CYCGROUP(X) ((X)->rt_cycgroup) 7157c478bd9Sstevel@tonic-gate #define STDEV(X) ((X)->rt_stdev) 7167c478bd9Sstevel@tonic-gate #define STINO(X) ((X)->rt_stino) 7177c478bd9Sstevel@tonic-gate #define ORIGNAME(X) ((X)->rt_origname) 7187c478bd9Sstevel@tonic-gate #define DIRSZ(X) ((X)->rt_dirsz) 7197c478bd9Sstevel@tonic-gate #define COPY(X) ((X)->rt_copy) 7207c478bd9Sstevel@tonic-gate #define AUDITORS(X) ((X)->rt_auditors) 7217c478bd9Sstevel@tonic-gate #define AUDINFO(X) ((X)->rt_audinfo) 7227c478bd9Sstevel@tonic-gate #define SYMINFO(X) ((X)->rt_syminfo) 7237c478bd9Sstevel@tonic-gate #define INITARRAY(X) ((X)->rt_initarray) 7247c478bd9Sstevel@tonic-gate #define FINIARRAY(X) ((X)->rt_finiarray) 7257c478bd9Sstevel@tonic-gate #define PREINITARRAY(X) ((X)->rt_preinitarray) 7267c478bd9Sstevel@tonic-gate #define MMAPS(X) ((X)->rt_mmaps) 7277c478bd9Sstevel@tonic-gate #define MMAPCNT(X) ((X)->rt_mmapcnt) 7287c478bd9Sstevel@tonic-gate #define INITARRAYSZ(X) ((X)->rt_initarraysz) 7297c478bd9Sstevel@tonic-gate #define FINIARRAYSZ(X) ((X)->rt_finiarraysz) 7307c478bd9Sstevel@tonic-gate #define PREINITARRAYSZ(X) ((X)->rt_preinitarraysz) 7317c478bd9Sstevel@tonic-gate #define DYNINFO(X) ((X)->rt_dyninfo) 7327c478bd9Sstevel@tonic-gate #define DYNINFOCNT(X) ((X)->rt_dyninfocnt) 7337c478bd9Sstevel@tonic-gate #define RELACOUNT(X) ((X)->rt_relacount) 7347c478bd9Sstevel@tonic-gate #define IDX(X) ((X)->rt_idx) 7357c478bd9Sstevel@tonic-gate #define LAZY(X) ((X)->rt_lazy) 7367c478bd9Sstevel@tonic-gate #define CONDVAR(X) ((X)->rt_condvar) 7377c478bd9Sstevel@tonic-gate #define CNTL(X) ((X)->rt_cntl) 7387c478bd9Sstevel@tonic-gate #define HWCAP(X) ((X)->rt_hwcap) 7397c478bd9Sstevel@tonic-gate #define SFCAP(X) ((X)->rt_sfcap) 7407c478bd9Sstevel@tonic-gate #define THREADID(X) ((X)->rt_threadid) 7417c478bd9Sstevel@tonic-gate 742dffec89cSrie /* 743dffec89cSrie * Flags for tsorting. 744dffec89cSrie */ 745dffec89cSrie #define RT_SORT_FWD 0x01 /* topological sort (.fini) */ 746dffec89cSrie #define RT_SORT_REV 0x02 /* reverse topological sort (.init) */ 747dffec89cSrie #define RT_SORT_DELETE 0x10 /* process FLG_RT_DELNEED objects */ 748dffec89cSrie /* only (called via dlclose()) */ 7497c478bd9Sstevel@tonic-gate /* 7507c478bd9Sstevel@tonic-gate * Flags for lookup_sym (and hence find_sym) routines. 7517c478bd9Sstevel@tonic-gate */ 7527c478bd9Sstevel@tonic-gate #define LKUP_DEFT 0x0000 /* simple lookup request */ 7537c478bd9Sstevel@tonic-gate #define LKUP_SPEC 0x0001 /* special ELF lookup (allows address */ 7547c478bd9Sstevel@tonic-gate /* resolutions to plt[] entries) */ 7557c478bd9Sstevel@tonic-gate #define LKUP_LDOT 0x0002 /* indicates the original A_OUT */ 7567c478bd9Sstevel@tonic-gate /* symbol had a leading `.' */ 7577c478bd9Sstevel@tonic-gate #define LKUP_FIRST 0x0004 /* lookup symbol in first link map */ 7587c478bd9Sstevel@tonic-gate /* only */ 7597c478bd9Sstevel@tonic-gate #define LKUP_COPY 0x0008 /* lookup symbol for a COPY reloc, do */ 7607c478bd9Sstevel@tonic-gate /* not bind to symbol at head */ 7617c478bd9Sstevel@tonic-gate #define LKUP_ALLCNTLIST 0x0010 /* lookup symbol in all control lists */ 7627c478bd9Sstevel@tonic-gate #define LKUP_SELF 0x0020 /* lookup symbol in ourself - undef */ 7637c478bd9Sstevel@tonic-gate /* is valid */ 7647c478bd9Sstevel@tonic-gate #define LKUP_WEAK 0x0040 /* relocation reference is weak */ 7657c478bd9Sstevel@tonic-gate #define LKUP_NEXT 0x0080 /* request originates from RTLD_NEXT */ 7667c478bd9Sstevel@tonic-gate #define LKUP_NODESCENT 0x0100 /* don't descend through dependencies */ 7677c478bd9Sstevel@tonic-gate #define LKUP_NOFALBACK 0x0200 /* don't fall back to loading */ 7687c478bd9Sstevel@tonic-gate /* pending lazy dependencies */ 7697c478bd9Sstevel@tonic-gate #define LKUP_DIRECT 0x0400 /* direct binding request */ 770*660acd81Srie #define LKUP_SYMNDX 0x0800 /* establish symbol index */ 7717c478bd9Sstevel@tonic-gate 7727c478bd9Sstevel@tonic-gate /* 7737c478bd9Sstevel@tonic-gate * Data structure for calling lookup_sym() 7747c478bd9Sstevel@tonic-gate */ 7757c478bd9Sstevel@tonic-gate typedef struct { 7767c478bd9Sstevel@tonic-gate const char *sl_name; /* symbol name */ 7777c478bd9Sstevel@tonic-gate Rt_map *sl_cmap; /* callers link-map */ 7787c478bd9Sstevel@tonic-gate Rt_map *sl_imap; /* initial link-map to search */ 7797c478bd9Sstevel@tonic-gate ulong_t sl_hash; /* symbol hash value */ 7807c478bd9Sstevel@tonic-gate ulong_t sl_rsymndx; /* referencing reloc symndx */ 7817c478bd9Sstevel@tonic-gate uint_t sl_flags; /* lookup flags */ 7827c478bd9Sstevel@tonic-gate } Slookup; 7837c478bd9Sstevel@tonic-gate 7847c478bd9Sstevel@tonic-gate 7857c478bd9Sstevel@tonic-gate typedef enum { 7867c478bd9Sstevel@tonic-gate PLT_T_NONE = 0, 7877c478bd9Sstevel@tonic-gate PLT_T_21D, 7887c478bd9Sstevel@tonic-gate PLT_T_24D, 7897c478bd9Sstevel@tonic-gate PLT_T_U32, 7907c478bd9Sstevel@tonic-gate PLT_T_U44, 7917c478bd9Sstevel@tonic-gate PLT_T_FULL, 7927c478bd9Sstevel@tonic-gate PLT_T_FAR, 7937c478bd9Sstevel@tonic-gate PLT_T_NUM /* Must be last */ 7947c478bd9Sstevel@tonic-gate } Pltbindtype; 7957c478bd9Sstevel@tonic-gate 7967c478bd9Sstevel@tonic-gate /* 7977c478bd9Sstevel@tonic-gate * Prototypes. 7987c478bd9Sstevel@tonic-gate */ 7997c478bd9Sstevel@tonic-gate extern Lm_list lml_main; /* main's link map list */ 8007c478bd9Sstevel@tonic-gate extern Lm_list lml_rtld; /* rtld's link map list */ 8017c478bd9Sstevel@tonic-gate extern Lm_list *lml_list[]; 8027c478bd9Sstevel@tonic-gate 8037c478bd9Sstevel@tonic-gate extern int do_reloc(uchar_t, uchar_t *, Xword *, const char *, 8047c478bd9Sstevel@tonic-gate const char *); 8057c478bd9Sstevel@tonic-gate extern Pltbindtype elf_plt_write(uintptr_t, uintptr_t, void *, uintptr_t, 8067c478bd9Sstevel@tonic-gate Xword); 8077c478bd9Sstevel@tonic-gate extern void eprintf(Error, const char *, ...); 8087c478bd9Sstevel@tonic-gate extern Rt_map *is_so_loaded(Lm_list *, const char *, int); 8097c478bd9Sstevel@tonic-gate extern Sym *lookup_sym(Slookup *, Rt_map **, uint_t *); 8107c478bd9Sstevel@tonic-gate extern int rt_dldump(Rt_map *, const char *, int, Addr); 8117c478bd9Sstevel@tonic-gate 8127c478bd9Sstevel@tonic-gate #ifdef __cplusplus 8137c478bd9Sstevel@tonic-gate } 8147c478bd9Sstevel@tonic-gate #endif 8157c478bd9Sstevel@tonic-gate 8167c478bd9Sstevel@tonic-gate #endif /* _RTLD_H */ 817