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 55aefb655Srie * Common Development and Distribution License (the "License"). 65aefb655Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 215aefb655Srie 227c478bd9Sstevel@tonic-gate /* 23f441771bSRod Evans * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate #ifndef _RTLD_H 267c478bd9Sstevel@tonic-gate #define _RTLD_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate /* 2910a4fa49Srie * Global include file for the runtime linker. 307c478bd9Sstevel@tonic-gate */ 3156deab07SRod Evans #include <sys/mman.h> 327c478bd9Sstevel@tonic-gate #include <time.h> 337c478bd9Sstevel@tonic-gate #include <sgs.h> 347c478bd9Sstevel@tonic-gate #include <thread.h> 357c478bd9Sstevel@tonic-gate #include <synch.h> 36ba2be530Sab196087 #include <link.h> 377c478bd9Sstevel@tonic-gate #include <sys/avl.h> 387c478bd9Sstevel@tonic-gate #include <alist.h> 3910a4fa49Srie #include <libc_int.h> 4008278a5eSRod Evans #include <elfcap.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 437c478bd9Sstevel@tonic-gate #include <inttypes.h> 447c478bd9Sstevel@tonic-gate #endif 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 477c478bd9Sstevel@tonic-gate extern "C" { 487c478bd9Sstevel@tonic-gate #endif 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 51cb511613SAli Bahrami * We use rtld_ino_t instead of ino_t so that we can get 52cb511613SAli Bahrami * access to large inode values from 32-bit code. 53cb511613SAli Bahrami */ 54cb511613SAli Bahrami #ifdef _LP64 55cb511613SAli Bahrami typedef ino_t rtld_ino_t; 56cb511613SAli Bahrami #else 57cb511613SAli Bahrami typedef ino64_t rtld_ino_t; 58cb511613SAli Bahrami #endif 59cb511613SAli Bahrami 607c478bd9Sstevel@tonic-gate typedef struct rt_map Rt_map; 6156deab07SRod Evans typedef struct slookup Slookup; 6208278a5eSRod Evans typedef struct sresult Sresult; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * A binding descriptor. Establishes the binding relationship between two 665aefb655Srie * objects, the caller (originator) and the dependency (destination). 672017c965SRod Evans * 682017c965SRod Evans * Every relationship between two objects is tracked by a binding descriptor. 692017c965SRod Evans * This descriptor is referenced from a link-map's DEPENDS and CALLERS lists. 702017c965SRod Evans * Note, Aplist's are diagramed to fully expose the allocations required to 712017c965SRod Evans * establish the data structure relationships. 722017c965SRod Evans * 732017c965SRod Evans * Bnd_desc 742017c965SRod Evans * ---------- 752017c965SRod Evans * ------------| b_caller | 762017c965SRod Evans * | | b_depend | ---------- 772017c965SRod Evans * | | | | 782017c965SRod Evans * Rt_map | ---------- | Rt_map 792017c965SRod Evans * ---------- | ^ ^ | ---------- 802017c965SRod Evans * | | <-- | | --> | | 812017c965SRod Evans * | | -------- | | | | 822017c965SRod Evans * | DEPENDS | ----> | | | | -------- | | 832017c965SRod Evans * | | | | | | | | <---- | CALLERS | 842017c965SRod Evans * | | | | --- | | | | | 852017c965SRod Evans * | | | | --- | | | | 862017c965SRod Evans * | | -------- | | | | 872017c965SRod Evans * ---------- Aplist -------- ---------- 882017c965SRod Evans * Aplist 897c478bd9Sstevel@tonic-gate */ 907c478bd9Sstevel@tonic-gate typedef struct { 917c478bd9Sstevel@tonic-gate Rt_map *b_caller; /* caller (originator) of a binding */ 927c478bd9Sstevel@tonic-gate Rt_map *b_depend; /* dependency (destination) of a */ 937c478bd9Sstevel@tonic-gate /* binding */ 947c478bd9Sstevel@tonic-gate uint_t b_flags; /* relationship of caller to the */ 957c478bd9Sstevel@tonic-gate /* dependency */ 967c478bd9Sstevel@tonic-gate } Bnd_desc; 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #define BND_NEEDED 0x0001 /* caller NEEDED the dependency */ 997c478bd9Sstevel@tonic-gate #define BND_REFER 0x0002 /* caller relocation references the */ 1007c478bd9Sstevel@tonic-gate /* dependency */ 1012017c965SRod Evans #define BND_FILTER 0x0004 /* binding identifies filter, used */ 1022017c965SRod Evans /* for diagnostics only */ 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * Private structure for communication between rtld_db and rtld. 1057c478bd9Sstevel@tonic-gate * 10610a4fa49Srie * We must bump the version number when ever an update in one of the 10710a4fa49Srie * structures/fields that rtld_db reads is updated. This hopefully permits 10810a4fa49Srie * rtld_db implementations of the future to recognize core files produced on 10910a4fa49Srie * older systems and deal with these core files accordingly. 1107c478bd9Sstevel@tonic-gate * 11156deab07SRod Evans * As of version 'R_RTLDDB_VERSION <= 2' the following fields were valid for 11256deab07SRod Evans * core file examination (basically the public Link_map): 1137c478bd9Sstevel@tonic-gate * 1147c478bd9Sstevel@tonic-gate * ADDR() 1157c478bd9Sstevel@tonic-gate * NAME() 1167c478bd9Sstevel@tonic-gate * DYN() 1177c478bd9Sstevel@tonic-gate * NEXT() 1187c478bd9Sstevel@tonic-gate * PREV() 1197c478bd9Sstevel@tonic-gate * 12056deab07SRod Evans * Valid fields for R_RTLDDB_VERSION3 1217c478bd9Sstevel@tonic-gate * 1227c478bd9Sstevel@tonic-gate * PATHNAME() 1237c478bd9Sstevel@tonic-gate * PADSTART() 1247c478bd9Sstevel@tonic-gate * PADIMLEN() 1257c478bd9Sstevel@tonic-gate * MSIZE() 1267c478bd9Sstevel@tonic-gate * FLAGS() 1277c478bd9Sstevel@tonic-gate * FLAGS1() 1287c478bd9Sstevel@tonic-gate * 12956deab07SRod Evans * Valid fields for R_RTLDDB_VERSION4 1307c478bd9Sstevel@tonic-gate * 1317c478bd9Sstevel@tonic-gate * TLSMODID() 1327c478bd9Sstevel@tonic-gate * 13356deab07SRod Evans * Valid fields for R_RTLDDB_VERSION5 1347c478bd9Sstevel@tonic-gate * 1357c478bd9Sstevel@tonic-gate * Added rtld_flags & FLG_RT_RELOCED to stable flags range 1367c478bd9Sstevel@tonic-gate * 13728bda19cSRod Evans * Valid fields for R_RTLDDB_VERSION6 13828bda19cSRod Evans * 13928bda19cSRod Evans * rtd_dynlmlst converted from a List to APlist 1407c478bd9Sstevel@tonic-gate */ 1417c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION1 1 /* base version level - used for core */ 1427c478bd9Sstevel@tonic-gate /* file examination */ 14310a4fa49Srie #define R_RTLDDB_VERSION2 2 /* minor revision - not relevant for */ 1447c478bd9Sstevel@tonic-gate /* core files */ 1457c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION3 3 1467c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION4 4 1477c478bd9Sstevel@tonic-gate #define R_RTLDDB_VERSION5 5 14828bda19cSRod Evans #define R_RTLDDB_VERSION6 6 14928bda19cSRod Evans #define R_RTLDDB_VERSION R_RTLDDB_VERSION6 /* current version */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate typedef struct rtld_db_priv { 1527c478bd9Sstevel@tonic-gate struct r_debug rtd_rdebug; /* original r_debug structure */ 1537c478bd9Sstevel@tonic-gate Word rtd_version; /* version no. */ 1547c478bd9Sstevel@tonic-gate size_t rtd_objpad; /* padding around mmap()ed objects */ 15557ef7aa9SRod Evans APlist **rtd_dynlmlst; /* pointer to dynlm_list pointer */ 1567c478bd9Sstevel@tonic-gate } Rtld_db_priv; 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 1597c478bd9Sstevel@tonic-gate typedef struct rtld_db_priv32 { 1607c478bd9Sstevel@tonic-gate struct r_debug32 rtd_rdebug; /* original r_debug structure */ 1617c478bd9Sstevel@tonic-gate Elf32_Word rtd_version; /* version no. */ 1627c478bd9Sstevel@tonic-gate Elf32_Word rtd_objpad; /* padding around mmap()ed objects */ 16357ef7aa9SRod Evans Elf32_Addr rtd_dynlmlst; /* pointer to dynlm_list */ 1647c478bd9Sstevel@tonic-gate } Rtld_db_priv32; 1657c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1667c478bd9Sstevel@tonic-gate 16710a4fa49Srie /* 16810a4fa49Srie * External function definitions. ld.so.1 must convey information to libc in 16910a4fa49Srie * regards to threading. libc also provides routines for atexit() and message 17010a4fa49Srie * localization. libc provides the necessary interfaces via its RTLDINFO 17110a4fa49Srie * structure and/or later _ld_libc() calls. 17210a4fa49Srie * 17310a4fa49Srie * These external functions are maintained for each link-map list, and used 17410a4fa49Srie * where appropriate. The functions are associated with the object that 17510a4fa49Srie * provided them, so that should the object be deleted (say, from an alternative 17610a4fa49Srie * link-map), the functions can be removed. 17710a4fa49Srie */ 17810a4fa49Srie typedef struct { 17910a4fa49Srie Rt_map *lc_lmp; /* function provider */ 18010a4fa49Srie union { 18110a4fa49Srie int (*lc_func)(); /* external function pointer */ 18210a4fa49Srie uintptr_t lc_val; /* external value */ 18310a4fa49Srie char *lc_ptr; /* external character pointer */ 18410a4fa49Srie } lc_un; 18510a4fa49Srie } Lc_desc; 1867c478bd9Sstevel@tonic-gate 1877c478bd9Sstevel@tonic-gate /* 1887c478bd9Sstevel@tonic-gate * Link map list definition. Link-maps are used to describe each loaded object. 1897c478bd9Sstevel@tonic-gate * Lists of these link-maps describe the various namespaces within a process. 1907c478bd9Sstevel@tonic-gate * The process executable and its dependencies are maintained on the lml_main 1917c478bd9Sstevel@tonic-gate * list. The runtime linker, and its dependencies are maintained on the 1927c478bd9Sstevel@tonic-gate * lml_rtld list. Additional lists can be created (see dlmopen()) for such 1937c478bd9Sstevel@tonic-gate * things as auditors and their dependencies. 1947c478bd9Sstevel@tonic-gate * 1957c478bd9Sstevel@tonic-gate * Each link-map list maintains an Alist of one, or more, linked lists of 1967c478bd9Sstevel@tonic-gate * link-maps. For backward compatibility, the lm_head/lm_tail elements are 1977c478bd9Sstevel@tonic-gate * initialized to the first linked-list of link-maps: 1987c478bd9Sstevel@tonic-gate * 1997c478bd9Sstevel@tonic-gate * Lm_list 2007c478bd9Sstevel@tonic-gate * ---------- 2017c478bd9Sstevel@tonic-gate * | lm_tail | ------------------------------------ 2027c478bd9Sstevel@tonic-gate * | lm_head | -------------------- | 2037c478bd9Sstevel@tonic-gate * | | | Rt_map | Rt_map 2047c478bd9Sstevel@tonic-gate * | | | ------ | ------ 2057c478bd9Sstevel@tonic-gate * | | Alist --> | | |--> | | 2067c478bd9Sstevel@tonic-gate * | | --------- | | | -- | | 2077c478bd9Sstevel@tonic-gate * | lm_lists | ----> | | | | | --> | | 2087c478bd9Sstevel@tonic-gate * | | |---------| | | | | | | 2097c478bd9Sstevel@tonic-gate * | | | lc_head | -- ------ | ------ 2107c478bd9Sstevel@tonic-gate * | | | lc_tail | ------------------ 2117c478bd9Sstevel@tonic-gate * | | |---------| 2122017c965SRod Evans * ---------- | lc_head | 2137c478bd9Sstevel@tonic-gate * | lc_tail | 2147c478bd9Sstevel@tonic-gate * |---------| 2157c478bd9Sstevel@tonic-gate * 2167c478bd9Sstevel@tonic-gate * Multiple link-map lists exist to support the addition of lazy loaded 2177c478bd9Sstevel@tonic-gate * families, filtee families, and dlopen() families. The intent of these 2187c478bd9Sstevel@tonic-gate * lists is to insure that a family of objects that are to be loaded are 2197c478bd9Sstevel@tonic-gate * fully relocatable, and hence usable, before they become part of the main 2207c478bd9Sstevel@tonic-gate * (al_data[0]) link-map control list. This main link-map control list is 2217c478bd9Sstevel@tonic-gate * the only list in existence when control is transferred to user code. 2227c478bd9Sstevel@tonic-gate * 2237c478bd9Sstevel@tonic-gate * During process initialization, the dynamic executable and its non-lazy 2247c478bd9Sstevel@tonic-gate * dependencies are maintained on al_data[0]. If a new object is loaded, then 2257c478bd9Sstevel@tonic-gate * this object is added to the next available control list [1], typically 2267c478bd9Sstevel@tonic-gate * al_data[1]. Any dependencies of this object that have not already been 2277c478bd9Sstevel@tonic-gate * loaded are added to the same control list. Once all of the objects on the 2287c478bd9Sstevel@tonic-gate * new control list have been successfully relocated, the objects are moved from 2297c478bd9Sstevel@tonic-gate * the new control list to the highest control list to which objects of the new 2307c478bd9Sstevel@tonic-gate * control list bound to, typically al_data[1] to al_data[0]. 2317c478bd9Sstevel@tonic-gate * 2327c478bd9Sstevel@tonic-gate * Each loading scenario can be broken down as follows: 2337c478bd9Sstevel@tonic-gate * 2347c478bd9Sstevel@tonic-gate * setup() - only the initial link-map control list is used: 2357c478bd9Sstevel@tonic-gate * i. create al_data[0] 2367c478bd9Sstevel@tonic-gate * ii. add new link-map for main on al_data[0] 2377c478bd9Sstevel@tonic-gate * iii. analyze al_data[0] to add all non-lazy dependencies 2387c478bd9Sstevel@tonic-gate * iv. relocate al_data[0] dependencies. 2397c478bd9Sstevel@tonic-gate * 2407c478bd9Sstevel@tonic-gate * dlopen() - the initiator can only be the initial link-map control list: 2417c478bd9Sstevel@tonic-gate * i. create al_data[1] from caller al_data[0] 2427c478bd9Sstevel@tonic-gate * ii. add new link-map for the dlopen'ed object on al_data[1] 2437c478bd9Sstevel@tonic-gate * iii. analyze al_data[1] to add all non-lazy dependencies 2447c478bd9Sstevel@tonic-gate * iv. relocate al_data[1] dependencies, and move to al_data[0]. 2457c478bd9Sstevel@tonic-gate * 2467c478bd9Sstevel@tonic-gate * filtee and lazy loading processing - the initiator can be any link-map 2477c478bd9Sstevel@tonic-gate * control list that is being relocated: 2487c478bd9Sstevel@tonic-gate * i. create al_data[y] from caller al_data[x] 2497c478bd9Sstevel@tonic-gate * ii. add new link-map for the new object on al_data[y] 2507c478bd9Sstevel@tonic-gate * iii. analyze al_data[y] to add all non-lazy dependencies 2517c478bd9Sstevel@tonic-gate * iv. relocate al_data[y] dependencies, and move to al_data[x]. 2527c478bd9Sstevel@tonic-gate * 2537c478bd9Sstevel@tonic-gate * This Alist therefore maintains a stack of link-map control lists. The newest 2547c478bd9Sstevel@tonic-gate * link-map control list can locate symbols within any of the former lists, 2557c478bd9Sstevel@tonic-gate * however, control is not passed to a former list until the newest lists 2567c478bd9Sstevel@tonic-gate * processing is complete. Thus, objects can't bind to new objects until they 2577c478bd9Sstevel@tonic-gate * have been fully analyzed and relocated. 2587c478bd9Sstevel@tonic-gate * 2597c478bd9Sstevel@tonic-gate * [1] Note, additional link-map control list creation occurs after the head 2607c478bd9Sstevel@tonic-gate * link-map object (typically the dynamic executable) has been relocated. This 2617c478bd9Sstevel@tonic-gate * staging is required to satisfy the binding requirements of copy relocations. 2627c478bd9Sstevel@tonic-gate * Copy relocations, effectively, transfer the bindings of the copied data 2637c478bd9Sstevel@tonic-gate * (say _iob in libc.so.1) to the copy location (_iob in the application). 2647c478bd9Sstevel@tonic-gate * Thus an object that might bind to the original copy data must be redirected 2657c478bd9Sstevel@tonic-gate * to the copy reference. As the knowledge of a copy relocation having taken 2667c478bd9Sstevel@tonic-gate * place is only known after relocating the application, link-map control list 2677c478bd9Sstevel@tonic-gate * additions are suspended until after this relocation has completed. 2687c478bd9Sstevel@tonic-gate */ 2697c478bd9Sstevel@tonic-gate typedef struct { 2707c478bd9Sstevel@tonic-gate Rt_map *lc_head; 2717c478bd9Sstevel@tonic-gate Rt_map *lc_tail; 272cce0e03bSab196087 APlist *lc_now; /* pending promoted bind-now objects */ 2737c478bd9Sstevel@tonic-gate uint_t lc_flags; 2747c478bd9Sstevel@tonic-gate } Lm_cntl; 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate #define LMC_FLG_ANALYZING 0x01 /* control list is being analyzed */ 2777c478bd9Sstevel@tonic-gate #define LMC_FLG_RELOCATING 0x02 /* control list is being relocated */ 2787c478bd9Sstevel@tonic-gate #define LMC_FLG_REANALYZE 0x04 /* repeat analysis (established when */ 2797c478bd9Sstevel@tonic-gate /* interposers are added */ 2807c478bd9Sstevel@tonic-gate 2815aefb655Srie struct lm_list { 2827c478bd9Sstevel@tonic-gate /* 2837c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 2847c478bd9Sstevel@tonic-gate */ 2857c478bd9Sstevel@tonic-gate Rt_map *lm_head; /* linked list pointers to active */ 2867c478bd9Sstevel@tonic-gate Rt_map *lm_tail; /* link-map list */ 287cce0e03bSab196087 APlist *lm_handle; /* not used by rtld_db - but spacing */ 2887c478bd9Sstevel@tonic-gate /* is required for flags */ 2897c478bd9Sstevel@tonic-gate Word lm_flags; 2907c478bd9Sstevel@tonic-gate /* 2917c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 2927c478bd9Sstevel@tonic-gate */ 29310a4fa49Srie Alist *lm_rti; /* list of RTLDINFO tables */ 2948af2c5b9Srie Audit_list *lm_alp; /* audit list descriptor */ 2957c478bd9Sstevel@tonic-gate avl_tree_t *lm_fpavl; /* avl tree of objects loaded */ 2967c478bd9Sstevel@tonic-gate Alist *lm_lists; /* active and pending link-map lists */ 29741072f3cSrie char ***lm_environ; /* pointer to environment array */ 2987c478bd9Sstevel@tonic-gate Word lm_tflags; /* transferable flags */ 2995aefb655Srie uint_t lm_obj; /* total number of objs on link-map */ 3005aefb655Srie uint_t lm_init; /* new obj since last init processing */ 301e0e63816SRod Evans uint_t lm_lazy; /* number of objects with pending */ 302e0e63816SRod Evans /* lazy dependencies */ 30310a4fa49Srie uint_t lm_tls; /* new obj that require TLS */ 3045aefb655Srie uint_t lm_lmid; /* unique link-map list identifier, */ 3055aefb655Srie char *lm_lmidstr; /* and associated diagnostic string */ 3062020b2b6SRod Evans Alist *lm_aud_cookies; /* local auditor cookies */ 30710a4fa49Srie Lc_desc lm_lcs[CI_MAX]; /* external libc functions */ 3085aefb655Srie }; 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 3115aefb655Srie struct lm_list32 { 3127c478bd9Sstevel@tonic-gate /* 3137c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 3147c478bd9Sstevel@tonic-gate */ 3157c478bd9Sstevel@tonic-gate Elf32_Addr lm_head; 3167c478bd9Sstevel@tonic-gate Elf32_Addr lm_tail; 3177c478bd9Sstevel@tonic-gate Elf32_Addr lm_handle; 3187c478bd9Sstevel@tonic-gate Elf32_Word lm_flags; 3197c478bd9Sstevel@tonic-gate /* 3207c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 3217c478bd9Sstevel@tonic-gate */ 32210a4fa49Srie Elf32_Addr lm_rti; 3237c478bd9Sstevel@tonic-gate Elf32_Addr lm_fpavl; 3247c478bd9Sstevel@tonic-gate Elf32_Addr lm_lists; 32541072f3cSrie Elf32_Addr lm_environ; 3267c478bd9Sstevel@tonic-gate Elf32_Word lm_tflags; 3275aefb655Srie uint_t lm_obj; 3285aefb655Srie uint_t lm_init; 3295aefb655Srie uint_t lm_lazy; 33010a4fa49Srie uint_t lm_tls; 3315aefb655Srie uint_t lm_lmid; 3325aefb655Srie Elf32_Addr lm_lmidstr; 3332020b2b6SRod Evans Elf32_Addr lm_aud_cookies; 33410a4fa49Srie Elf32_Addr lm_lcs[CI_MAX]; 3355aefb655Srie }; 3367c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 3377c478bd9Sstevel@tonic-gate 3387c478bd9Sstevel@tonic-gate /* 3397c478bd9Sstevel@tonic-gate * Possible Link_map list flags (Lm_list.lm_flags) 3407c478bd9Sstevel@tonic-gate */ 3417c478bd9Sstevel@tonic-gate /* 3427c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 3437c478bd9Sstevel@tonic-gate */ 3447c478bd9Sstevel@tonic-gate #define LML_FLG_BASELM 0x00000001 /* primary link-map */ 3457c478bd9Sstevel@tonic-gate #define LML_FLG_RTLDLM 0x00000002 /* rtld link-map */ 3467c478bd9Sstevel@tonic-gate /* 3477c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 3487c478bd9Sstevel@tonic-gate */ 3492020b2b6SRod Evans #define LML_FLG_ACTAUDIT 0x00000004 /* audit activity posted */ 3507c478bd9Sstevel@tonic-gate #define LML_FLG_PLTREL 0x00000008 /* deferred plt relocation */ 3512020b2b6SRod Evans /* initialization (ld.so.1 */ 3522020b2b6SRod Evans /* only) */ 3537c478bd9Sstevel@tonic-gate #define LML_FLG_HOLDLOCK 0x00000010 /* hold the rtld mutex lock */ 3547c478bd9Sstevel@tonic-gate #define LML_FLG_ENVIRON 0x00000020 /* environ var initialized */ 3557c478bd9Sstevel@tonic-gate #define LML_FLG_INTRPOSE 0x00000040 /* interposing objs on list */ 3567c478bd9Sstevel@tonic-gate #define LML_FLG_LOCAUDIT 0x00000080 /* local auditors exists for */ 3577c478bd9Sstevel@tonic-gate /* this link-map list */ 3587c478bd9Sstevel@tonic-gate #define LML_FLG_LOADAVAIL 0x00000100 /* load anything available */ 3597c478bd9Sstevel@tonic-gate #define LML_FLG_IGNRELERR 0x00000200 /* ignore relocation errors - */ 3607c478bd9Sstevel@tonic-gate /* internal for crle(1) */ 3612020b2b6SRod Evans #define LML_FLG_STARTREL 0x00000400 /* relocation started */ 3622020b2b6SRod Evans #define LML_FLG_ATEXIT 0x00000800 /* atexit processing */ 3632020b2b6SRod Evans #define LML_FLG_OBJADDED 0x00001000 /* object(s) added */ 3642020b2b6SRod Evans #define LML_FLG_OBJDELETED 0x00002000 /* object(s) deleted */ 3652020b2b6SRod Evans #define LML_FLG_OBJREEVAL 0x00004000 /* existing object(s) needs */ 366dffec89cSrie /* tsort reevaluation */ 3672020b2b6SRod Evans #define LML_FLG_INTRPOSETSORT 0x00008000 /* interpose tsorting done */ 3682020b2b6SRod Evans #define LML_FLG_AUDITNOTIFY 0x00010000 /* audit consistent required */ 3692020b2b6SRod Evans #define LML_FLG_GROUPSEXIST 0x00020000 /* local groups exist */ 3702926dd2eSrie 3717c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_LDDSTUB 0x00100000 /* identify lddstub */ 3727c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_ENABLE 0x00200000 /* tracing enabled (ldd) */ 3737c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_WARN 0x00400000 /* print warnings for undefs */ 3747c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_VERBOSE 0x00800000 /* verbose (versioning) trace */ 3757c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_SEARCH 0x01000000 /* trace search paths */ 3767c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_UNREF 0x02000000 /* trace unreferenced */ 3777c478bd9Sstevel@tonic-gate /* dependencies */ 3787c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_UNUSED 0x04000000 /* trace unused dependencies */ 3797c478bd9Sstevel@tonic-gate #define LML_FLG_TRC_INIT 0x08000000 /* print .init order */ 380df4628cbSrie #define LML_FLG_TRC_NOUNRESWEAK 0x10000000 /* unresolved weak references */ 381df4628cbSrie /* are not allowed */ 382dae2dfb7Srie #define LML_FLG_TRC_NOPAREXT 0x20000000 /* unresolved PARENT/EXTERN */ 383dae2dfb7Srie /* references are not */ 384dae2dfb7Srie /* allowed */ 3857c478bd9Sstevel@tonic-gate #define LML_MSK_TRC 0xfff00000 /* tracing mask */ 3867c478bd9Sstevel@tonic-gate 3877c478bd9Sstevel@tonic-gate /* 3887c478bd9Sstevel@tonic-gate * Possible Link_map transferable flags (Lm_list.lm_tflags), i.e., link-map 3897c478bd9Sstevel@tonic-gate * list flags that can be propagated to any new link-map list created. 3907c478bd9Sstevel@tonic-gate */ 3917c478bd9Sstevel@tonic-gate #define LML_TFLG_NOLAZYLD 0x00000001 /* lazy loading disabled */ 3927c478bd9Sstevel@tonic-gate #define LML_TFLG_NODIRECT 0x00000002 /* direct bindings disabled */ 3932020b2b6SRod Evans #define LML_TFLG_NOAUDIT 0x00000004 /* auditing disabled */ 3947c478bd9Sstevel@tonic-gate #define LML_TFLG_LOADFLTR 0x00000008 /* trigger filtee loading */ 3957c478bd9Sstevel@tonic-gate 39656deab07SRod Evans #define LML_TFLG_AUD_PREINIT 0x00001000 /* preinit (audit) exists */ 39756deab07SRod Evans #define LML_TFLG_AUD_OBJSEARCH 0x00002000 /* objsearch (audit) exists */ 39856deab07SRod Evans #define LML_TFLG_AUD_OBJOPEN 0x00004000 /* objopen (audit) exists */ 39956deab07SRod Evans #define LML_TFLG_AUD_OBJFILTER 0x00008000 /* objfilter (audit) exists */ 40056deab07SRod Evans #define LML_TFLG_AUD_OBJCLOSE 0x00010000 /* objclose (audit) exists */ 40156deab07SRod Evans #define LML_TFLG_AUD_SYMBIND 0x00020000 /* symbind (audit) exists */ 40256deab07SRod Evans #define LML_TFLG_AUD_PLTENTER 0x00040000 /* pltenter (audit) exists */ 40356deab07SRod Evans #define LML_TFLG_AUD_PLTEXIT 0x00080000 /* pltexit (audit) exists */ 40456deab07SRod Evans #define LML_TFLG_AUD_ACTIVITY 0x00100000 /* activity (audit) exists */ 4057c478bd9Sstevel@tonic-gate 4067c478bd9Sstevel@tonic-gate /* 40756deab07SRod Evans * NOTE: Each auditing module establishes a set of audit flags, AFLAGS(), that 40856deab07SRod Evans * define the auditing interfaces the module offers. These auditing flags are 40956deab07SRod Evans * the LML_TFLG_AUD_ flags defined above. Global auditors result in setting 41056deab07SRod Evans * the lm_tflags too. Local auditors only use the AFLAGS(). All tests for 41156deab07SRod Evans * auditing inspect the lm_tflags and AFLAGS() for a specific auditing 41256deab07SRod Evans * interface, and thus use the same flag to test for both types of auditors. 4137c478bd9Sstevel@tonic-gate */ 41456deab07SRod Evans #define LML_TFLG_AUD_MASK 0x0ffff000 /* audit interfaces mask */ 4157c478bd9Sstevel@tonic-gate 4167c478bd9Sstevel@tonic-gate /* 4178af2c5b9Srie * Define a Group Handle. 4188af2c5b9Srie * 4198af2c5b9Srie * The capability of ld.so.1 to associate a group of objects, look for symbols 4208af2c5b9Srie * within that group, ensure that groups are isolated from one another (with 4212017c965SRod Evans * regard to relocations), and to unload a group, centers around a handle. 4228af2c5b9Srie * 4232017c965SRod Evans * Dependencies can be added to an existing handle as the dependencies are 4242017c965SRod Evans * lazily loaded. The core dependencies on the handle are the ldd(1) list of 4252017c965SRod Evans * the referenced object. 4262017c965SRod Evans * 4272017c965SRod Evans * Handles can be created from: 4282017c965SRod Evans * 4292017c965SRod Evans * - a dlopen() request. This associates a caller to a reference object, 4302017c965SRod Evans * and the referenced objects dependencies. This group of objects can 4312017c965SRod Evans * then be inspected for symbols (dlsym()). 4322017c965SRod Evans * - a filtering request. This associates a filter (caller) to a referenced 4332017c965SRod Evans * object (filtee). The redirection of filter symbols to their filtee 4342017c965SRod Evans * counterpart is essentially a dlsym() using the filtee's handle. 4352017c965SRod Evans * 4362017c965SRod Evans * The handle created for these events is referred to as a public handle. This 4372017c965SRod Evans * handle tracks the referenced object, all of the dependencies of the 4382017c965SRod Evans * referenced object, and the caller (parent). 4398af2c5b9Srie * 4408af2c5b9Srie * Presently, an object may have two handles, one requested with RTLD_FIRST 4418af2c5b9Srie * and one without. 4428af2c5b9Srie * 4432017c965SRod Evans * A handle may be referenced by any number of callers (parents). A reference 4448af2c5b9Srie * count tracks the number. A dlclose() operation drops the reference count, 4458af2c5b9Srie * and when the count is zero, the handle is used to determine the family of 4468af2c5b9Srie * objects to unload. As bindings may occur to objects on the handle from 4472017c965SRod Evans * other handles, it may not be possible to remove a complete family of objects 4482017c965SRod Evans * or the handle itself. Handles in this state are moved to an orphan list. 4492017c965SRod Evans * A handle on the orphan list is taken off the orphan list if the associated 4502017c965SRod Evans * object is reopened. Otherwise, the handle remains on the orphan list for 4512017c965SRod Evans * the duration of the process. The orphan list is inspected any time objects 4522017c965SRod Evans * are unloaded, to determine if the orphaned objects can also be unloaded. 4532017c965SRod Evans * 4542017c965SRod Evans * Handles can also be created for internal uses: 4552017c965SRod Evans * 4562017c965SRod Evans * - to promote objects to RTLD_NOW. 4572017c965SRod Evans * - to establish families for symbol binding fallback, required when lazy 4582017c965SRod Evans * loadable objects are still pending. 4592017c965SRod Evans * 4602017c965SRod Evans * The handle created for these events is referred to as a private handle. This 4612017c965SRod Evans * handle does not need to track the caller (parent), and because of this, does 4622017c965SRod Evans * not need to be considered during dlclose() operations, as the handle can not 4632017c965SRod Evans * be referenced by callers outside of the referenced objects family. 4642017c965SRod Evans * 4652017c965SRod Evans * Note, a private handle is essentially a subset of a public handle. Should 4662017c965SRod Evans * an internal operation require a private handle, and a public handle already 4672017c965SRod Evans * exist, the public handle can be used. Should an external operation require 4682017c965SRod Evans * a public handle, and a private handle exist, the private handle is promoted 4692017c965SRod Evans * to a public handle. Any handle that gets created will remain in existence 4702017c965SRod Evans * for the life time of the referenced object. 4718af2c5b9Srie * 4728af2c5b9Srie * Objects can be dlopened using RTLD_NOW. This attribute requires that all 4738af2c5b9Srie * relocations of the object, and its dependencies are processed immediately, 4748af2c5b9Srie * before return to the caller. Typically, an object is loaded without 4758af2c5b9Srie * RTLD_NOW, and procedure linkage relocations are satisfied when their 4768af2c5b9Srie * associated function is first called. If an object is already loaded, and an 4778af2c5b9Srie * RTLD_NOW request is made, then the object, and its dependencies, most undergo 4788af2c5b9Srie * additional relocation processing. This promotion from lazy binding to 4798af2c5b9Srie * immediate binding is carried out using handles, as the handle defines the 4802017c965SRod Evans * dependencies that must be processed. 4812017c965SRod Evans * 4822017c965SRod Evans * To ensure that objects within a lazy loadable environment can be relocated, 4832017c965SRod Evans * no matter whether the objects have their dependencies described completely, 4842017c965SRod Evans * a symbol lookup fallback is employed. Any pending lazy loadable objects are 4852017c965SRod Evans * loaded, and a handle established to search the object and it's dependencies 4862017c965SRod Evans * for the required symbol. 4872017c965SRod Evans * 4882017c965SRod Evans * A group handle (and its associated group descriptors), is referenced from 4892017c965SRod Evans * a link-map's HANDLES and GROUPS lists. Note, Aplist's are diagramed to 4902017c965SRod Evans * fully expose the allocations required to establish the data structure 4912017c965SRod Evans * relationships. 4922017c965SRod Evans * 4932017c965SRod Evans * Grp_desc 4942017c965SRod Evans * Alist 4952017c965SRod Evans * ----------- 4962017c965SRod Evans * --> | | 4972017c965SRod Evans * | |-----------| 4982017c965SRod Evans * | | gd_depend | --------- 4992017c965SRod Evans * | | | | 5002017c965SRod Evans * | |-----------| | 5012017c965SRod Evans * --------|--- | gd_depend | | 5022017c965SRod Evans * | | | (parent) | | 5032017c965SRod Evans * | | |-----------| | 5042017c965SRod Evans * | | | gd_depend | | 5052017c965SRod Evans * | | | | | 5062017c965SRod Evans * | | | | | 5072017c965SRod Evans * | | ----------- | 5082017c965SRod Evans * | | | 5092017c965SRod Evans * | | Grp_hdl | 5102017c965SRod Evans * | | ----------- | 5112017c965SRod Evans * | -- | gh_depends | | 5122017c965SRod Evans * | --------- | gh_ownlmp | | 5132017c965SRod Evans * | | | | | 5142017c965SRod Evans * | | | | | 5152017c965SRod Evans * | | | | | 5162017c965SRod Evans * Rt_map | | ------------ | Rt_map 5172017c965SRod Evans * ---------- | | ^ ^ | ---------- 5182017c965SRod Evans * | | <- | | | --> | | 5192017c965SRod Evans * | | <--- -------- | | | | 5202017c965SRod Evans * | HANDLES | ----> | | | | -------- | | 5212017c965SRod Evans * | | | | | | | | <---- | GROUPS | 5222017c965SRod Evans * | | | | --- | | | | | 5232017c965SRod Evans * | | | | --- | | | | 5242017c965SRod Evans * | | -------- | | | | 5252017c965SRod Evans * ---------- Aplist -------- ---------- 5262017c965SRod Evans * Aplist 5277c478bd9Sstevel@tonic-gate */ 5287c478bd9Sstevel@tonic-gate typedef struct { 5297c478bd9Sstevel@tonic-gate Alist *gh_depends; /* handle dependency list */ 5305aefb655Srie Rt_map *gh_ownlmp; /* handle owners link-map */ 5315aefb655Srie Lm_list *gh_ownlml; /* handle owners link-map list */ 5327c478bd9Sstevel@tonic-gate uint_t gh_refcnt; /* handle reference count */ 5338af2c5b9Srie uint_t gh_flags; /* handle flags (GPH_ values) */ 5347c478bd9Sstevel@tonic-gate } Grp_hdl; 5357c478bd9Sstevel@tonic-gate 5362017c965SRod Evans /* 5372017c965SRod Evans * Define the two categories of handle. 5382017c965SRod Evans */ 5392017c965SRod Evans #define GPH_PUBLIC 0x0001 /* handle returned to caller(s) */ 5402017c965SRod Evans #define GPH_PRIVATE 0x0002 /* handle used internally */ 5417c478bd9Sstevel@tonic-gate 5427c478bd9Sstevel@tonic-gate /* 5432017c965SRod Evans * Define any flags that affects how the handle is used. 5442017c965SRod Evans */ 5452017c965SRod Evans #define GPH_ZERO 0x0010 /* special handle for dlopen(0) */ 5462017c965SRod Evans #define GPH_LDSO 0x0020 /* special handle for ld.so.1 */ 5472017c965SRod Evans #define GPH_FIRST 0x0040 /* dlsym() can only use originating */ 5482017c965SRod Evans /* dependency */ 5492017c965SRod Evans #define GPH_FILTEE 0x0080 /* handle identifies a filtee, used */ 5502017c965SRod Evans /* for diagnostics only */ 5512017c965SRod Evans /* 5522017c965SRod Evans * Define any state that is associated with the handle. 5532017c965SRod Evans */ 5542017c965SRod Evans #define GPH_INITIAL 0x0100 /* handle is initialized */ 555e0e63816SRod Evans 5562017c965SRod Evans /* 5578af2c5b9Srie * Define a Group Descriptor. 5588af2c5b9Srie * 5598af2c5b9Srie * Each dependency associated with a group handle is maintained by a group 5608af2c5b9Srie * descriptor. The descriptor defines the associated dependency together with 5618af2c5b9Srie * flags that indicate how the dependency can be used. 5627c478bd9Sstevel@tonic-gate */ 5637c478bd9Sstevel@tonic-gate typedef struct { 5647c478bd9Sstevel@tonic-gate Rt_map *gd_depend; /* dependency */ 5658af2c5b9Srie uint_t gd_flags; /* dependency flags (GPD_ values) */ 5667c478bd9Sstevel@tonic-gate } Grp_desc; 5677c478bd9Sstevel@tonic-gate 568efb9e8b8Srie #define GPD_DLSYM 0x0001 /* dependency available to dlsym() */ 569efb9e8b8Srie #define GPD_RELOC 0x0002 /* dependency available to satisfy */ 570efb9e8b8Srie /* relocation binding */ 571efb9e8b8Srie #define GPD_ADDEPS 0x0004 /* dependencies of this dependency */ 5727c478bd9Sstevel@tonic-gate /* should be added to handle */ 573efb9e8b8Srie #define GPD_PARENT 0x0008 /* dependency is a parent */ 574efb9e8b8Srie #define GPD_FILTER 0x0010 /* dependency is our filter */ 5752017c965SRod Evans #define GPD_REMOVE 0x0100 /* descriptor is a candidate for */ 5767c478bd9Sstevel@tonic-gate /* removal from the group */ 5777c478bd9Sstevel@tonic-gate 5787c478bd9Sstevel@tonic-gate /* 5797c478bd9Sstevel@tonic-gate * Define threading structures. For compatibility with libthread (T1_VERSION 1 5807c478bd9Sstevel@tonic-gate * and TI_VERSION 2) our locking structure is sufficient to hold a mutex or a 5817c478bd9Sstevel@tonic-gate * readers/writers lock. 5827c478bd9Sstevel@tonic-gate */ 5837c478bd9Sstevel@tonic-gate typedef struct { 5847c478bd9Sstevel@tonic-gate union { 5857c478bd9Sstevel@tonic-gate mutex_t l_mutex; 5867c478bd9Sstevel@tonic-gate rwlock_t l_rwlock; 5877c478bd9Sstevel@tonic-gate } u; 5887c478bd9Sstevel@tonic-gate } Rt_lock; 5897c478bd9Sstevel@tonic-gate 5907c478bd9Sstevel@tonic-gate typedef cond_t Rt_cond; 5917c478bd9Sstevel@tonic-gate 5927c478bd9Sstevel@tonic-gate /* 5937c478bd9Sstevel@tonic-gate * Define a dynamic section information descriptor. This parallels the entries 5947c478bd9Sstevel@tonic-gate * in the .dynamic section and holds auxiliary information to implement lazy 5957c478bd9Sstevel@tonic-gate * loading and filtee processing. 5967c478bd9Sstevel@tonic-gate */ 5977c478bd9Sstevel@tonic-gate typedef struct { 5987c478bd9Sstevel@tonic-gate uint_t di_flags; 5997c478bd9Sstevel@tonic-gate void *di_info; 600f441771bSRod Evans const char *di_name; 6017c478bd9Sstevel@tonic-gate } Dyninfo; 6027c478bd9Sstevel@tonic-gate 6037c478bd9Sstevel@tonic-gate #define FLG_DI_STDFLTR 0x00001 /* .dynamic entry for DT_FILTER */ 6047c478bd9Sstevel@tonic-gate #define FLG_DI_AUXFLTR 0x00002 /* .dynamic entry for DT_AUXILIARY */ 6057c478bd9Sstevel@tonic-gate #define FLG_DI_SYMFLTR 0x00004 /* .dynamic entry for DT_SYMFILTER */ 6067c478bd9Sstevel@tonic-gate /* and DT_SYMAUXILIARY */ 6077c478bd9Sstevel@tonic-gate #define MSK_DI_FILTER 0x0000f /* mask for all filter possibilities */ 6087c478bd9Sstevel@tonic-gate 60975e7992aSrie #define FLG_DI_POSFLAG1 0x00010 /* .dynamic entry for DT_POSFLAG_1 */ 61075e7992aSrie #define FLG_DI_NEEDED 0x00020 /* .dynamic entry for DT_NEEDED */ 611f441771bSRod Evans #define FLG_DI_REGISTER 0x00040 /* .dynamic entry for DT_REGISTER */ 612f441771bSRod Evans #define FLG_DI_IGNORE 0x00080 /* .dynamic entry should be ignored */ 6137c478bd9Sstevel@tonic-gate 614f441771bSRod Evans #define FLG_DI_LAZY 0x00100 /* lazy needed entry, preceded by */ 615f441771bSRod Evans /* DF_P1_LAZYLOAD (DT_POSFLAG_1) */ 616f441771bSRod Evans #define FLG_DI_GROUP 0x00200 /* group needed entry, preceded by */ 617f441771bSRod Evans /* DF_P1_GROUPPERM (DT_POSFLAG_1) */ 618f441771bSRod Evans #define FLG_DI_DEFERRED 0x00400 /* deferred needed entry, preceded by */ 619f441771bSRod Evans /* DF_P1_DEFERRED (DT_POSFLAG_1) */ 620f441771bSRod Evans 621f441771bSRod Evans #define FLG_DI_LAZYFAIL 0x01000 /* the lazy loading of this entry */ 62275e7992aSrie /* failed */ 623f441771bSRod Evans #define FLG_DI_LDD_DONE 0x02000 /* entry has been processed (ldd) */ 624f441771bSRod Evans #define FLG_DI_DEF_DONE 0x04000 /* entry has been processed (dlinfo) */ 625f441771bSRod Evans 6267c478bd9Sstevel@tonic-gate /* 6279aa23310Srie * Data structure to track AVL tree of pathnames. This structure provides the 6289aa23310Srie * basis of both the "not-found" node tree, and the "full-path" node tree. Both 6299aa23310Srie * of these trees persist for the life of a process, although the "not-found" 6309aa23310Srie * tree may be moved aside during a dlopen() or dlsym() fall back operation. 6317c478bd9Sstevel@tonic-gate */ 6327c478bd9Sstevel@tonic-gate typedef struct { 6339aa23310Srie const char *pn_name; /* path name */ 6349aa23310Srie avl_node_t pn_avl; /* avl book-keeping (see SGSOFFSETOF) */ 6359aa23310Srie uint_t pn_hash; /* path name hash value */ 6369aa23310Srie } PathNode; 6379aa23310Srie 6389aa23310Srie /* 6399aa23310Srie * Data structure to track AVL tree for full path names of objects that are 6409aa23310Srie * loaded into memory. 6419aa23310Srie */ 6429aa23310Srie typedef struct { 6439aa23310Srie PathNode fpn_node; /* path node */ 6447c478bd9Sstevel@tonic-gate Rt_map *fpn_lmp; /* object link-map */ 6459aa23310Srie } FullPathNode; 6467c478bd9Sstevel@tonic-gate 6477c478bd9Sstevel@tonic-gate /* 648cce0e03bSab196087 * A given link-map can hold either a supplier or receiver copy 649cce0e03bSab196087 * relocation list, but not both. This union is used to overlap 650cce0e03bSab196087 * the space used for the two lists. 651cce0e03bSab196087 */ 652cce0e03bSab196087 typedef union { 653cce0e03bSab196087 Alist *rtc_r; /* receiver list (Rel_copy) */ 654cce0e03bSab196087 APlist *rtc_s; /* supplier list (Rt_map *) */ 655cce0e03bSab196087 } Rt_map_copy; 656cce0e03bSab196087 657cce0e03bSab196087 658cce0e03bSab196087 /* 6597c478bd9Sstevel@tonic-gate * Link-map definition. 6607c478bd9Sstevel@tonic-gate */ 6617c478bd9Sstevel@tonic-gate struct rt_map { 6627c478bd9Sstevel@tonic-gate /* 6637c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 6647c478bd9Sstevel@tonic-gate */ 6657c478bd9Sstevel@tonic-gate Link_map rt_public; /* public data */ 66656deab07SRod Evans const char *rt_pathname; /* full pathname of loaded object */ 6677c478bd9Sstevel@tonic-gate ulong_t rt_padstart; /* start of image (including padding) */ 6687c478bd9Sstevel@tonic-gate ulong_t rt_padimlen; /* size of image (including padding */ 66956deab07SRod Evans ulong_t rt_msize; /* total memory reservation range */ 6707c478bd9Sstevel@tonic-gate uint_t rt_flags; /* state flags, see FLG below */ 6717c478bd9Sstevel@tonic-gate uint_t rt_flags1; /* state flags1, see FL1 below */ 6727c478bd9Sstevel@tonic-gate ulong_t rt_tlsmodid; /* TLS module id */ 6737c478bd9Sstevel@tonic-gate /* 6747c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 6757c478bd9Sstevel@tonic-gate */ 676cce0e03bSab196087 APlist *rt_alias; /* list of linked file names */ 67708278a5eSRod Evans APlist *rt_fpnode; /* list of FullPathNode AVL nodes */ 6787c478bd9Sstevel@tonic-gate char *rt_runpath; /* LD_RUN_PATH and its equivalent */ 67956deab07SRod Evans Alist *rt_runlist; /* Pdesc structures */ 680cce0e03bSab196087 APlist *rt_depends; /* list of dependencies */ 681cce0e03bSab196087 APlist *rt_callers; /* list of callers */ 682cce0e03bSab196087 APlist *rt_handles; /* dlopen handles */ 683cce0e03bSab196087 APlist *rt_groups; /* groups we're a member of */ 6847c478bd9Sstevel@tonic-gate struct fct *rt_fct; /* file class table for this object */ 6857c478bd9Sstevel@tonic-gate void *rt_priv; /* private data, object type specific */ 6867c478bd9Sstevel@tonic-gate Lm_list *rt_list; /* link map list we belong to */ 6877c478bd9Sstevel@tonic-gate uint_t rt_objfltrndx; /* object filtees .dynamic index */ 6887c478bd9Sstevel@tonic-gate uint_t rt_symsfltrcnt; /* number of standard symbol filtees */ 6897c478bd9Sstevel@tonic-gate uint_t rt_symafltrcnt; /* number of auxiliary symbol filtees */ 6907c478bd9Sstevel@tonic-gate int rt_mode; /* usage mode, see RTLD mode flags */ 691dffec89cSrie int rt_sortval; /* temporary buffer to traverse graph */ 6927c478bd9Sstevel@tonic-gate uint_t rt_cycgroup; /* cyclic group */ 6937c478bd9Sstevel@tonic-gate dev_t rt_stdev; /* device id and inode number for .so */ 694cb511613SAli Bahrami rtld_ino_t rt_stino; /* multiple inclusion checks */ 69556deab07SRod Evans const char *rt_origname; /* original pathname of loaded object */ 6967c478bd9Sstevel@tonic-gate size_t rt_dirsz; /* and its size */ 69756deab07SRod Evans size_t rt_lmsize; /* size of the link-map allocation */ 698cce0e03bSab196087 Rt_map_copy rt_copy; /* list of copy relocations */ 6997c478bd9Sstevel@tonic-gate Audit_desc *rt_auditors; /* audit descriptor array */ 7007c478bd9Sstevel@tonic-gate Audit_info *rt_audinfo; /* audit information descriptor */ 7017c478bd9Sstevel@tonic-gate Syminfo *rt_syminfo; /* elf .syminfo section - here */ 7027c478bd9Sstevel@tonic-gate /* because it is checked in */ 7037c478bd9Sstevel@tonic-gate /* common code */ 704b23a7923SAli Bahrami Addr *rt_initarray; /* .init_array table */ 705b23a7923SAli Bahrami Addr *rt_finiarray; /* .fini_array table */ 706b23a7923SAli Bahrami Addr *rt_preinitarray; /* .preinit_array table */ 70756deab07SRod Evans mmapobj_result_t *rt_mmaps; /* array of mapping information */ 7087c478bd9Sstevel@tonic-gate uint_t rt_mmapcnt; /* and associated number */ 709b23a7923SAli Bahrami uint_t rt_initarraysz; /* size of .init_array table */ 710b23a7923SAli Bahrami uint_t rt_finiarraysz; /* size of .fini_array table */ 711b23a7923SAli Bahrami uint_t rt_preinitarraysz; /* size of .preinit_array table */ 7127c478bd9Sstevel@tonic-gate Dyninfo *rt_dyninfo; /* .dynamic information descriptors */ 7137c478bd9Sstevel@tonic-gate uint_t rt_dyninfocnt; /* count of dyninfo entries */ 7147c478bd9Sstevel@tonic-gate uint_t rt_relacount; /* no. of RELATIVE relocations */ 7157c478bd9Sstevel@tonic-gate uint_t rt_idx; /* hold index within linkmap list */ 716e0e63816SRod Evans uint_t rt_lazy; /* number of lazy dependencies */ 717e0e63816SRod Evans /* pending */ 71808278a5eSRod Evans Cap *rt_cap; /* capabilities data */ 71908278a5eSRod Evans Capchain *rt_capchain; /* capabilities chain data */ 7207c478bd9Sstevel@tonic-gate uint_t rt_cntl; /* link-map control list we belong to */ 72156deab07SRod Evans uint_t rt_aflags; /* auditor flags, see LML_TFLG_AUD_ */ 722*40a2899cSKeith M Wesolowski Rt_cond rt_cv; /* for waiting on flags changes */ 723*40a2899cSKeith M Wesolowski Rt_lock rt_lock; /* for coordinating flags changes */ 72456deab07SRod Evans /* address of _init */ 725*40a2899cSKeith M Wesolowski thread_t rt_init_thread; /* thread id in this lm's _init */ 72656deab07SRod Evans void (*rt_init)(void); 72756deab07SRod Evans /* address of _fini */ 72856deab07SRod Evans void (*rt_fini)(void); 72956deab07SRod Evans /* link map symbol interpreter */ 73008278a5eSRod Evans int (*rt_symintp)(Slookup *, Sresult *, uint_t *, int *); 7317c478bd9Sstevel@tonic-gate }; 7327c478bd9Sstevel@tonic-gate 7337c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32 7347c478bd9Sstevel@tonic-gate /* 7357c478bd9Sstevel@tonic-gate * Structure to allow 64-bit rtld_db to read 32-bit processes out of procfs. 7367c478bd9Sstevel@tonic-gate */ 737cce0e03bSab196087 typedef union { 738cce0e03bSab196087 uint32_t rtc_r; 739cce0e03bSab196087 uint32_t rtc_s; 740cce0e03bSab196087 } Rt_map_copy32; 741cce0e03bSab196087 7427c478bd9Sstevel@tonic-gate typedef struct rt_map32 { 7437c478bd9Sstevel@tonic-gate /* 7447c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 7457c478bd9Sstevel@tonic-gate */ 7467c478bd9Sstevel@tonic-gate Link_map32 rt_public; 7477c478bd9Sstevel@tonic-gate uint32_t rt_pathname; 7487c478bd9Sstevel@tonic-gate uint32_t rt_padstart; 7497c478bd9Sstevel@tonic-gate uint32_t rt_padimlen; 7507c478bd9Sstevel@tonic-gate uint32_t rt_msize; 7517c478bd9Sstevel@tonic-gate uint32_t rt_flags; 7527c478bd9Sstevel@tonic-gate uint32_t rt_flags1; 7537c478bd9Sstevel@tonic-gate uint32_t rt_tlsmodid; 7547c478bd9Sstevel@tonic-gate /* 7557c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 7567c478bd9Sstevel@tonic-gate */ 7577c478bd9Sstevel@tonic-gate uint32_t rt_alias; 7587c478bd9Sstevel@tonic-gate uint32_t rt_fpnode; 7597c478bd9Sstevel@tonic-gate uint32_t rt_runpath; 7607c478bd9Sstevel@tonic-gate uint32_t rt_runlist; 7617c478bd9Sstevel@tonic-gate uint32_t rt_depends; 7627c478bd9Sstevel@tonic-gate uint32_t rt_callers; 7637c478bd9Sstevel@tonic-gate uint32_t rt_handles; 7647c478bd9Sstevel@tonic-gate uint32_t rt_groups; 7657c478bd9Sstevel@tonic-gate uint32_t rt_fct; 7667c478bd9Sstevel@tonic-gate uint32_t rt_priv; 7677c478bd9Sstevel@tonic-gate uint32_t rt_list; 7687c478bd9Sstevel@tonic-gate uint32_t rt_objfltrndx; 7697c478bd9Sstevel@tonic-gate uint32_t rt_symsfltrcnt; 7707c478bd9Sstevel@tonic-gate uint32_t rt_symafltrcnt; 771dffec89cSrie int32_t rt_mode; 772dffec89cSrie int32_t rt_sortval; 7737c478bd9Sstevel@tonic-gate uint32_t rt_cycgroup; 7747c478bd9Sstevel@tonic-gate uint32_t rt_stdev; 7757c478bd9Sstevel@tonic-gate uint32_t rt_stino; 7767c478bd9Sstevel@tonic-gate uint32_t rt_origname; 7777c478bd9Sstevel@tonic-gate uint32_t rt_dirsz; 778cce0e03bSab196087 Rt_map_copy32 rt_copy; 7797c478bd9Sstevel@tonic-gate uint32_t rt_auditors; 7807c478bd9Sstevel@tonic-gate uint32_t rt_audinfo; 7817c478bd9Sstevel@tonic-gate uint32_t rt_syminfo; 7827c478bd9Sstevel@tonic-gate uint32_t rt_initarray; 7837c478bd9Sstevel@tonic-gate uint32_t rt_finiarray; 7847c478bd9Sstevel@tonic-gate uint32_t rt_preinitarray; 7857c478bd9Sstevel@tonic-gate uint32_t rt_mmaps; 7867c478bd9Sstevel@tonic-gate uint32_t rt_mmapcnt; 7877c478bd9Sstevel@tonic-gate uint32_t rt_initarraysz; 7887c478bd9Sstevel@tonic-gate uint32_t rt_finiarraysz; 7897c478bd9Sstevel@tonic-gate uint32_t rt_preinitarraysz; 7907c478bd9Sstevel@tonic-gate uint32_t rt_dyninfo; 7917c478bd9Sstevel@tonic-gate uint32_t rt_dyninfocnt; 7927c478bd9Sstevel@tonic-gate uint32_t rt_relacount; 7937c478bd9Sstevel@tonic-gate uint32_t rt_idx; 7947c478bd9Sstevel@tonic-gate uint32_t rt_lazy; 79508278a5eSRod Evans uint32_t rt_cap; 79608278a5eSRod Evans uint32_t rt_capchain; 7977c478bd9Sstevel@tonic-gate uint32_t rt_cntl; 79856deab07SRod Evans uint32_t rt_aflags; 79956deab07SRod Evans uint32_t rt_init; 80056deab07SRod Evans uint32_t rt_fini; 80156deab07SRod Evans uint32_t rt_symintp; 8027c478bd9Sstevel@tonic-gate } Rt_map32; 8037c478bd9Sstevel@tonic-gate 8047c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 8057c478bd9Sstevel@tonic-gate 8067c478bd9Sstevel@tonic-gate /* 8077c478bd9Sstevel@tonic-gate * Link map state flags. 8087c478bd9Sstevel@tonic-gate */ 8097c478bd9Sstevel@tonic-gate /* 8107c478bd9Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 8117c478bd9Sstevel@tonic-gate */ 8127c478bd9Sstevel@tonic-gate #define FLG_RT_ISMAIN 0x00000001 /* object represents main executable */ 8137c478bd9Sstevel@tonic-gate #define FLG_RT_IMGALLOC 0x00000002 /* image is allocated (not mmap'ed) */ 8147c478bd9Sstevel@tonic-gate /* 81556deab07SRod Evans * Available for r_debug version >= R_RTLDDB_VERSION5 8167c478bd9Sstevel@tonic-gate */ 8177c478bd9Sstevel@tonic-gate #define FLG_RT_RELOCED 0x00000004 /* object has been relocated */ 8187c478bd9Sstevel@tonic-gate /* 8197c478bd9Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 8207c478bd9Sstevel@tonic-gate */ 8217c478bd9Sstevel@tonic-gate #define FLG_RT_SETGROUP 0x00000008 /* group establishment required */ 82208278a5eSRod Evans #define FLG_RT_CAP 0x00000010 /* process $CAPABILITY expansion */ 8237c478bd9Sstevel@tonic-gate #define FLG_RT_OBJECT 0x00000020 /* object processing (ie. .o's) */ 824390b98b5Srie #define FLG_RT_NEWLOAD 0x00000040 /* object is newly loaded */ 8257c478bd9Sstevel@tonic-gate #define FLG_RT_NODUMP 0x00000080 /* object can't be dldump(3x)'ed */ 8267c478bd9Sstevel@tonic-gate #define FLG_RT_DELETE 0x00000100 /* object can be deleted */ 8277c478bd9Sstevel@tonic-gate #define FLG_RT_ANALYZED 0x00000200 /* object has been analyzed */ 8287c478bd9Sstevel@tonic-gate #define FLG_RT_INITDONE 0x00000400 /* objects .init has been completed */ 8297c478bd9Sstevel@tonic-gate #define FLG_RT_TRANS 0x00000800 /* object is acting as a translator */ 8307c478bd9Sstevel@tonic-gate #define FLG_RT_FIXED 0x00001000 /* image location is fixed */ 8317c478bd9Sstevel@tonic-gate #define FLG_RT_PRELOAD 0x00002000 /* object was preloaded */ 8327c478bd9Sstevel@tonic-gate #define FLG_RT_ALTER 0x00004000 /* alternative object used */ 8337c478bd9Sstevel@tonic-gate #define FLG_RT_LOADFLTR 0x00008000 /* trigger filtee loading */ 8347c478bd9Sstevel@tonic-gate #define FLG_RT_AUDIT 0x00010000 /* object is an auditor */ 8357c478bd9Sstevel@tonic-gate #define FLG_RT_MODESET 0x00020000 /* MODE() has been initialized */ 8367c478bd9Sstevel@tonic-gate #define FLG_RT_ANALZING 0x00040000 /* object is being analyzed */ 8377c478bd9Sstevel@tonic-gate #define FLG_RT_INITFRST 0x00080000 /* execute .init first */ 8387c478bd9Sstevel@tonic-gate #define FLG_RT_NOOPEN 0x00100000 /* dlopen() not allowed */ 8397c478bd9Sstevel@tonic-gate #define FLG_RT_FINICLCT 0x00200000 /* fini has been collected (tsort) */ 8407c478bd9Sstevel@tonic-gate #define FLG_RT_INITCALL 0x00400000 /* objects .init has been called */ 84135450702SAli Bahrami #define FLG_RT_OBJINTPO 0x00800000 /* object is a global interposer */ 84235450702SAli Bahrami #define FLG_RT_SYMINTPO 0x01000000 /* object contains symbol interposer */ 84335450702SAli Bahrami #define MSK_RT_INTPOSE 0x01800000 /* mask for all interposer */ 8449a411307Srie /* possibilities */ 84535450702SAli Bahrami #define FLG_RT_MOVE 0x02000000 /* object needs move operation */ 8462017c965SRod Evans #define FLG_RT_RELOCING 0x04000000 /* object is being relocated */ 84735450702SAli Bahrami #define FLG_RT_REGSYMS 0x08000000 /* object has DT_REGISTER entries */ 84835450702SAli Bahrami #define FLG_RT_INITCLCT 0x10000000 /* init has been collected (tsort) */ 8492017c965SRod Evans #define FLG_RT_PUBHDL 0x20000000 /* generate a handle for this object */ 8502017c965SRod Evans #define FLG_RT_PRIHDL 0x40000000 /* either public or private */ 8517c478bd9Sstevel@tonic-gate 8527c478bd9Sstevel@tonic-gate #define FL1_RT_COPYTOOK 0x00000001 /* copy relocation taken */ 85308278a5eSRod Evans #define FL1_RT_ALTCHECK 0x00000002 /* alternative system capabilities */ 85408278a5eSRod Evans /* checked */ 85508278a5eSRod Evans #define FL1_RT_ALTCAP 0x00000004 /* alternative system capabilities */ 85608278a5eSRod Evans /* should be used */ 85708278a5eSRod Evans #define FL1_RT_CONFSET 0x00000008 /* object was loaded by crle(1) */ 85808278a5eSRod Evans #define FL1_RT_NODEFLIB 0x00000010 /* ignore default library search */ 85908278a5eSRod Evans #define FL1_RT_ENDFILTE 0x00000020 /* filtee terminates filters search */ 86008278a5eSRod Evans #define FL1_RT_DISPREL 0x00000040 /* object has *disp* relocation */ 86108278a5eSRod Evans #define FL1_RT_DTFLAGS 0x00000080 /* DT_FLAGS element exists */ 8627c478bd9Sstevel@tonic-gate #define FL1_RT_LDDSTUB 0x00000100 /* identify lddstub */ 8637c478bd9Sstevel@tonic-gate #define FL1_RT_NOINIFIN 0x00000200 /* no .init or .fini exists */ 8647c478bd9Sstevel@tonic-gate #define FL1_RT_USED 0x00000400 /* symbol referenced from this object */ 8657c478bd9Sstevel@tonic-gate #define FL1_RT_SYMBOLIC 0x00000800 /* DF_SYMBOLIC was set - use */ 8667c478bd9Sstevel@tonic-gate /* symbolic sym resolution */ 8677c478bd9Sstevel@tonic-gate #define FL1_RT_OBJSFLTR 0x00001000 /* object is acting as a standard */ 8687c478bd9Sstevel@tonic-gate #define FL1_RT_OBJAFLTR 0x00002000 /* or auxiliary filter */ 8697c478bd9Sstevel@tonic-gate #define FL1_RT_SYMSFLTR 0x00004000 /* symbol is acting as a standard */ 8707c478bd9Sstevel@tonic-gate #define FL1_RT_SYMAFLTR 0x00008000 /* or auxiliary filter */ 8718af2c5b9Srie #define MSK_RT_FILTER 0x0000f000 /* mask for all filter possibilities */ 8727c478bd9Sstevel@tonic-gate 87310a4fa49Srie #define FL1_RT_TLSADD 0x00010000 /* objects TLS has been registered */ 874d326b23bSrie #define FL1_RT_TLSSTAT 0x00020000 /* object requires static TLS */ 8759a411307Srie #define FL1_RT_DIRECT 0x00040000 /* object has DIRECT bindings enabled */ 8767247f888Srie #define FL1_RT_GLOBAUD 0x00080000 /* establish global auditing */ 877b533f56bSRobert Mustacchi #define FL1_RT_DEPAUD 0x00100000 /* audit library from DT_DEPAUDIT */ 87810a4fa49Srie 8797c478bd9Sstevel@tonic-gate /* 8807c478bd9Sstevel@tonic-gate * Flags for the tls_modactivity() routine 8817c478bd9Sstevel@tonic-gate */ 8827c478bd9Sstevel@tonic-gate #define TM_FLG_MODADD 0x01 /* call tls_modadd() interface */ 8837c478bd9Sstevel@tonic-gate #define TM_FLG_MODREM 0x02 /* call tls_modrem() interface */ 8847c478bd9Sstevel@tonic-gate 8857c478bd9Sstevel@tonic-gate /* 88656deab07SRod Evans * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION <= 2). 8877c478bd9Sstevel@tonic-gate */ 8887c478bd9Sstevel@tonic-gate #define ADDR(X) ((X)->rt_public.l_addr) 8897c478bd9Sstevel@tonic-gate #define NAME(X) ((X)->rt_public.l_name) 8907c478bd9Sstevel@tonic-gate #define DYN(X) ((X)->rt_public.l_ld) 8917c478bd9Sstevel@tonic-gate #define NEXT(X) ((X)->rt_public.l_next) 8927c478bd9Sstevel@tonic-gate #define PREV(X) ((X)->rt_public.l_prev) 8937c478bd9Sstevel@tonic-gate #define REFNAME(X) ((X)->rt_public.l_refname) 8947c478bd9Sstevel@tonic-gate 8957c478bd9Sstevel@tonic-gate /* 896cb511613SAli Bahrami * An Rt_map starts with a Link_map, followed by other information. 897cb511613SAli Bahrami * ld.so.1 allocates Rt_map structures, and then casts them to Link_map, 898cb511613SAli Bahrami * and back, depending on context. 899cb511613SAli Bahrami * 900cb511613SAli Bahrami * On some platforms, Rt_map can have a higher alignment requirement 901cb511613SAli Bahrami * than Link_map. On such platforms, the cast from Link_map to Rt_map will 902cb511613SAli Bahrami * draw an E_BAD_PTR_CAST_ALIGN warning from lint. Since we allocate 903cb511613SAli Bahrami * the memory as the higher alignment Rt_map, we know that this is a safe 904cb511613SAli Bahrami * conversion. The LINKMAP_TO_RTMAP macro is used to handle the conversion 905cb511613SAli Bahrami * in a manner that satisfies lint. 906cb511613SAli Bahrami */ 907cb511613SAli Bahrami #ifdef lint 908cb511613SAli Bahrami #define LINKMAP_TO_RTMAP(X) (Rt_map *)(void *)(X) 909cb511613SAli Bahrami #else 910cb511613SAli Bahrami #define LINKMAP_TO_RTMAP(X) (Rt_map *)(X) 911cb511613SAli Bahrami #endif 912cb511613SAli Bahrami 913cb511613SAli Bahrami /* 914cb511613SAli Bahrami * Convenience macros for the common case of using 915cb511613SAli Bahrami * NEXT()/PREV() and casting the result to (Rt_map *) 916cb511613SAli Bahrami */ 917cb511613SAli Bahrami #define NEXT_RT_MAP(X) LINKMAP_TO_RTMAP(NEXT(X)) 918cb511613SAli Bahrami #define PREV_RT_MAP(X) LINKMAP_TO_RTMAP(PREV(X)) 919cb511613SAli Bahrami 920cb511613SAli Bahrami /* 92156deab07SRod Evans * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION3). 9227c478bd9Sstevel@tonic-gate */ 9237c478bd9Sstevel@tonic-gate #define PATHNAME(X) ((X)->rt_pathname) 9247c478bd9Sstevel@tonic-gate #define PADSTART(X) ((X)->rt_padstart) 9257c478bd9Sstevel@tonic-gate #define PADIMLEN(X) ((X)->rt_padimlen) 9267c478bd9Sstevel@tonic-gate #define MSIZE(X) ((X)->rt_msize) 9277c478bd9Sstevel@tonic-gate #define FLAGS(X) ((X)->rt_flags) 9287c478bd9Sstevel@tonic-gate #define FLAGS1(X) ((X)->rt_flags1) 92956deab07SRod Evans 93056deab07SRod Evans /* 93156deab07SRod Evans * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION4). 93256deab07SRod Evans */ 9337c478bd9Sstevel@tonic-gate #define TLSMODID(X) ((X)->rt_tlsmodid) 9347c478bd9Sstevel@tonic-gate 93556deab07SRod Evans /* 93656deab07SRod Evans * Macros for getting to unexposed, link-map data. 93756deab07SRod Evans */ 93856deab07SRod Evans #define LMSIZE(X) ((X)->rt_lmsize) 93956deab07SRod Evans #define AFLAGS(X) ((X)->rt_aflags) 9407c478bd9Sstevel@tonic-gate #define ALIAS(X) ((X)->rt_alias) 9417c478bd9Sstevel@tonic-gate #define FPNODE(X) ((X)->rt_fpnode) 9427c478bd9Sstevel@tonic-gate #define INIT(X) ((X)->rt_init) 9437c478bd9Sstevel@tonic-gate #define FINI(X) ((X)->rt_fini) 9447c478bd9Sstevel@tonic-gate #define RPATH(X) ((X)->rt_runpath) 9457c478bd9Sstevel@tonic-gate #define RLIST(X) ((X)->rt_runlist) 9467c478bd9Sstevel@tonic-gate #define DEPENDS(X) ((X)->rt_depends) 9477c478bd9Sstevel@tonic-gate #define CALLERS(X) ((X)->rt_callers) 9487c478bd9Sstevel@tonic-gate #define HANDLES(X) ((X)->rt_handles) 9497c478bd9Sstevel@tonic-gate #define GROUPS(X) ((X)->rt_groups) 9507c478bd9Sstevel@tonic-gate #define FCT(X) ((X)->rt_fct) 9517c478bd9Sstevel@tonic-gate #define SYMINTP(X) ((X)->rt_symintp) 9527c478bd9Sstevel@tonic-gate #define LIST(X) ((X)->rt_list) 9537c478bd9Sstevel@tonic-gate #define OBJFLTRNDX(X) ((X)->rt_objfltrndx) 9547c478bd9Sstevel@tonic-gate #define SYMSFLTRCNT(X) ((X)->rt_symsfltrcnt) 9557c478bd9Sstevel@tonic-gate #define SYMAFLTRCNT(X) ((X)->rt_symafltrcnt) 9567c478bd9Sstevel@tonic-gate #define MODE(X) ((X)->rt_mode) 9577c478bd9Sstevel@tonic-gate #define SORTVAL(X) ((X)->rt_sortval) 9587c478bd9Sstevel@tonic-gate #define CYCGROUP(X) ((X)->rt_cycgroup) 9597c478bd9Sstevel@tonic-gate #define STDEV(X) ((X)->rt_stdev) 9607c478bd9Sstevel@tonic-gate #define STINO(X) ((X)->rt_stino) 9617c478bd9Sstevel@tonic-gate #define ORIGNAME(X) ((X)->rt_origname) 9627c478bd9Sstevel@tonic-gate #define DIRSZ(X) ((X)->rt_dirsz) 963cce0e03bSab196087 #define COPY_R(X) ((X)->rt_copy.rtc_r) 964cce0e03bSab196087 #define COPY_S(X) ((X)->rt_copy.rtc_s) 9657c478bd9Sstevel@tonic-gate #define AUDITORS(X) ((X)->rt_auditors) 9667c478bd9Sstevel@tonic-gate #define AUDINFO(X) ((X)->rt_audinfo) 9677c478bd9Sstevel@tonic-gate #define SYMINFO(X) ((X)->rt_syminfo) 9687c478bd9Sstevel@tonic-gate #define INITARRAY(X) ((X)->rt_initarray) 9697c478bd9Sstevel@tonic-gate #define FINIARRAY(X) ((X)->rt_finiarray) 9707c478bd9Sstevel@tonic-gate #define PREINITARRAY(X) ((X)->rt_preinitarray) 9717c478bd9Sstevel@tonic-gate #define MMAPS(X) ((X)->rt_mmaps) 9727c478bd9Sstevel@tonic-gate #define MMAPCNT(X) ((X)->rt_mmapcnt) 9737c478bd9Sstevel@tonic-gate #define INITARRAYSZ(X) ((X)->rt_initarraysz) 9747c478bd9Sstevel@tonic-gate #define FINIARRAYSZ(X) ((X)->rt_finiarraysz) 9757c478bd9Sstevel@tonic-gate #define PREINITARRAYSZ(X) ((X)->rt_preinitarraysz) 9767c478bd9Sstevel@tonic-gate #define DYNINFO(X) ((X)->rt_dyninfo) 9777c478bd9Sstevel@tonic-gate #define DYNINFOCNT(X) ((X)->rt_dyninfocnt) 9787c478bd9Sstevel@tonic-gate #define RELACOUNT(X) ((X)->rt_relacount) 9797c478bd9Sstevel@tonic-gate #define IDX(X) ((X)->rt_idx) 9807c478bd9Sstevel@tonic-gate #define LAZY(X) ((X)->rt_lazy) 9817c478bd9Sstevel@tonic-gate #define CNTL(X) ((X)->rt_cntl) 98208278a5eSRod Evans #define CAP(X) ((X)->rt_cap) 98308278a5eSRod Evans #define CAPCHAIN(X) ((X)->rt_capchain) 9847c478bd9Sstevel@tonic-gate 985dffec89cSrie /* 986dffec89cSrie * Flags for tsorting. 987dffec89cSrie */ 988dffec89cSrie #define RT_SORT_FWD 0x01 /* topological sort (.fini) */ 989dffec89cSrie #define RT_SORT_REV 0x02 /* reverse topological sort (.init) */ 99056deab07SRod Evans #define RT_SORT_DELETE 0x10 /* process FLG_RT_DELETE objects */ 991dffec89cSrie /* only (called via dlclose()) */ 992883c6d49Srie #define RT_SORT_INTPOSE 0x20 /* process interposer objects */ 993883c6d49Srie 9947c478bd9Sstevel@tonic-gate /* 9957c478bd9Sstevel@tonic-gate * Flags for lookup_sym (and hence find_sym) routines. 9967c478bd9Sstevel@tonic-gate */ 9977c478bd9Sstevel@tonic-gate #define LKUP_DEFT 0x0000 /* simple lookup request */ 9987c478bd9Sstevel@tonic-gate #define LKUP_SPEC 0x0001 /* special ELF lookup (allows address */ 9997c478bd9Sstevel@tonic-gate /* resolutions to plt[] entries) */ 10007c478bd9Sstevel@tonic-gate #define LKUP_LDOT 0x0002 /* indicates the original A_OUT */ 10017c478bd9Sstevel@tonic-gate /* symbol had a leading `.' */ 10027c478bd9Sstevel@tonic-gate #define LKUP_FIRST 0x0004 /* lookup symbol in first link map */ 10037c478bd9Sstevel@tonic-gate /* only */ 10047c478bd9Sstevel@tonic-gate #define LKUP_COPY 0x0008 /* lookup symbol for a COPY reloc, do */ 10057c478bd9Sstevel@tonic-gate /* not bind to symbol at head */ 100660758829Srie #define LKUP_STDRELOC 0x0010 /* lookup originates from a standard */ 100760758829Srie /* relocation (elf_reloc()) */ 10087c478bd9Sstevel@tonic-gate #define LKUP_SELF 0x0020 /* lookup symbol in ourself - undef */ 10097c478bd9Sstevel@tonic-gate /* is valid */ 10107c478bd9Sstevel@tonic-gate #define LKUP_WEAK 0x0040 /* relocation reference is weak */ 10117c478bd9Sstevel@tonic-gate #define LKUP_NEXT 0x0080 /* request originates from RTLD_NEXT */ 10127c478bd9Sstevel@tonic-gate #define LKUP_NODESCENT 0x0100 /* don't descend through dependencies */ 101375e7992aSrie #define LKUP_NOFALLBACK 0x0200 /* don't fall back to loading */ 10147c478bd9Sstevel@tonic-gate /* pending lazy dependencies */ 10157c478bd9Sstevel@tonic-gate #define LKUP_DIRECT 0x0400 /* direct binding request */ 1016660acd81Srie #define LKUP_SYMNDX 0x0800 /* establish symbol index */ 101760758829Srie #define LKUP_SINGLETON 0x1000 /* search for a singleton symbol */ 101860758829Srie #define LKUP_STANDARD 0x2000 /* standard lookup - originated from */ 101960758829Srie /* head link-map element */ 102037ffaf83SRod Evans #define LKUP_WORLD 0x4000 /* ensure world lookup */ 102108278a5eSRod Evans #define LKUP_DLSYM 0x8000 /* lookup stems from dlsym() request */ 10227c478bd9Sstevel@tonic-gate 10237c478bd9Sstevel@tonic-gate /* 102475e7992aSrie * For the runtime linker to perform a symbol search, a number of data items 102575e7992aSrie * related to the search are required. An Slookup data structure is used to 102675e7992aSrie * convey this data to lookup_sym(), and in special cases, to other core 102775e7992aSrie * routines that provide the implementation details for lookup_sym() 102875e7992aSrie * 102975e7992aSrie * The symbol name (sl_name), the caller (sl_cmap), and the link-map from which 103075e7992aSrie * to start the search (sl_imap) are fundamental to the symbol search. The 103175e7992aSrie * initial search link-map might get modified by the core routines that provide 103275e7992aSrie * the implementation details for lookup_sym(). This modification accommodates 103375e7992aSrie * requirements such as processing a handle, direct binding and interposition. 103475e7992aSrie * The association between the caller and the potential destination also 103575e7992aSrie * determines whether the destination is a candidate to search. 103675e7992aSrie * 103775e7992aSrie * The lookup identifier (sl_id) is used to identify a runtime linker operation. 103875e7992aSrie * Within this operation, any lazy loads that fail are not re-examined. This 103975e7992aSrie * technique keeps the overhead of processing a failed lazy load to a minimum. 104075e7992aSrie * 104175e7992aSrie * Symbol searches that originate from a relocation record are accompanied by 104275e7992aSrie * the relocation index (sl_rsymndx), the symbol reference (sl_rsym) and 104375e7992aSrie * possibly the relocation type (sl_rtype). This data provides for determining 104475e7992aSrie * lazy loading, direct binding, and special symbol processing requirements 104575e7992aSrie * such as copy relocations and singleton lookup. 104675e7992aSrie * 104775e7992aSrie * The symbols hash value is computed by lookup_sym, and propagated throughout 104875e7992aSrie * the search engine. Note, occasionally the Slookup data is passed to a core 104975e7992aSrie * routine that provides the implementation details for lookup_sym(), ie. 105075e7992aSrie * elf_find_sym(), in which case the caller must initialize the hash value. 105175e7992aSrie * 105275e7992aSrie * The symbols binding information is established by lookup_sym() when the 105375e7992aSrie * symbols relocation type is supplied. Weak bindings allow relocations to 105475e7992aSrie * be set to zero should a symbol lookup fail. 105575e7992aSrie * 105675e7992aSrie * The flags allow the caller to control aspects of the search, including the 105775e7992aSrie * interpretation of copy relocations, etc. Note, a number of flag settings 105875e7992aSrie * are established in lookup_sym() from attributes of the symbol reference. 10597c478bd9Sstevel@tonic-gate */ 106056deab07SRod Evans struct slookup { 10617c478bd9Sstevel@tonic-gate const char *sl_name; /* symbol name */ 10627c478bd9Sstevel@tonic-gate Rt_map *sl_cmap; /* callers link-map */ 10637c478bd9Sstevel@tonic-gate Rt_map *sl_imap; /* initial link-map to search */ 106475e7992aSrie ulong_t sl_id; /* identifier for this lookup */ 10657c478bd9Sstevel@tonic-gate ulong_t sl_hash; /* symbol hash value */ 10667c478bd9Sstevel@tonic-gate ulong_t sl_rsymndx; /* referencing reloc symndx */ 106760758829Srie Sym *sl_rsym; /* referencing symbol */ 106860758829Srie uchar_t sl_rtype; /* relocation type associate with */ 106960758829Srie /* symbol */ 107060758829Srie uchar_t sl_bind; /* symbols binding (returned) */ 10717c478bd9Sstevel@tonic-gate uint_t sl_flags; /* lookup flags */ 107256deab07SRod Evans }; 10737c478bd9Sstevel@tonic-gate 107475e7992aSrie #define SLOOKUP_INIT(sl, name, cmap, imap, id, hash, rsymndx, rsym, rtype, \ 107575e7992aSrie flags) \ 107675e7992aSrie (void) (sl.sl_name = (name), sl.sl_cmap = (cmap), sl.sl_imap = (imap), \ 107775e7992aSrie sl.sl_id = (id), sl.sl_hash = (hash), sl.sl_rsymndx = (rsymndx), \ 107875e7992aSrie sl.sl_rsym = (rsym), sl.sl_rtype = (rtype), sl.sl_bind = 0, \ 107975e7992aSrie sl.sl_flags = (flags)) 10807c478bd9Sstevel@tonic-gate 108175e7992aSrie /* 108208278a5eSRod Evans * After a symbol lookup has been resolved, the runtime linker needs to retain 108308278a5eSRod Evans * information regarding the bound definition. An Sresult data structure is 108408278a5eSRod Evans * used to provide this information. 108508278a5eSRod Evans * 108608278a5eSRod Evans * The symbol name (sr_name) may differ from the original referenced symbol if 108708278a5eSRod Evans * a symbol capabilities family member has resolved the binding. The defining 108808278a5eSRod Evans * object (sr_dmap) indicates the object in which the definition has been found. 108908278a5eSRod Evans * The symbol table entry (sr_sym) defines the bound symbol definition. 109008278a5eSRod Evans * 109108278a5eSRod Evans * Note, a symbol lookup may start with one Sresult buffer, but underlying 109208278a5eSRod Evans * routines (for example, those that probe filters) might employ their own 109308278a5eSRod Evans * Sresult buffer. If a binding is allowed, the latter buffer may get inherited 109408278a5eSRod Evans * by the former. Along with this chain of requests, binding info (binfo) and 109508278a5eSRod Evans * not-found information (in_nfavl), may be passed between all the associated 109608278a5eSRod Evans * functions. Hence, the binfo and in_nfavl data is not maintained as part of 109708278a5eSRod Evans * a Sresult structure. 109808278a5eSRod Evans */ 109908278a5eSRod Evans struct sresult { 110008278a5eSRod Evans const char *sr_name; /* symbol definition name */ 110108278a5eSRod Evans Rt_map *sr_dmap; /* defining objects link-map */ 110208278a5eSRod Evans Sym *sr_sym; /* symbol table pointer */ 110308278a5eSRod Evans }; 110408278a5eSRod Evans 110508278a5eSRod Evans #define SRESULT_INIT(sr, name) \ 110608278a5eSRod Evans (void) (sr.sr_name = (name), sr.sr_dmap = NULL, sr.sr_sym = NULL) 110708278a5eSRod Evans 110808278a5eSRod Evans /* 110908278a5eSRod Evans * Define a system capabilities structure for maintaining the various 111008278a5eSRod Evans * capabilities of the system. This structure follows the Objcapset definition 111108278a5eSRod Evans * from libld.h, however the system can only have one platform or machine 111208278a5eSRod Evans * hardware name, thus this structure is a little simpler. 1113f3390f39SRobert Mustacchi * 1114f3390f39SRobert Mustacchi * Note, the amd64 version of elf_rtbndr assumes that the sc_hw_1 value is at 1115f3390f39SRobert Mustacchi * offset zero. If you are changing this structure in a way that invalidates 1116f3390f39SRobert Mustacchi * this you need to update that code. 111708278a5eSRod Evans */ 111808278a5eSRod Evans typedef struct { 111908278a5eSRod Evans elfcap_mask_t sc_hw_1; /* CA_SUNW_HW_1 capabilities */ 112008278a5eSRod Evans elfcap_mask_t sc_sf_1; /* CA_SUNW_SF_1 capabilities */ 112108278a5eSRod Evans elfcap_mask_t sc_hw_2; /* CA_SUNW_HW_2 capabilities */ 112208278a5eSRod Evans char *sc_plat; /* CA_SUNW_PLAT capability */ 112308278a5eSRod Evans size_t sc_platsz; /* and size */ 112408278a5eSRod Evans char *sc_mach; /* CA_SUNW_MACH capability */ 112508278a5eSRod Evans size_t sc_machsz; /* and size */ 112608278a5eSRod Evans } Syscapset; 112708278a5eSRod Evans 112808278a5eSRod Evans /* 112975e7992aSrie * Define a number of .plt lookup outcomes, for use in binding diagnostics. 113075e7992aSrie */ 11317c478bd9Sstevel@tonic-gate typedef enum { 11327c478bd9Sstevel@tonic-gate PLT_T_NONE = 0, 11337c478bd9Sstevel@tonic-gate PLT_T_21D, 11347c478bd9Sstevel@tonic-gate PLT_T_24D, 11357c478bd9Sstevel@tonic-gate PLT_T_U32, 11367c478bd9Sstevel@tonic-gate PLT_T_U44, 11377c478bd9Sstevel@tonic-gate PLT_T_FULL, 11387c478bd9Sstevel@tonic-gate PLT_T_FAR, 11397c478bd9Sstevel@tonic-gate PLT_T_NUM /* Must be last */ 11407c478bd9Sstevel@tonic-gate } Pltbindtype; 11417c478bd9Sstevel@tonic-gate 11427c478bd9Sstevel@tonic-gate /* 11437c478bd9Sstevel@tonic-gate * Prototypes. 11447c478bd9Sstevel@tonic-gate */ 114575e7992aSrie extern ulong_t ld_entry_cnt; /* counter bumped on each entry to */ 114675e7992aSrie /* ld.so.1. */ 11477c478bd9Sstevel@tonic-gate extern Lm_list lml_main; /* main's link map list */ 11487c478bd9Sstevel@tonic-gate extern Lm_list lml_rtld; /* rtld's link map list */ 11497c478bd9Sstevel@tonic-gate extern Lm_list *lml_list[]; 11507c478bd9Sstevel@tonic-gate 11517c478bd9Sstevel@tonic-gate extern Pltbindtype elf_plt_write(uintptr_t, uintptr_t, void *, uintptr_t, 11527c478bd9Sstevel@tonic-gate Xword); 11539aa23310Srie extern Rt_map *is_so_loaded(Lm_list *, const char *, int *); 115408278a5eSRod Evans extern int lookup_sym(Slookup *, Sresult *, uint_t *, int *); 11557c478bd9Sstevel@tonic-gate extern int rt_dldump(Rt_map *, const char *, int, Addr); 11567c478bd9Sstevel@tonic-gate 11577c478bd9Sstevel@tonic-gate #ifdef __cplusplus 11587c478bd9Sstevel@tonic-gate } 11597c478bd9Sstevel@tonic-gate #endif 11607c478bd9Sstevel@tonic-gate 11617c478bd9Sstevel@tonic-gate #endif /* _RTLD_H */ 1162