10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51618Srie * Common Development and Distribution License (the "License"). 61618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211618Srie 220Sstevel@tonic-gate /* 2312449SRod.Evans@Sun.COM * Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate #ifndef _RTLD_H 260Sstevel@tonic-gate #define _RTLD_H 270Sstevel@tonic-gate 280Sstevel@tonic-gate /* 291824Srie * Global include file for the runtime linker. 300Sstevel@tonic-gate */ 318598SRod.Evans@Sun.COM #include <sys/mman.h> 320Sstevel@tonic-gate #include <time.h> 330Sstevel@tonic-gate #include <sgs.h> 340Sstevel@tonic-gate #include <thread.h> 350Sstevel@tonic-gate #include <synch.h> 366206Sab196087 #include <link.h> 370Sstevel@tonic-gate #include <sys/avl.h> 380Sstevel@tonic-gate #include <alist.h> 391824Srie #include <libc_int.h> 4011827SRod.Evans@Sun.COM #include <elfcap.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #ifdef _SYSCALL32 430Sstevel@tonic-gate #include <inttypes.h> 440Sstevel@tonic-gate #endif 450Sstevel@tonic-gate 460Sstevel@tonic-gate #ifdef __cplusplus 470Sstevel@tonic-gate extern "C" { 480Sstevel@tonic-gate #endif 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* 518394SAli.Bahrami@Sun.COM * We use rtld_ino_t instead of ino_t so that we can get 528394SAli.Bahrami@Sun.COM * access to large inode values from 32-bit code. 538394SAli.Bahrami@Sun.COM */ 548394SAli.Bahrami@Sun.COM #ifdef _LP64 558394SAli.Bahrami@Sun.COM typedef ino_t rtld_ino_t; 568394SAli.Bahrami@Sun.COM #else 578394SAli.Bahrami@Sun.COM typedef ino64_t rtld_ino_t; 588394SAli.Bahrami@Sun.COM #endif 598394SAli.Bahrami@Sun.COM 600Sstevel@tonic-gate typedef struct rt_map Rt_map; 618598SRod.Evans@Sun.COM typedef struct slookup Slookup; 6211827SRod.Evans@Sun.COM typedef struct sresult Sresult; 630Sstevel@tonic-gate 640Sstevel@tonic-gate /* 650Sstevel@tonic-gate * A binding descriptor. Establishes the binding relationship between two 661618Srie * objects, the caller (originator) and the dependency (destination). 679577SRod.Evans@Sun.COM * 689577SRod.Evans@Sun.COM * Every relationship between two objects is tracked by a binding descriptor. 699577SRod.Evans@Sun.COM * This descriptor is referenced from a link-map's DEPENDS and CALLERS lists. 709577SRod.Evans@Sun.COM * Note, Aplist's are diagramed to fully expose the allocations required to 719577SRod.Evans@Sun.COM * establish the data structure relationships. 729577SRod.Evans@Sun.COM * 739577SRod.Evans@Sun.COM * Bnd_desc 749577SRod.Evans@Sun.COM * ---------- 759577SRod.Evans@Sun.COM * ------------| b_caller | 769577SRod.Evans@Sun.COM * | | b_depend | ---------- 779577SRod.Evans@Sun.COM * | | | | 789577SRod.Evans@Sun.COM * Rt_map | ---------- | Rt_map 799577SRod.Evans@Sun.COM * ---------- | ^ ^ | ---------- 809577SRod.Evans@Sun.COM * | | <-- | | --> | | 819577SRod.Evans@Sun.COM * | | -------- | | | | 829577SRod.Evans@Sun.COM * | DEPENDS | ----> | | | | -------- | | 839577SRod.Evans@Sun.COM * | | | | | | | | <---- | CALLERS | 849577SRod.Evans@Sun.COM * | | | | --- | | | | | 859577SRod.Evans@Sun.COM * | | | | --- | | | | 869577SRod.Evans@Sun.COM * | | -------- | | | | 879577SRod.Evans@Sun.COM * ---------- Aplist -------- ---------- 889577SRod.Evans@Sun.COM * Aplist 890Sstevel@tonic-gate */ 900Sstevel@tonic-gate typedef struct { 910Sstevel@tonic-gate Rt_map *b_caller; /* caller (originator) of a binding */ 920Sstevel@tonic-gate Rt_map *b_depend; /* dependency (destination) of a */ 930Sstevel@tonic-gate /* binding */ 940Sstevel@tonic-gate uint_t b_flags; /* relationship of caller to the */ 950Sstevel@tonic-gate /* dependency */ 960Sstevel@tonic-gate } Bnd_desc; 970Sstevel@tonic-gate 980Sstevel@tonic-gate #define BND_NEEDED 0x0001 /* caller NEEDED the dependency */ 990Sstevel@tonic-gate #define BND_REFER 0x0002 /* caller relocation references the */ 1000Sstevel@tonic-gate /* dependency */ 1019577SRod.Evans@Sun.COM #define BND_FILTER 0x0004 /* binding identifies filter, used */ 1029577SRod.Evans@Sun.COM /* for diagnostics only */ 1030Sstevel@tonic-gate /* 1040Sstevel@tonic-gate * Private structure for communication between rtld_db and rtld. 1050Sstevel@tonic-gate * 1061824Srie * We must bump the version number when ever an update in one of the 1071824Srie * structures/fields that rtld_db reads is updated. This hopefully permits 1081824Srie * rtld_db implementations of the future to recognize core files produced on 1091824Srie * older systems and deal with these core files accordingly. 1100Sstevel@tonic-gate * 1118598SRod.Evans@Sun.COM * As of version 'R_RTLDDB_VERSION <= 2' the following fields were valid for 1128598SRod.Evans@Sun.COM * core file examination (basically the public Link_map): 1130Sstevel@tonic-gate * 1140Sstevel@tonic-gate * ADDR() 1150Sstevel@tonic-gate * NAME() 1160Sstevel@tonic-gate * DYN() 1170Sstevel@tonic-gate * NEXT() 1180Sstevel@tonic-gate * PREV() 1190Sstevel@tonic-gate * 1208598SRod.Evans@Sun.COM * Valid fields for R_RTLDDB_VERSION3 1210Sstevel@tonic-gate * 1220Sstevel@tonic-gate * PATHNAME() 1230Sstevel@tonic-gate * PADSTART() 1240Sstevel@tonic-gate * PADIMLEN() 1250Sstevel@tonic-gate * MSIZE() 1260Sstevel@tonic-gate * FLAGS() 1270Sstevel@tonic-gate * FLAGS1() 1280Sstevel@tonic-gate * 1298598SRod.Evans@Sun.COM * Valid fields for R_RTLDDB_VERSION4 1300Sstevel@tonic-gate * 1310Sstevel@tonic-gate * TLSMODID() 1320Sstevel@tonic-gate * 1338598SRod.Evans@Sun.COM * Valid fields for R_RTLDDB_VERSION5 1340Sstevel@tonic-gate * 1350Sstevel@tonic-gate * Added rtld_flags & FLG_RT_RELOCED to stable flags range 1360Sstevel@tonic-gate * 13710167SRod.Evans@Sun.COM * Valid fields for R_RTLDDB_VERSION6 13810167SRod.Evans@Sun.COM * 13910167SRod.Evans@Sun.COM * rtd_dynlmlst converted from a List to APlist 1400Sstevel@tonic-gate */ 1410Sstevel@tonic-gate #define R_RTLDDB_VERSION1 1 /* base version level - used for core */ 1420Sstevel@tonic-gate /* file examination */ 1431824Srie #define R_RTLDDB_VERSION2 2 /* minor revision - not relevant for */ 1440Sstevel@tonic-gate /* core files */ 1450Sstevel@tonic-gate #define R_RTLDDB_VERSION3 3 1460Sstevel@tonic-gate #define R_RTLDDB_VERSION4 4 1470Sstevel@tonic-gate #define R_RTLDDB_VERSION5 5 14810167SRod.Evans@Sun.COM #define R_RTLDDB_VERSION6 6 14910167SRod.Evans@Sun.COM #define R_RTLDDB_VERSION R_RTLDDB_VERSION6 /* current version */ 1500Sstevel@tonic-gate 1510Sstevel@tonic-gate typedef struct rtld_db_priv { 1520Sstevel@tonic-gate struct r_debug rtd_rdebug; /* original r_debug structure */ 1530Sstevel@tonic-gate Word rtd_version; /* version no. */ 1540Sstevel@tonic-gate size_t rtd_objpad; /* padding around mmap()ed objects */ 1559131SRod.Evans@Sun.COM APlist **rtd_dynlmlst; /* pointer to dynlm_list pointer */ 1560Sstevel@tonic-gate } Rtld_db_priv; 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate #ifdef _SYSCALL32 1590Sstevel@tonic-gate typedef struct rtld_db_priv32 { 1600Sstevel@tonic-gate struct r_debug32 rtd_rdebug; /* original r_debug structure */ 1610Sstevel@tonic-gate Elf32_Word rtd_version; /* version no. */ 1620Sstevel@tonic-gate Elf32_Word rtd_objpad; /* padding around mmap()ed objects */ 1639131SRod.Evans@Sun.COM Elf32_Addr rtd_dynlmlst; /* pointer to dynlm_list */ 1640Sstevel@tonic-gate } Rtld_db_priv32; 1650Sstevel@tonic-gate #endif /* _SYSCALL32 */ 1660Sstevel@tonic-gate 1671824Srie /* 1681824Srie * External function definitions. ld.so.1 must convey information to libc in 1691824Srie * regards to threading. libc also provides routines for atexit() and message 1701824Srie * localization. libc provides the necessary interfaces via its RTLDINFO 1711824Srie * structure and/or later _ld_libc() calls. 1721824Srie * 1731824Srie * These external functions are maintained for each link-map list, and used 1741824Srie * where appropriate. The functions are associated with the object that 1751824Srie * provided them, so that should the object be deleted (say, from an alternative 1761824Srie * link-map), the functions can be removed. 1771824Srie */ 1781824Srie typedef struct { 1791824Srie Rt_map *lc_lmp; /* function provider */ 1801824Srie union { 1811824Srie int (*lc_func)(); /* external function pointer */ 1821824Srie uintptr_t lc_val; /* external value */ 1831824Srie char *lc_ptr; /* external character pointer */ 1841824Srie } lc_un; 1851824Srie } Lc_desc; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate /* 1880Sstevel@tonic-gate * Link map list definition. Link-maps are used to describe each loaded object. 1890Sstevel@tonic-gate * Lists of these link-maps describe the various namespaces within a process. 1900Sstevel@tonic-gate * The process executable and its dependencies are maintained on the lml_main 1910Sstevel@tonic-gate * list. The runtime linker, and its dependencies are maintained on the 1920Sstevel@tonic-gate * lml_rtld list. Additional lists can be created (see dlmopen()) for such 1930Sstevel@tonic-gate * things as auditors and their dependencies. 1940Sstevel@tonic-gate * 1950Sstevel@tonic-gate * Each link-map list maintains an Alist of one, or more, linked lists of 1960Sstevel@tonic-gate * link-maps. For backward compatibility, the lm_head/lm_tail elements are 1970Sstevel@tonic-gate * initialized to the first linked-list of link-maps: 1980Sstevel@tonic-gate * 1990Sstevel@tonic-gate * Lm_list 2000Sstevel@tonic-gate * ---------- 2010Sstevel@tonic-gate * | lm_tail | ------------------------------------ 2020Sstevel@tonic-gate * | lm_head | -------------------- | 2030Sstevel@tonic-gate * | | | Rt_map | Rt_map 2040Sstevel@tonic-gate * | | | ------ | ------ 2050Sstevel@tonic-gate * | | Alist --> | | |--> | | 2060Sstevel@tonic-gate * | | --------- | | | -- | | 2070Sstevel@tonic-gate * | lm_lists | ----> | | | | | --> | | 2080Sstevel@tonic-gate * | | |---------| | | | | | | 2090Sstevel@tonic-gate * | | | lc_head | -- ------ | ------ 2100Sstevel@tonic-gate * | | | lc_tail | ------------------ 2110Sstevel@tonic-gate * | | |---------| 2129577SRod.Evans@Sun.COM * ---------- | lc_head | 2130Sstevel@tonic-gate * | lc_tail | 2140Sstevel@tonic-gate * |---------| 2150Sstevel@tonic-gate * 2160Sstevel@tonic-gate * Multiple link-map lists exist to support the addition of lazy loaded 2170Sstevel@tonic-gate * families, filtee families, and dlopen() families. The intent of these 2180Sstevel@tonic-gate * lists is to insure that a family of objects that are to be loaded are 2190Sstevel@tonic-gate * fully relocatable, and hence usable, before they become part of the main 2200Sstevel@tonic-gate * (al_data[0]) link-map control list. This main link-map control list is 2210Sstevel@tonic-gate * the only list in existence when control is transferred to user code. 2220Sstevel@tonic-gate * 2230Sstevel@tonic-gate * During process initialization, the dynamic executable and its non-lazy 2240Sstevel@tonic-gate * dependencies are maintained on al_data[0]. If a new object is loaded, then 2250Sstevel@tonic-gate * this object is added to the next available control list [1], typically 2260Sstevel@tonic-gate * al_data[1]. Any dependencies of this object that have not already been 2270Sstevel@tonic-gate * loaded are added to the same control list. Once all of the objects on the 2280Sstevel@tonic-gate * new control list have been successfully relocated, the objects are moved from 2290Sstevel@tonic-gate * the new control list to the highest control list to which objects of the new 2300Sstevel@tonic-gate * control list bound to, typically al_data[1] to al_data[0]. 2310Sstevel@tonic-gate * 2320Sstevel@tonic-gate * Each loading scenario can be broken down as follows: 2330Sstevel@tonic-gate * 2340Sstevel@tonic-gate * setup() - only the initial link-map control list is used: 2350Sstevel@tonic-gate * i. create al_data[0] 2360Sstevel@tonic-gate * ii. add new link-map for main on al_data[0] 2370Sstevel@tonic-gate * iii. analyze al_data[0] to add all non-lazy dependencies 2380Sstevel@tonic-gate * iv. relocate al_data[0] dependencies. 2390Sstevel@tonic-gate * 2400Sstevel@tonic-gate * dlopen() - the initiator can only be the initial link-map control list: 2410Sstevel@tonic-gate * i. create al_data[1] from caller al_data[0] 2420Sstevel@tonic-gate * ii. add new link-map for the dlopen'ed object on al_data[1] 2430Sstevel@tonic-gate * iii. analyze al_data[1] to add all non-lazy dependencies 2440Sstevel@tonic-gate * iv. relocate al_data[1] dependencies, and move to al_data[0]. 2450Sstevel@tonic-gate * 2460Sstevel@tonic-gate * filtee and lazy loading processing - the initiator can be any link-map 2470Sstevel@tonic-gate * control list that is being relocated: 2480Sstevel@tonic-gate * i. create al_data[y] from caller al_data[x] 2490Sstevel@tonic-gate * ii. add new link-map for the new object on al_data[y] 2500Sstevel@tonic-gate * iii. analyze al_data[y] to add all non-lazy dependencies 2510Sstevel@tonic-gate * iv. relocate al_data[y] dependencies, and move to al_data[x]. 2520Sstevel@tonic-gate * 2530Sstevel@tonic-gate * This Alist therefore maintains a stack of link-map control lists. The newest 2540Sstevel@tonic-gate * link-map control list can locate symbols within any of the former lists, 2550Sstevel@tonic-gate * however, control is not passed to a former list until the newest lists 2560Sstevel@tonic-gate * processing is complete. Thus, objects can't bind to new objects until they 2570Sstevel@tonic-gate * have been fully analyzed and relocated. 2580Sstevel@tonic-gate * 2590Sstevel@tonic-gate * [1] Note, additional link-map control list creation occurs after the head 2600Sstevel@tonic-gate * link-map object (typically the dynamic executable) has been relocated. This 2610Sstevel@tonic-gate * staging is required to satisfy the binding requirements of copy relocations. 2620Sstevel@tonic-gate * Copy relocations, effectively, transfer the bindings of the copied data 2630Sstevel@tonic-gate * (say _iob in libc.so.1) to the copy location (_iob in the application). 2640Sstevel@tonic-gate * Thus an object that might bind to the original copy data must be redirected 2650Sstevel@tonic-gate * to the copy reference. As the knowledge of a copy relocation having taken 2660Sstevel@tonic-gate * place is only known after relocating the application, link-map control list 2670Sstevel@tonic-gate * additions are suspended until after this relocation has completed. 2680Sstevel@tonic-gate */ 2690Sstevel@tonic-gate typedef struct { 2700Sstevel@tonic-gate Rt_map *lc_head; 2710Sstevel@tonic-gate Rt_map *lc_tail; 2725892Sab196087 APlist *lc_now; /* pending promoted bind-now objects */ 2730Sstevel@tonic-gate uint_t lc_flags; 2740Sstevel@tonic-gate } Lm_cntl; 2750Sstevel@tonic-gate 2760Sstevel@tonic-gate #define LMC_FLG_ANALYZING 0x01 /* control list is being analyzed */ 2770Sstevel@tonic-gate #define LMC_FLG_RELOCATING 0x02 /* control list is being relocated */ 2780Sstevel@tonic-gate #define LMC_FLG_REANALYZE 0x04 /* repeat analysis (established when */ 2790Sstevel@tonic-gate /* interposers are added */ 2800Sstevel@tonic-gate 2811618Srie struct lm_list { 2820Sstevel@tonic-gate /* 2830Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 2840Sstevel@tonic-gate */ 2850Sstevel@tonic-gate Rt_map *lm_head; /* linked list pointers to active */ 2860Sstevel@tonic-gate Rt_map *lm_tail; /* link-map list */ 2875892Sab196087 APlist *lm_handle; /* not used by rtld_db - but spacing */ 2880Sstevel@tonic-gate /* is required for flags */ 2890Sstevel@tonic-gate Word lm_flags; 2900Sstevel@tonic-gate /* 2910Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 2920Sstevel@tonic-gate */ 2931824Srie Alist *lm_rti; /* list of RTLDINFO tables */ 2945067Srie Audit_list *lm_alp; /* audit list descriptor */ 2950Sstevel@tonic-gate avl_tree_t *lm_fpavl; /* avl tree of objects loaded */ 2960Sstevel@tonic-gate Alist *lm_lists; /* active and pending link-map lists */ 2976Srie char ***lm_environ; /* pointer to environment array */ 2980Sstevel@tonic-gate Word lm_tflags; /* transferable flags */ 2991618Srie uint_t lm_obj; /* total number of objs on link-map */ 3001618Srie uint_t lm_init; /* new obj since last init processing */ 3019963SRod.Evans@Sun.COM uint_t lm_lazy; /* number of objects with pending */ 3029963SRod.Evans@Sun.COM /* lazy dependencies */ 3031824Srie uint_t lm_tls; /* new obj that require TLS */ 3041618Srie uint_t lm_lmid; /* unique link-map list identifier, */ 3051618Srie char *lm_lmidstr; /* and associated diagnostic string */ 3065892Sab196087 APlist *lm_actaudit; /* list of pending audit activity */ 3071824Srie Lc_desc lm_lcs[CI_MAX]; /* external libc functions */ 3081618Srie }; 3090Sstevel@tonic-gate 3100Sstevel@tonic-gate #ifdef _SYSCALL32 3111618Srie struct lm_list32 { 3120Sstevel@tonic-gate /* 3130Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 3140Sstevel@tonic-gate */ 3150Sstevel@tonic-gate Elf32_Addr lm_head; 3160Sstevel@tonic-gate Elf32_Addr lm_tail; 3170Sstevel@tonic-gate Elf32_Addr lm_handle; 3180Sstevel@tonic-gate Elf32_Word lm_flags; 3190Sstevel@tonic-gate /* 3200Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 3210Sstevel@tonic-gate */ 3221824Srie Elf32_Addr lm_rti; 3230Sstevel@tonic-gate Elf32_Addr lm_fpavl; 3240Sstevel@tonic-gate Elf32_Addr lm_lists; 3256Srie Elf32_Addr lm_environ; 3260Sstevel@tonic-gate Elf32_Word lm_tflags; 3271618Srie uint_t lm_obj; 3281618Srie uint_t lm_init; 3291618Srie uint_t lm_lazy; 3301824Srie uint_t lm_tls; 3311618Srie uint_t lm_lmid; 3321618Srie Elf32_Addr lm_lmidstr; 3334679Srie Elf32_Addr lm_actaudit; 3341824Srie Elf32_Addr lm_lcs[CI_MAX]; 3351618Srie }; 3360Sstevel@tonic-gate #endif /* _SYSCALL32 */ 3370Sstevel@tonic-gate 3380Sstevel@tonic-gate /* 3390Sstevel@tonic-gate * Possible Link_map list flags (Lm_list.lm_flags) 3400Sstevel@tonic-gate */ 3410Sstevel@tonic-gate /* 3420Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 3430Sstevel@tonic-gate */ 3440Sstevel@tonic-gate #define LML_FLG_BASELM 0x00000001 /* primary link-map */ 3450Sstevel@tonic-gate #define LML_FLG_RTLDLM 0x00000002 /* rtld link-map */ 3460Sstevel@tonic-gate /* 3470Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 3480Sstevel@tonic-gate */ 3490Sstevel@tonic-gate #define LML_FLG_NOAUDIT 0x00000004 /* symbol auditing disabled */ 3500Sstevel@tonic-gate #define LML_FLG_PLTREL 0x00000008 /* deferred plt relocation */ 3510Sstevel@tonic-gate /* initialization */ 3520Sstevel@tonic-gate /* (ld.so.1 only) */ 3530Sstevel@tonic-gate #define LML_FLG_HOLDLOCK 0x00000010 /* hold the rtld mutex lock */ 3540Sstevel@tonic-gate #define LML_FLG_ENVIRON 0x00000020 /* environ var initialized */ 3550Sstevel@tonic-gate #define LML_FLG_INTRPOSE 0x00000040 /* interposing objs on list */ 3560Sstevel@tonic-gate #define LML_FLG_LOCAUDIT 0x00000080 /* local auditors exists for */ 3570Sstevel@tonic-gate /* this link-map list */ 3580Sstevel@tonic-gate #define LML_FLG_LOADAVAIL 0x00000100 /* load anything available */ 3590Sstevel@tonic-gate #define LML_FLG_IGNRELERR 0x00000200 /* ignore relocation errors - */ 3600Sstevel@tonic-gate /* internal for crle(1) */ 3610Sstevel@tonic-gate #define LML_FLG_DBNOTIF 0x00000400 /* binding activity going on */ 362280Srie #define LML_FLG_STARTREL 0x00000800 /* relocation started */ 363280Srie #define LML_FLG_ATEXIT 0x00001000 /* atexit processing */ 364280Srie #define LML_FLG_OBJADDED 0x00002000 /* object(s) added */ 365280Srie #define LML_FLG_OBJDELETED 0x00004000 /* object(s) deleted */ 366280Srie #define LML_FLG_OBJREEVAL 0x00008000 /* existing object(s) needs */ 367280Srie /* tsort reevaluation */ 3683817Srie #define LML_FLG_INTRPOSETSORT 0x00020000 /* interpose tsorting done */ 3694679Srie #define LML_FLG_AUDITNOTIFY 0x00040000 /* audit consistent required */ 3705220Srie #define LML_FLG_GROUPSEXIST 0x00080000 /* local groups exist */ 3712850Srie 3720Sstevel@tonic-gate #define LML_FLG_TRC_LDDSTUB 0x00100000 /* identify lddstub */ 3730Sstevel@tonic-gate #define LML_FLG_TRC_ENABLE 0x00200000 /* tracing enabled (ldd) */ 3740Sstevel@tonic-gate #define LML_FLG_TRC_WARN 0x00400000 /* print warnings for undefs */ 3750Sstevel@tonic-gate #define LML_FLG_TRC_VERBOSE 0x00800000 /* verbose (versioning) trace */ 3760Sstevel@tonic-gate #define LML_FLG_TRC_SEARCH 0x01000000 /* trace search paths */ 3770Sstevel@tonic-gate #define LML_FLG_TRC_UNREF 0x02000000 /* trace unreferenced */ 3780Sstevel@tonic-gate /* dependencies */ 3790Sstevel@tonic-gate #define LML_FLG_TRC_UNUSED 0x04000000 /* trace unused dependencies */ 3800Sstevel@tonic-gate #define LML_FLG_TRC_INIT 0x08000000 /* print .init order */ 3814947Srie #define LML_FLG_TRC_NOUNRESWEAK 0x10000000 /* unresolved weak references */ 3824947Srie /* are not allowed */ 3836150Srie #define LML_FLG_TRC_NOPAREXT 0x20000000 /* unresolved PARENT/EXTERN */ 3846150Srie /* references are not */ 3856150Srie /* allowed */ 3860Sstevel@tonic-gate #define LML_MSK_TRC 0xfff00000 /* tracing mask */ 3870Sstevel@tonic-gate 3880Sstevel@tonic-gate /* 3890Sstevel@tonic-gate * Possible Link_map transferable flags (Lm_list.lm_tflags), i.e., link-map 3900Sstevel@tonic-gate * list flags that can be propagated to any new link-map list created. 3910Sstevel@tonic-gate */ 3920Sstevel@tonic-gate #define LML_TFLG_NOLAZYLD 0x00000001 /* lazy loading disabled */ 3930Sstevel@tonic-gate #define LML_TFLG_NODIRECT 0x00000002 /* direct bindings disabled */ 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate #define LML_TFLG_LOADFLTR 0x00000008 /* trigger filtee loading */ 3960Sstevel@tonic-gate 3978598SRod.Evans@Sun.COM #define LML_TFLG_AUD_PREINIT 0x00001000 /* preinit (audit) exists */ 3988598SRod.Evans@Sun.COM #define LML_TFLG_AUD_OBJSEARCH 0x00002000 /* objsearch (audit) exists */ 3998598SRod.Evans@Sun.COM #define LML_TFLG_AUD_OBJOPEN 0x00004000 /* objopen (audit) exists */ 4008598SRod.Evans@Sun.COM #define LML_TFLG_AUD_OBJFILTER 0x00008000 /* objfilter (audit) exists */ 4018598SRod.Evans@Sun.COM #define LML_TFLG_AUD_OBJCLOSE 0x00010000 /* objclose (audit) exists */ 4028598SRod.Evans@Sun.COM #define LML_TFLG_AUD_SYMBIND 0x00020000 /* symbind (audit) exists */ 4038598SRod.Evans@Sun.COM #define LML_TFLG_AUD_PLTENTER 0x00040000 /* pltenter (audit) exists */ 4048598SRod.Evans@Sun.COM #define LML_TFLG_AUD_PLTEXIT 0x00080000 /* pltexit (audit) exists */ 4058598SRod.Evans@Sun.COM #define LML_TFLG_AUD_ACTIVITY 0x00100000 /* activity (audit) exists */ 4060Sstevel@tonic-gate 4070Sstevel@tonic-gate /* 4088598SRod.Evans@Sun.COM * NOTE: Each auditing module establishes a set of audit flags, AFLAGS(), that 4098598SRod.Evans@Sun.COM * define the auditing interfaces the module offers. These auditing flags are 4108598SRod.Evans@Sun.COM * the LML_TFLG_AUD_ flags defined above. Global auditors result in setting 4118598SRod.Evans@Sun.COM * the lm_tflags too. Local auditors only use the AFLAGS(). All tests for 4128598SRod.Evans@Sun.COM * auditing inspect the lm_tflags and AFLAGS() for a specific auditing 4138598SRod.Evans@Sun.COM * interface, and thus use the same flag to test for both types of auditors. 4140Sstevel@tonic-gate */ 4158598SRod.Evans@Sun.COM #define LML_TFLG_AUD_MASK 0x0ffff000 /* audit interfaces mask */ 4160Sstevel@tonic-gate 4170Sstevel@tonic-gate /* 4185067Srie * Define a Group Handle. 4195067Srie * 4205067Srie * The capability of ld.so.1 to associate a group of objects, look for symbols 4215067Srie * within that group, ensure that groups are isolated from one another (with 4229577SRod.Evans@Sun.COM * regard to relocations), and to unload a group, centers around a handle. 4239577SRod.Evans@Sun.COM * 4249577SRod.Evans@Sun.COM * Dependencies can be added to an existing handle as the dependencies are 4259577SRod.Evans@Sun.COM * lazily loaded. The core dependencies on the handle are the ldd(1) list of 4269577SRod.Evans@Sun.COM * the referenced object. 4279577SRod.Evans@Sun.COM * 4289577SRod.Evans@Sun.COM * Handles can be created from: 4295067Srie * 4309577SRod.Evans@Sun.COM * - a dlopen() request. This associates a caller to a reference object, 4319577SRod.Evans@Sun.COM * and the referenced objects dependencies. This group of objects can 4329577SRod.Evans@Sun.COM * then be inspected for symbols (dlsym()). 4339577SRod.Evans@Sun.COM * - a filtering request. This associates a filter (caller) to a referenced 4349577SRod.Evans@Sun.COM * object (filtee). The redirection of filter symbols to their filtee 4359577SRod.Evans@Sun.COM * counterpart is essentially a dlsym() using the filtee's handle. 4369577SRod.Evans@Sun.COM * 4379577SRod.Evans@Sun.COM * The handle created for these events is referred to as a public handle. This 4389577SRod.Evans@Sun.COM * handle tracks the referenced object, all of the dependencies of the 4399577SRod.Evans@Sun.COM * referenced object, and the caller (parent). 4405067Srie * 4415067Srie * Presently, an object may have two handles, one requested with RTLD_FIRST 4425067Srie * and one without. 4435067Srie * 4449577SRod.Evans@Sun.COM * A handle may be referenced by any number of callers (parents). A reference 4455067Srie * count tracks the number. A dlclose() operation drops the reference count, 4465067Srie * and when the count is zero, the handle is used to determine the family of 4475067Srie * objects to unload. As bindings may occur to objects on the handle from 4489577SRod.Evans@Sun.COM * other handles, it may not be possible to remove a complete family of objects 4499577SRod.Evans@Sun.COM * or the handle itself. Handles in this state are moved to an orphan list. 4509577SRod.Evans@Sun.COM * A handle on the orphan list is taken off the orphan list if the associated 4519577SRod.Evans@Sun.COM * object is reopened. Otherwise, the handle remains on the orphan list for 4529577SRod.Evans@Sun.COM * the duration of the process. The orphan list is inspected any time objects 4539577SRod.Evans@Sun.COM * are unloaded, to determine if the orphaned objects can also be unloaded. 4549577SRod.Evans@Sun.COM * 4559577SRod.Evans@Sun.COM * Handles can also be created for internal uses: 4569577SRod.Evans@Sun.COM * 4579577SRod.Evans@Sun.COM * - to promote objects to RTLD_NOW. 4589577SRod.Evans@Sun.COM * - to establish families for symbol binding fallback, required when lazy 4599577SRod.Evans@Sun.COM * loadable objects are still pending. 4609577SRod.Evans@Sun.COM * 4619577SRod.Evans@Sun.COM * The handle created for these events is referred to as a private handle. This 4629577SRod.Evans@Sun.COM * handle does not need to track the caller (parent), and because of this, does 4639577SRod.Evans@Sun.COM * not need to be considered during dlclose() operations, as the handle can not 4649577SRod.Evans@Sun.COM * be referenced by callers outside of the referenced objects family. 4659577SRod.Evans@Sun.COM * 4669577SRod.Evans@Sun.COM * Note, a private handle is essentially a subset of a public handle. Should 4679577SRod.Evans@Sun.COM * an internal operation require a private handle, and a public handle already 4689577SRod.Evans@Sun.COM * exist, the public handle can be used. Should an external operation require 4699577SRod.Evans@Sun.COM * a public handle, and a private handle exist, the private handle is promoted 4709577SRod.Evans@Sun.COM * to a public handle. Any handle that gets created will remain in existence 4719577SRod.Evans@Sun.COM * for the life time of the referenced object. 4725067Srie * 4735067Srie * Objects can be dlopened using RTLD_NOW. This attribute requires that all 4745067Srie * relocations of the object, and its dependencies are processed immediately, 4755067Srie * before return to the caller. Typically, an object is loaded without 4765067Srie * RTLD_NOW, and procedure linkage relocations are satisfied when their 4775067Srie * associated function is first called. If an object is already loaded, and an 4785067Srie * RTLD_NOW request is made, then the object, and its dependencies, most undergo 4795067Srie * additional relocation processing. This promotion from lazy binding to 4805067Srie * immediate binding is carried out using handles, as the handle defines the 4819577SRod.Evans@Sun.COM * dependencies that must be processed. 4829577SRod.Evans@Sun.COM * 4839577SRod.Evans@Sun.COM * To ensure that objects within a lazy loadable environment can be relocated, 4849577SRod.Evans@Sun.COM * no matter whether the objects have their dependencies described completely, 4859577SRod.Evans@Sun.COM * a symbol lookup fallback is employed. Any pending lazy loadable objects are 4869577SRod.Evans@Sun.COM * loaded, and a handle established to search the object and it's dependencies 4879577SRod.Evans@Sun.COM * for the required symbol. 4889577SRod.Evans@Sun.COM * 4899577SRod.Evans@Sun.COM * A group handle (and its associated group descriptors), is referenced from 4909577SRod.Evans@Sun.COM * a link-map's HANDLES and GROUPS lists. Note, Aplist's are diagramed to 4919577SRod.Evans@Sun.COM * fully expose the allocations required to establish the data structure 4929577SRod.Evans@Sun.COM * relationships. 4939577SRod.Evans@Sun.COM * 4949577SRod.Evans@Sun.COM * Grp_desc 4959577SRod.Evans@Sun.COM * Alist 4969577SRod.Evans@Sun.COM * ----------- 4979577SRod.Evans@Sun.COM * --> | | 4989577SRod.Evans@Sun.COM * | |-----------| 4999577SRod.Evans@Sun.COM * | | gd_depend | --------- 5009577SRod.Evans@Sun.COM * | | | | 5019577SRod.Evans@Sun.COM * | |-----------| | 5029577SRod.Evans@Sun.COM * --------|--- | gd_depend | | 5039577SRod.Evans@Sun.COM * | | | (parent) | | 5049577SRod.Evans@Sun.COM * | | |-----------| | 5059577SRod.Evans@Sun.COM * | | | gd_depend | | 5069577SRod.Evans@Sun.COM * | | | | | 5079577SRod.Evans@Sun.COM * | | | | | 5089577SRod.Evans@Sun.COM * | | ----------- | 5099577SRod.Evans@Sun.COM * | | | 5109577SRod.Evans@Sun.COM * | | Grp_hdl | 5119577SRod.Evans@Sun.COM * | | ----------- | 5129577SRod.Evans@Sun.COM * | -- | gh_depends | | 5139577SRod.Evans@Sun.COM * | --------- | gh_ownlmp | | 5149577SRod.Evans@Sun.COM * | | | | | 5159577SRod.Evans@Sun.COM * | | | | | 5169577SRod.Evans@Sun.COM * | | | | | 5179577SRod.Evans@Sun.COM * Rt_map | | ------------ | Rt_map 5189577SRod.Evans@Sun.COM * ---------- | | ^ ^ | ---------- 5199577SRod.Evans@Sun.COM * | | <- | | | --> | | 5209577SRod.Evans@Sun.COM * | | <--- -------- | | | | 5219577SRod.Evans@Sun.COM * | HANDLES | ----> | | | | -------- | | 5229577SRod.Evans@Sun.COM * | | | | | | | | <---- | GROUPS | 5239577SRod.Evans@Sun.COM * | | | | --- | | | | | 5249577SRod.Evans@Sun.COM * | | | | --- | | | | 5259577SRod.Evans@Sun.COM * | | -------- | | | | 5269577SRod.Evans@Sun.COM * ---------- Aplist -------- ---------- 5279577SRod.Evans@Sun.COM * Aplist 5280Sstevel@tonic-gate */ 5290Sstevel@tonic-gate typedef struct { 5301618Srie Alist *gh_depends; /* handle dependency list */ 5311618Srie Rt_map *gh_ownlmp; /* handle owners link-map */ 5321618Srie Lm_list *gh_ownlml; /* handle owners link-map list */ 5330Sstevel@tonic-gate uint_t gh_refcnt; /* handle reference count */ 5345067Srie uint_t gh_flags; /* handle flags (GPH_ values) */ 5350Sstevel@tonic-gate } Grp_hdl; 5360Sstevel@tonic-gate 5379577SRod.Evans@Sun.COM /* 5389577SRod.Evans@Sun.COM * Define the two categories of handle. 5399577SRod.Evans@Sun.COM */ 5409577SRod.Evans@Sun.COM #define GPH_PUBLIC 0x0001 /* handle returned to caller(s) */ 5419577SRod.Evans@Sun.COM #define GPH_PRIVATE 0x0002 /* handle used internally */ 5429577SRod.Evans@Sun.COM 5439577SRod.Evans@Sun.COM /* 5449577SRod.Evans@Sun.COM * Define any flags that affects how the handle is used. 5459577SRod.Evans@Sun.COM */ 5469577SRod.Evans@Sun.COM #define GPH_ZERO 0x0010 /* special handle for dlopen(0) */ 5479577SRod.Evans@Sun.COM #define GPH_LDSO 0x0020 /* special handle for ld.so.1 */ 5489577SRod.Evans@Sun.COM #define GPH_FIRST 0x0040 /* dlsym() can only use originating */ 5490Sstevel@tonic-gate /* dependency */ 5509577SRod.Evans@Sun.COM #define GPH_FILTEE 0x0080 /* handle identifies a filtee, used */ 5519577SRod.Evans@Sun.COM /* for diagnostics only */ 5529577SRod.Evans@Sun.COM /* 5539577SRod.Evans@Sun.COM * Define any state that is associated with the handle. 5549577SRod.Evans@Sun.COM */ 5559577SRod.Evans@Sun.COM #define GPH_INITIAL 0x0100 /* handle is initialized */ 5569963SRod.Evans@Sun.COM 5570Sstevel@tonic-gate /* 5585067Srie * Define a Group Descriptor. 5595067Srie * 5605067Srie * Each dependency associated with a group handle is maintained by a group 5615067Srie * descriptor. The descriptor defines the associated dependency together with 5625067Srie * flags that indicate how the dependency can be used. 5630Sstevel@tonic-gate */ 5640Sstevel@tonic-gate typedef struct { 5658598SRod.Evans@Sun.COM Rt_map *gd_depend; /* dependency */ 5665067Srie uint_t gd_flags; /* dependency flags (GPD_ values) */ 5670Sstevel@tonic-gate } Grp_desc; 5680Sstevel@tonic-gate 5694699Srie #define GPD_DLSYM 0x0001 /* dependency available to dlsym() */ 5704699Srie #define GPD_RELOC 0x0002 /* dependency available to satisfy */ 5714699Srie /* relocation binding */ 5724699Srie #define GPD_ADDEPS 0x0004 /* dependencies of this dependency */ 5730Sstevel@tonic-gate /* should be added to handle */ 5744699Srie #define GPD_PARENT 0x0008 /* dependency is a parent */ 5754699Srie #define GPD_FILTER 0x0010 /* dependency is our filter */ 5769577SRod.Evans@Sun.COM #define GPD_REMOVE 0x0100 /* descriptor is a candidate for */ 5770Sstevel@tonic-gate /* removal from the group */ 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate /* 5800Sstevel@tonic-gate * Define threading structures. For compatibility with libthread (T1_VERSION 1 5810Sstevel@tonic-gate * and TI_VERSION 2) our locking structure is sufficient to hold a mutex or a 5820Sstevel@tonic-gate * readers/writers lock. 5830Sstevel@tonic-gate */ 5840Sstevel@tonic-gate typedef struct { 5850Sstevel@tonic-gate union { 5860Sstevel@tonic-gate mutex_t l_mutex; 5870Sstevel@tonic-gate rwlock_t l_rwlock; 5880Sstevel@tonic-gate } u; 5890Sstevel@tonic-gate } Rt_lock; 5900Sstevel@tonic-gate 5910Sstevel@tonic-gate typedef cond_t Rt_cond; 5920Sstevel@tonic-gate 5930Sstevel@tonic-gate /* 5940Sstevel@tonic-gate * Define a dynamic section information descriptor. This parallels the entries 5950Sstevel@tonic-gate * in the .dynamic section and holds auxiliary information to implement lazy 5960Sstevel@tonic-gate * loading and filtee processing. 5970Sstevel@tonic-gate */ 5980Sstevel@tonic-gate typedef struct { 59912449SRod.Evans@Sun.COM uint_t di_flags; 60012449SRod.Evans@Sun.COM void *di_info; 60112449SRod.Evans@Sun.COM const char *di_name; 6020Sstevel@tonic-gate } Dyninfo; 6030Sstevel@tonic-gate 6040Sstevel@tonic-gate #define FLG_DI_STDFLTR 0x00001 /* .dynamic entry for DT_FILTER */ 6050Sstevel@tonic-gate #define FLG_DI_AUXFLTR 0x00002 /* .dynamic entry for DT_AUXILIARY */ 6060Sstevel@tonic-gate #define FLG_DI_SYMFLTR 0x00004 /* .dynamic entry for DT_SYMFILTER */ 6070Sstevel@tonic-gate /* and DT_SYMAUXILIARY */ 6080Sstevel@tonic-gate #define MSK_DI_FILTER 0x0000f /* mask for all filter possibilities */ 6090Sstevel@tonic-gate 6105950Srie #define FLG_DI_POSFLAG1 0x00010 /* .dynamic entry for DT_POSFLAG_1 */ 6115950Srie #define FLG_DI_NEEDED 0x00020 /* .dynamic entry for DT_NEEDED */ 61212449SRod.Evans@Sun.COM #define FLG_DI_REGISTER 0x00040 /* .dynamic entry for DT_REGISTER */ 61312449SRod.Evans@Sun.COM #define FLG_DI_IGNORE 0x00080 /* .dynamic entry should be ignored */ 61412449SRod.Evans@Sun.COM 61512449SRod.Evans@Sun.COM #define FLG_DI_LAZY 0x00100 /* lazy needed entry, preceded by */ 6165950Srie /* DF_P1_LAZYLOAD (DT_POSFLAG_1) */ 61712449SRod.Evans@Sun.COM #define FLG_DI_GROUP 0x00200 /* group needed entry, preceded by */ 6185950Srie /* DF_P1_GROUPPERM (DT_POSFLAG_1) */ 61912449SRod.Evans@Sun.COM #define FLG_DI_DEFERRED 0x00400 /* deferred needed entry, preceded by */ 62012449SRod.Evans@Sun.COM /* DF_P1_DEFERRED (DT_POSFLAG_1) */ 6210Sstevel@tonic-gate 62212449SRod.Evans@Sun.COM #define FLG_DI_LAZYFAIL 0x01000 /* the lazy loading of this entry */ 6235950Srie /* failed */ 62412449SRod.Evans@Sun.COM #define FLG_DI_LDD_DONE 0x02000 /* entry has been processed (ldd) */ 62512449SRod.Evans@Sun.COM #define FLG_DI_DEF_DONE 0x04000 /* entry has been processed (dlinfo) */ 62612449SRod.Evans@Sun.COM 6270Sstevel@tonic-gate /* 6286387Srie * Data structure to track AVL tree of pathnames. This structure provides the 6296387Srie * basis of both the "not-found" node tree, and the "full-path" node tree. Both 6306387Srie * of these trees persist for the life of a process, although the "not-found" 6316387Srie * tree may be moved aside during a dlopen() or dlsym() fall back operation. 6320Sstevel@tonic-gate */ 6330Sstevel@tonic-gate typedef struct { 6346387Srie const char *pn_name; /* path name */ 6356387Srie avl_node_t pn_avl; /* avl book-keeping (see SGSOFFSETOF) */ 6366387Srie uint_t pn_hash; /* path name hash value */ 6376387Srie } PathNode; 6386387Srie 6396387Srie /* 6406387Srie * Data structure to track AVL tree for full path names of objects that are 6416387Srie * loaded into memory. 6426387Srie */ 6436387Srie typedef struct { 6446387Srie PathNode fpn_node; /* path node */ 6450Sstevel@tonic-gate Rt_map *fpn_lmp; /* object link-map */ 6466387Srie } FullPathNode; 6470Sstevel@tonic-gate 6480Sstevel@tonic-gate /* 6495892Sab196087 * A given link-map can hold either a supplier or receiver copy 6505892Sab196087 * relocation list, but not both. This union is used to overlap 6515892Sab196087 * the space used for the two lists. 6525892Sab196087 */ 6535892Sab196087 typedef union { 6545892Sab196087 Alist *rtc_r; /* receiver list (Rel_copy) */ 6555892Sab196087 APlist *rtc_s; /* supplier list (Rt_map *) */ 6565892Sab196087 } Rt_map_copy; 6575892Sab196087 6585892Sab196087 6595892Sab196087 /* 6600Sstevel@tonic-gate * Link-map definition. 6610Sstevel@tonic-gate */ 6620Sstevel@tonic-gate struct rt_map { 6630Sstevel@tonic-gate /* 6640Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 6650Sstevel@tonic-gate */ 6660Sstevel@tonic-gate Link_map rt_public; /* public data */ 6678598SRod.Evans@Sun.COM const char *rt_pathname; /* full pathname of loaded object */ 6680Sstevel@tonic-gate ulong_t rt_padstart; /* start of image (including padding) */ 6690Sstevel@tonic-gate ulong_t rt_padimlen; /* size of image (including padding */ 6708598SRod.Evans@Sun.COM ulong_t rt_msize; /* total memory reservation range */ 6710Sstevel@tonic-gate uint_t rt_flags; /* state flags, see FLG below */ 6720Sstevel@tonic-gate uint_t rt_flags1; /* state flags1, see FL1 below */ 6730Sstevel@tonic-gate ulong_t rt_tlsmodid; /* TLS module id */ 6740Sstevel@tonic-gate /* 6750Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 6760Sstevel@tonic-gate */ 6775892Sab196087 APlist *rt_alias; /* list of linked file names */ 67811827SRod.Evans@Sun.COM APlist *rt_fpnode; /* list of FullPathNode AVL nodes */ 6790Sstevel@tonic-gate char *rt_runpath; /* LD_RUN_PATH and its equivalent */ 6808598SRod.Evans@Sun.COM Alist *rt_runlist; /* Pdesc structures */ 6815892Sab196087 APlist *rt_depends; /* list of dependencies */ 6825892Sab196087 APlist *rt_callers; /* list of callers */ 6835892Sab196087 APlist *rt_handles; /* dlopen handles */ 6845892Sab196087 APlist *rt_groups; /* groups we're a member of */ 6850Sstevel@tonic-gate struct fct *rt_fct; /* file class table for this object */ 6860Sstevel@tonic-gate void *rt_priv; /* private data, object type specific */ 6870Sstevel@tonic-gate Lm_list *rt_list; /* link map list we belong to */ 6880Sstevel@tonic-gate uint_t rt_objfltrndx; /* object filtees .dynamic index */ 6890Sstevel@tonic-gate uint_t rt_symsfltrcnt; /* number of standard symbol filtees */ 6900Sstevel@tonic-gate uint_t rt_symafltrcnt; /* number of auxiliary symbol filtees */ 6910Sstevel@tonic-gate int rt_mode; /* usage mode, see RTLD mode flags */ 692280Srie int rt_sortval; /* temporary buffer to traverse graph */ 6930Sstevel@tonic-gate uint_t rt_cycgroup; /* cyclic group */ 6940Sstevel@tonic-gate dev_t rt_stdev; /* device id and inode number for .so */ 6958394SAli.Bahrami@Sun.COM rtld_ino_t rt_stino; /* multiple inclusion checks */ 6968598SRod.Evans@Sun.COM const char *rt_origname; /* original pathname of loaded object */ 6970Sstevel@tonic-gate size_t rt_dirsz; /* and its size */ 6988598SRod.Evans@Sun.COM size_t rt_lmsize; /* size of the link-map allocation */ 6995892Sab196087 Rt_map_copy rt_copy; /* list of copy relocations */ 7000Sstevel@tonic-gate Audit_desc *rt_auditors; /* audit descriptor array */ 7010Sstevel@tonic-gate Audit_info *rt_audinfo; /* audit information descriptor */ 7020Sstevel@tonic-gate Syminfo *rt_syminfo; /* elf .syminfo section - here */ 7030Sstevel@tonic-gate /* because it is checked in */ 7040Sstevel@tonic-gate /* common code */ 705*12736SAli.Bahrami@Oracle.COM Addr *rt_initarray; /* .init_array table */ 706*12736SAli.Bahrami@Oracle.COM Addr *rt_finiarray; /* .fini_array table */ 707*12736SAli.Bahrami@Oracle.COM Addr *rt_preinitarray; /* .preinit_array table */ 7088598SRod.Evans@Sun.COM mmapobj_result_t *rt_mmaps; /* array of mapping information */ 7090Sstevel@tonic-gate uint_t rt_mmapcnt; /* and associated number */ 710*12736SAli.Bahrami@Oracle.COM uint_t rt_initarraysz; /* size of .init_array table */ 711*12736SAli.Bahrami@Oracle.COM uint_t rt_finiarraysz; /* size of .fini_array table */ 712*12736SAli.Bahrami@Oracle.COM uint_t rt_preinitarraysz; /* size of .preinit_array table */ 7130Sstevel@tonic-gate Dyninfo *rt_dyninfo; /* .dynamic information descriptors */ 7140Sstevel@tonic-gate uint_t rt_dyninfocnt; /* count of dyninfo entries */ 7150Sstevel@tonic-gate uint_t rt_relacount; /* no. of RELATIVE relocations */ 7160Sstevel@tonic-gate uint_t rt_idx; /* hold index within linkmap list */ 7179963SRod.Evans@Sun.COM uint_t rt_lazy; /* number of lazy dependencies */ 7189963SRod.Evans@Sun.COM /* pending */ 71911827SRod.Evans@Sun.COM Cap *rt_cap; /* capabilities data */ 72011827SRod.Evans@Sun.COM Capchain *rt_capchain; /* capabilities chain data */ 7210Sstevel@tonic-gate uint_t rt_cntl; /* link-map control list we belong to */ 7228598SRod.Evans@Sun.COM uint_t rt_aflags; /* auditor flags, see LML_TFLG_AUD_ */ 7238598SRod.Evans@Sun.COM /* address of _init */ 7248598SRod.Evans@Sun.COM void (*rt_init)(void); 7258598SRod.Evans@Sun.COM /* address of _fini */ 7268598SRod.Evans@Sun.COM void (*rt_fini)(void); 7278598SRod.Evans@Sun.COM /* link map symbol interpreter */ 72811827SRod.Evans@Sun.COM int (*rt_symintp)(Slookup *, Sresult *, uint_t *, int *); 7290Sstevel@tonic-gate }; 7300Sstevel@tonic-gate 7310Sstevel@tonic-gate #ifdef _SYSCALL32 7320Sstevel@tonic-gate /* 7330Sstevel@tonic-gate * Structure to allow 64-bit rtld_db to read 32-bit processes out of procfs. 7340Sstevel@tonic-gate */ 7355892Sab196087 typedef union { 7365892Sab196087 uint32_t rtc_r; 7375892Sab196087 uint32_t rtc_s; 7385892Sab196087 } Rt_map_copy32; 7395892Sab196087 7400Sstevel@tonic-gate typedef struct rt_map32 { 7410Sstevel@tonic-gate /* 7420Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 7430Sstevel@tonic-gate */ 7440Sstevel@tonic-gate Link_map32 rt_public; 7450Sstevel@tonic-gate uint32_t rt_pathname; 7460Sstevel@tonic-gate uint32_t rt_padstart; 7470Sstevel@tonic-gate uint32_t rt_padimlen; 7480Sstevel@tonic-gate uint32_t rt_msize; 7490Sstevel@tonic-gate uint32_t rt_flags; 7500Sstevel@tonic-gate uint32_t rt_flags1; 7510Sstevel@tonic-gate uint32_t rt_tlsmodid; 7520Sstevel@tonic-gate /* 7530Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 7540Sstevel@tonic-gate */ 7550Sstevel@tonic-gate uint32_t rt_alias; 7560Sstevel@tonic-gate uint32_t rt_fpnode; 7570Sstevel@tonic-gate uint32_t rt_runpath; 7580Sstevel@tonic-gate uint32_t rt_runlist; 7590Sstevel@tonic-gate uint32_t rt_depends; 7600Sstevel@tonic-gate uint32_t rt_callers; 7610Sstevel@tonic-gate uint32_t rt_handles; 7620Sstevel@tonic-gate uint32_t rt_groups; 7630Sstevel@tonic-gate uint32_t rt_fct; 7640Sstevel@tonic-gate uint32_t rt_priv; 7650Sstevel@tonic-gate uint32_t rt_list; 7660Sstevel@tonic-gate uint32_t rt_objfltrndx; 7670Sstevel@tonic-gate uint32_t rt_symsfltrcnt; 7680Sstevel@tonic-gate uint32_t rt_symafltrcnt; 769280Srie int32_t rt_mode; 770280Srie int32_t rt_sortval; 7710Sstevel@tonic-gate uint32_t rt_cycgroup; 7720Sstevel@tonic-gate uint32_t rt_stdev; 7730Sstevel@tonic-gate uint32_t rt_stino; 7740Sstevel@tonic-gate uint32_t rt_origname; 7750Sstevel@tonic-gate uint32_t rt_dirsz; 7765892Sab196087 Rt_map_copy32 rt_copy; 7770Sstevel@tonic-gate uint32_t rt_auditors; 7780Sstevel@tonic-gate uint32_t rt_audinfo; 7790Sstevel@tonic-gate uint32_t rt_syminfo; 7800Sstevel@tonic-gate uint32_t rt_initarray; 7810Sstevel@tonic-gate uint32_t rt_finiarray; 7820Sstevel@tonic-gate uint32_t rt_preinitarray; 7830Sstevel@tonic-gate uint32_t rt_mmaps; 7840Sstevel@tonic-gate uint32_t rt_mmapcnt; 7850Sstevel@tonic-gate uint32_t rt_initarraysz; 7860Sstevel@tonic-gate uint32_t rt_finiarraysz; 7870Sstevel@tonic-gate uint32_t rt_preinitarraysz; 7880Sstevel@tonic-gate uint32_t rt_dyninfo; 7890Sstevel@tonic-gate uint32_t rt_dyninfocnt; 7900Sstevel@tonic-gate uint32_t rt_relacount; 7910Sstevel@tonic-gate uint32_t rt_idx; 7920Sstevel@tonic-gate uint32_t rt_lazy; 79311827SRod.Evans@Sun.COM uint32_t rt_cap; 79411827SRod.Evans@Sun.COM uint32_t rt_capchain; 7950Sstevel@tonic-gate uint32_t rt_cntl; 7968598SRod.Evans@Sun.COM uint32_t rt_aflags; 7978598SRod.Evans@Sun.COM uint32_t rt_init; 7988598SRod.Evans@Sun.COM uint32_t rt_fini; 7998598SRod.Evans@Sun.COM uint32_t rt_symintp; 8000Sstevel@tonic-gate } Rt_map32; 8010Sstevel@tonic-gate 8020Sstevel@tonic-gate #endif /* _SYSCALL32 */ 8030Sstevel@tonic-gate 8040Sstevel@tonic-gate /* 8050Sstevel@tonic-gate * Link map state flags. 8060Sstevel@tonic-gate */ 8070Sstevel@tonic-gate /* 8080Sstevel@tonic-gate * BEGIN: Exposed to rtld_db - don't move, don't delete 8090Sstevel@tonic-gate */ 8100Sstevel@tonic-gate #define FLG_RT_ISMAIN 0x00000001 /* object represents main executable */ 8110Sstevel@tonic-gate #define FLG_RT_IMGALLOC 0x00000002 /* image is allocated (not mmap'ed) */ 8120Sstevel@tonic-gate /* 8138598SRod.Evans@Sun.COM * Available for r_debug version >= R_RTLDDB_VERSION5 8140Sstevel@tonic-gate */ 8150Sstevel@tonic-gate #define FLG_RT_RELOCED 0x00000004 /* object has been relocated */ 8160Sstevel@tonic-gate /* 8170Sstevel@tonic-gate * END: Exposed to rtld_db - don't move, don't delete 8180Sstevel@tonic-gate */ 8190Sstevel@tonic-gate #define FLG_RT_SETGROUP 0x00000008 /* group establishment required */ 82011827SRod.Evans@Sun.COM #define FLG_RT_CAP 0x00000010 /* process $CAPABILITY expansion */ 8210Sstevel@tonic-gate #define FLG_RT_OBJECT 0x00000020 /* object processing (ie. .o's) */ 82264Srie #define FLG_RT_NEWLOAD 0x00000040 /* object is newly loaded */ 8230Sstevel@tonic-gate #define FLG_RT_NODUMP 0x00000080 /* object can't be dldump(3x)'ed */ 8240Sstevel@tonic-gate #define FLG_RT_DELETE 0x00000100 /* object can be deleted */ 8250Sstevel@tonic-gate #define FLG_RT_ANALYZED 0x00000200 /* object has been analyzed */ 8260Sstevel@tonic-gate #define FLG_RT_INITDONE 0x00000400 /* objects .init has been completed */ 8270Sstevel@tonic-gate #define FLG_RT_TRANS 0x00000800 /* object is acting as a translator */ 8280Sstevel@tonic-gate #define FLG_RT_FIXED 0x00001000 /* image location is fixed */ 8290Sstevel@tonic-gate #define FLG_RT_PRELOAD 0x00002000 /* object was preloaded */ 8300Sstevel@tonic-gate #define FLG_RT_ALTER 0x00004000 /* alternative object used */ 8310Sstevel@tonic-gate #define FLG_RT_LOADFLTR 0x00008000 /* trigger filtee loading */ 8320Sstevel@tonic-gate #define FLG_RT_AUDIT 0x00010000 /* object is an auditor */ 8330Sstevel@tonic-gate #define FLG_RT_MODESET 0x00020000 /* MODE() has been initialized */ 8340Sstevel@tonic-gate #define FLG_RT_ANALZING 0x00040000 /* object is being analyzed */ 8350Sstevel@tonic-gate #define FLG_RT_INITFRST 0x00080000 /* execute .init first */ 8360Sstevel@tonic-gate #define FLG_RT_NOOPEN 0x00100000 /* dlopen() not allowed */ 8370Sstevel@tonic-gate #define FLG_RT_FINICLCT 0x00200000 /* fini has been collected (tsort) */ 8380Sstevel@tonic-gate #define FLG_RT_INITCALL 0x00400000 /* objects .init has been called */ 8398159SAli.Bahrami@Sun.COM #define FLG_RT_OBJINTPO 0x00800000 /* object is a global interposer */ 8408159SAli.Bahrami@Sun.COM #define FLG_RT_SYMINTPO 0x01000000 /* object contains symbol interposer */ 8418159SAli.Bahrami@Sun.COM #define MSK_RT_INTPOSE 0x01800000 /* mask for all interposer */ 8423466Srie /* possibilities */ 8438159SAli.Bahrami@Sun.COM #define FLG_RT_MOVE 0x02000000 /* object needs move operation */ 8449577SRod.Evans@Sun.COM #define FLG_RT_RELOCING 0x04000000 /* object is being relocated */ 8458159SAli.Bahrami@Sun.COM #define FLG_RT_REGSYMS 0x08000000 /* object has DT_REGISTER entries */ 8468159SAli.Bahrami@Sun.COM #define FLG_RT_INITCLCT 0x10000000 /* init has been collected (tsort) */ 8479577SRod.Evans@Sun.COM #define FLG_RT_PUBHDL 0x20000000 /* generate a handle for this object */ 8489577SRod.Evans@Sun.COM #define FLG_RT_PRIHDL 0x40000000 /* either public or private */ 8490Sstevel@tonic-gate 8500Sstevel@tonic-gate #define FL1_RT_COPYTOOK 0x00000001 /* copy relocation taken */ 85111827SRod.Evans@Sun.COM #define FL1_RT_ALTCHECK 0x00000002 /* alternative system capabilities */ 85211827SRod.Evans@Sun.COM /* checked */ 85311827SRod.Evans@Sun.COM #define FL1_RT_ALTCAP 0x00000004 /* alternative system capabilities */ 85411827SRod.Evans@Sun.COM /* should be used */ 85511827SRod.Evans@Sun.COM #define FL1_RT_CONFSET 0x00000008 /* object was loaded by crle(1) */ 85611827SRod.Evans@Sun.COM #define FL1_RT_NODEFLIB 0x00000010 /* ignore default library search */ 85711827SRod.Evans@Sun.COM #define FL1_RT_ENDFILTE 0x00000020 /* filtee terminates filters search */ 85811827SRod.Evans@Sun.COM #define FL1_RT_DISPREL 0x00000040 /* object has *disp* relocation */ 85911827SRod.Evans@Sun.COM #define FL1_RT_DTFLAGS 0x00000080 /* DT_FLAGS element exists */ 8600Sstevel@tonic-gate #define FL1_RT_LDDSTUB 0x00000100 /* identify lddstub */ 8610Sstevel@tonic-gate #define FL1_RT_NOINIFIN 0x00000200 /* no .init or .fini exists */ 8620Sstevel@tonic-gate #define FL1_RT_USED 0x00000400 /* symbol referenced from this object */ 8630Sstevel@tonic-gate #define FL1_RT_SYMBOLIC 0x00000800 /* DF_SYMBOLIC was set - use */ 8640Sstevel@tonic-gate /* symbolic sym resolution */ 8650Sstevel@tonic-gate #define FL1_RT_OBJSFLTR 0x00001000 /* object is acting as a standard */ 8660Sstevel@tonic-gate #define FL1_RT_OBJAFLTR 0x00002000 /* or auxiliary filter */ 8670Sstevel@tonic-gate #define FL1_RT_SYMSFLTR 0x00004000 /* symbol is acting as a standard */ 8680Sstevel@tonic-gate #define FL1_RT_SYMAFLTR 0x00008000 /* or auxiliary filter */ 8695067Srie #define MSK_RT_FILTER 0x0000f000 /* mask for all filter possibilities */ 8700Sstevel@tonic-gate 8711824Srie #define FL1_RT_TLSADD 0x00010000 /* objects TLS has been registered */ 8722145Srie #define FL1_RT_TLSSTAT 0x00020000 /* object requires static TLS */ 8733466Srie #define FL1_RT_DIRECT 0x00040000 /* object has DIRECT bindings enabled */ 8744679Srie #define FL1_RT_GLOBAUD 0x00080000 /* establish global auditing */ 8751824Srie 8760Sstevel@tonic-gate /* 8770Sstevel@tonic-gate * Flags for the tls_modactivity() routine 8780Sstevel@tonic-gate */ 8790Sstevel@tonic-gate #define TM_FLG_MODADD 0x01 /* call tls_modadd() interface */ 8800Sstevel@tonic-gate #define TM_FLG_MODREM 0x02 /* call tls_modrem() interface */ 8810Sstevel@tonic-gate 8820Sstevel@tonic-gate /* 8838598SRod.Evans@Sun.COM * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION <= 2). 8840Sstevel@tonic-gate */ 8850Sstevel@tonic-gate #define ADDR(X) ((X)->rt_public.l_addr) 8860Sstevel@tonic-gate #define NAME(X) ((X)->rt_public.l_name) 8870Sstevel@tonic-gate #define DYN(X) ((X)->rt_public.l_ld) 8880Sstevel@tonic-gate #define NEXT(X) ((X)->rt_public.l_next) 8890Sstevel@tonic-gate #define PREV(X) ((X)->rt_public.l_prev) 8900Sstevel@tonic-gate #define REFNAME(X) ((X)->rt_public.l_refname) 8910Sstevel@tonic-gate 8920Sstevel@tonic-gate /* 8938394SAli.Bahrami@Sun.COM * An Rt_map starts with a Link_map, followed by other information. 8948394SAli.Bahrami@Sun.COM * ld.so.1 allocates Rt_map structures, and then casts them to Link_map, 8958394SAli.Bahrami@Sun.COM * and back, depending on context. 8968394SAli.Bahrami@Sun.COM * 8978394SAli.Bahrami@Sun.COM * On some platforms, Rt_map can have a higher alignment requirement 8988394SAli.Bahrami@Sun.COM * than Link_map. On such platforms, the cast from Link_map to Rt_map will 8998394SAli.Bahrami@Sun.COM * draw an E_BAD_PTR_CAST_ALIGN warning from lint. Since we allocate 9008394SAli.Bahrami@Sun.COM * the memory as the higher alignment Rt_map, we know that this is a safe 9018394SAli.Bahrami@Sun.COM * conversion. The LINKMAP_TO_RTMAP macro is used to handle the conversion 9028394SAli.Bahrami@Sun.COM * in a manner that satisfies lint. 9038394SAli.Bahrami@Sun.COM */ 9048394SAli.Bahrami@Sun.COM #ifdef lint 9058394SAli.Bahrami@Sun.COM #define LINKMAP_TO_RTMAP(X) (Rt_map *)(void *)(X) 9068394SAli.Bahrami@Sun.COM #else 9078394SAli.Bahrami@Sun.COM #define LINKMAP_TO_RTMAP(X) (Rt_map *)(X) 9088394SAli.Bahrami@Sun.COM #endif 9098394SAli.Bahrami@Sun.COM 9108394SAli.Bahrami@Sun.COM /* 9118394SAli.Bahrami@Sun.COM * Convenience macros for the common case of using 9128394SAli.Bahrami@Sun.COM * NEXT()/PREV() and casting the result to (Rt_map *) 9138394SAli.Bahrami@Sun.COM */ 9148394SAli.Bahrami@Sun.COM #define NEXT_RT_MAP(X) LINKMAP_TO_RTMAP(NEXT(X)) 9158394SAli.Bahrami@Sun.COM #define PREV_RT_MAP(X) LINKMAP_TO_RTMAP(PREV(X)) 9168394SAli.Bahrami@Sun.COM 9178394SAli.Bahrami@Sun.COM /* 9188598SRod.Evans@Sun.COM * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION3). 9190Sstevel@tonic-gate */ 9200Sstevel@tonic-gate #define PATHNAME(X) ((X)->rt_pathname) 9210Sstevel@tonic-gate #define PADSTART(X) ((X)->rt_padstart) 9220Sstevel@tonic-gate #define PADIMLEN(X) ((X)->rt_padimlen) 9230Sstevel@tonic-gate #define MSIZE(X) ((X)->rt_msize) 9240Sstevel@tonic-gate #define FLAGS(X) ((X)->rt_flags) 9250Sstevel@tonic-gate #define FLAGS1(X) ((X)->rt_flags1) 9268598SRod.Evans@Sun.COM 9278598SRod.Evans@Sun.COM /* 9288598SRod.Evans@Sun.COM * Macros for getting to exposed, link_map data (R_RTLDDB_VERSION4). 9298598SRod.Evans@Sun.COM */ 9300Sstevel@tonic-gate #define TLSMODID(X) ((X)->rt_tlsmodid) 9310Sstevel@tonic-gate 9328598SRod.Evans@Sun.COM /* 9338598SRod.Evans@Sun.COM * Macros for getting to unexposed, link-map data. 9348598SRod.Evans@Sun.COM */ 9358598SRod.Evans@Sun.COM #define LMSIZE(X) ((X)->rt_lmsize) 9368598SRod.Evans@Sun.COM #define AFLAGS(X) ((X)->rt_aflags) 9370Sstevel@tonic-gate #define ALIAS(X) ((X)->rt_alias) 9380Sstevel@tonic-gate #define FPNODE(X) ((X)->rt_fpnode) 9390Sstevel@tonic-gate #define INIT(X) ((X)->rt_init) 9400Sstevel@tonic-gate #define FINI(X) ((X)->rt_fini) 9410Sstevel@tonic-gate #define RPATH(X) ((X)->rt_runpath) 9420Sstevel@tonic-gate #define RLIST(X) ((X)->rt_runlist) 9430Sstevel@tonic-gate #define DEPENDS(X) ((X)->rt_depends) 9440Sstevel@tonic-gate #define CALLERS(X) ((X)->rt_callers) 9450Sstevel@tonic-gate #define HANDLES(X) ((X)->rt_handles) 9460Sstevel@tonic-gate #define GROUPS(X) ((X)->rt_groups) 9470Sstevel@tonic-gate #define FCT(X) ((X)->rt_fct) 9480Sstevel@tonic-gate #define SYMINTP(X) ((X)->rt_symintp) 9490Sstevel@tonic-gate #define LIST(X) ((X)->rt_list) 9500Sstevel@tonic-gate #define OBJFLTRNDX(X) ((X)->rt_objfltrndx) 9510Sstevel@tonic-gate #define SYMSFLTRCNT(X) ((X)->rt_symsfltrcnt) 9520Sstevel@tonic-gate #define SYMAFLTRCNT(X) ((X)->rt_symafltrcnt) 9530Sstevel@tonic-gate #define MODE(X) ((X)->rt_mode) 9540Sstevel@tonic-gate #define SORTVAL(X) ((X)->rt_sortval) 9550Sstevel@tonic-gate #define CYCGROUP(X) ((X)->rt_cycgroup) 9560Sstevel@tonic-gate #define STDEV(X) ((X)->rt_stdev) 9570Sstevel@tonic-gate #define STINO(X) ((X)->rt_stino) 9580Sstevel@tonic-gate #define ORIGNAME(X) ((X)->rt_origname) 9590Sstevel@tonic-gate #define DIRSZ(X) ((X)->rt_dirsz) 9605892Sab196087 #define COPY_R(X) ((X)->rt_copy.rtc_r) 9615892Sab196087 #define COPY_S(X) ((X)->rt_copy.rtc_s) 9620Sstevel@tonic-gate #define AUDITORS(X) ((X)->rt_auditors) 9630Sstevel@tonic-gate #define AUDINFO(X) ((X)->rt_audinfo) 9640Sstevel@tonic-gate #define SYMINFO(X) ((X)->rt_syminfo) 9650Sstevel@tonic-gate #define INITARRAY(X) ((X)->rt_initarray) 9660Sstevel@tonic-gate #define FINIARRAY(X) ((X)->rt_finiarray) 9670Sstevel@tonic-gate #define PREINITARRAY(X) ((X)->rt_preinitarray) 9680Sstevel@tonic-gate #define MMAPS(X) ((X)->rt_mmaps) 9690Sstevel@tonic-gate #define MMAPCNT(X) ((X)->rt_mmapcnt) 9700Sstevel@tonic-gate #define INITARRAYSZ(X) ((X)->rt_initarraysz) 9710Sstevel@tonic-gate #define FINIARRAYSZ(X) ((X)->rt_finiarraysz) 9720Sstevel@tonic-gate #define PREINITARRAYSZ(X) ((X)->rt_preinitarraysz) 9730Sstevel@tonic-gate #define DYNINFO(X) ((X)->rt_dyninfo) 9740Sstevel@tonic-gate #define DYNINFOCNT(X) ((X)->rt_dyninfocnt) 9750Sstevel@tonic-gate #define RELACOUNT(X) ((X)->rt_relacount) 9760Sstevel@tonic-gate #define IDX(X) ((X)->rt_idx) 9770Sstevel@tonic-gate #define LAZY(X) ((X)->rt_lazy) 9780Sstevel@tonic-gate #define CNTL(X) ((X)->rt_cntl) 97911827SRod.Evans@Sun.COM #define CAP(X) ((X)->rt_cap) 98011827SRod.Evans@Sun.COM #define CAPCHAIN(X) ((X)->rt_capchain) 9810Sstevel@tonic-gate 982280Srie /* 983280Srie * Flags for tsorting. 984280Srie */ 985280Srie #define RT_SORT_FWD 0x01 /* topological sort (.fini) */ 986280Srie #define RT_SORT_REV 0x02 /* reverse topological sort (.init) */ 9878598SRod.Evans@Sun.COM #define RT_SORT_DELETE 0x10 /* process FLG_RT_DELETE objects */ 988280Srie /* only (called via dlclose()) */ 9893817Srie #define RT_SORT_INTPOSE 0x20 /* process interposer objects */ 9903817Srie 9910Sstevel@tonic-gate /* 9920Sstevel@tonic-gate * Flags for lookup_sym (and hence find_sym) routines. 9930Sstevel@tonic-gate */ 9940Sstevel@tonic-gate #define LKUP_DEFT 0x0000 /* simple lookup request */ 9950Sstevel@tonic-gate #define LKUP_SPEC 0x0001 /* special ELF lookup (allows address */ 9960Sstevel@tonic-gate /* resolutions to plt[] entries) */ 9970Sstevel@tonic-gate #define LKUP_LDOT 0x0002 /* indicates the original A_OUT */ 9980Sstevel@tonic-gate /* symbol had a leading `.' */ 9990Sstevel@tonic-gate #define LKUP_FIRST 0x0004 /* lookup symbol in first link map */ 10000Sstevel@tonic-gate /* only */ 10010Sstevel@tonic-gate #define LKUP_COPY 0x0008 /* lookup symbol for a COPY reloc, do */ 10020Sstevel@tonic-gate /* not bind to symbol at head */ 10035220Srie #define LKUP_STDRELOC 0x0010 /* lookup originates from a standard */ 10045220Srie /* relocation (elf_reloc()) */ 10050Sstevel@tonic-gate #define LKUP_SELF 0x0020 /* lookup symbol in ourself - undef */ 10060Sstevel@tonic-gate /* is valid */ 10070Sstevel@tonic-gate #define LKUP_WEAK 0x0040 /* relocation reference is weak */ 10080Sstevel@tonic-gate #define LKUP_NEXT 0x0080 /* request originates from RTLD_NEXT */ 10090Sstevel@tonic-gate #define LKUP_NODESCENT 0x0100 /* don't descend through dependencies */ 10105950Srie #define LKUP_NOFALLBACK 0x0200 /* don't fall back to loading */ 10110Sstevel@tonic-gate /* pending lazy dependencies */ 10120Sstevel@tonic-gate #define LKUP_DIRECT 0x0400 /* direct binding request */ 1013502Srie #define LKUP_SYMNDX 0x0800 /* establish symbol index */ 10145220Srie #define LKUP_SINGLETON 0x1000 /* search for a singleton symbol */ 10155220Srie #define LKUP_STANDARD 0x2000 /* standard lookup - originated from */ 10165220Srie /* head link-map element */ 10178388SRod.Evans@Sun.COM #define LKUP_WORLD 0x4000 /* ensure world lookup */ 101811827SRod.Evans@Sun.COM #define LKUP_DLSYM 0x8000 /* lookup stems from dlsym() request */ 10190Sstevel@tonic-gate 10200Sstevel@tonic-gate /* 10215950Srie * For the runtime linker to perform a symbol search, a number of data items 10225950Srie * related to the search are required. An Slookup data structure is used to 10235950Srie * convey this data to lookup_sym(), and in special cases, to other core 10245950Srie * routines that provide the implementation details for lookup_sym() 10255950Srie * 10265950Srie * The symbol name (sl_name), the caller (sl_cmap), and the link-map from which 10275950Srie * to start the search (sl_imap) are fundamental to the symbol search. The 10285950Srie * initial search link-map might get modified by the core routines that provide 10295950Srie * the implementation details for lookup_sym(). This modification accommodates 10305950Srie * requirements such as processing a handle, direct binding and interposition. 10315950Srie * The association between the caller and the potential destination also 10325950Srie * determines whether the destination is a candidate to search. 10335950Srie * 10345950Srie * The lookup identifier (sl_id) is used to identify a runtime linker operation. 10355950Srie * Within this operation, any lazy loads that fail are not re-examined. This 10365950Srie * technique keeps the overhead of processing a failed lazy load to a minimum. 10375950Srie * 10385950Srie * Symbol searches that originate from a relocation record are accompanied by 10395950Srie * the relocation index (sl_rsymndx), the symbol reference (sl_rsym) and 10405950Srie * possibly the relocation type (sl_rtype). This data provides for determining 10415950Srie * lazy loading, direct binding, and special symbol processing requirements 10425950Srie * such as copy relocations and singleton lookup. 10435950Srie * 10445950Srie * The symbols hash value is computed by lookup_sym, and propagated throughout 10455950Srie * the search engine. Note, occasionally the Slookup data is passed to a core 10465950Srie * routine that provides the implementation details for lookup_sym(), ie. 10475950Srie * elf_find_sym(), in which case the caller must initialize the hash value. 10485950Srie * 10495950Srie * The symbols binding information is established by lookup_sym() when the 10505950Srie * symbols relocation type is supplied. Weak bindings allow relocations to 10515950Srie * be set to zero should a symbol lookup fail. 10525950Srie * 10535950Srie * The flags allow the caller to control aspects of the search, including the 10545950Srie * interpretation of copy relocations, etc. Note, a number of flag settings 10555950Srie * are established in lookup_sym() from attributes of the symbol reference. 10560Sstevel@tonic-gate */ 10578598SRod.Evans@Sun.COM struct slookup { 10580Sstevel@tonic-gate const char *sl_name; /* symbol name */ 10590Sstevel@tonic-gate Rt_map *sl_cmap; /* callers link-map */ 10600Sstevel@tonic-gate Rt_map *sl_imap; /* initial link-map to search */ 10615950Srie ulong_t sl_id; /* identifier for this lookup */ 10620Sstevel@tonic-gate ulong_t sl_hash; /* symbol hash value */ 10630Sstevel@tonic-gate ulong_t sl_rsymndx; /* referencing reloc symndx */ 10645220Srie Sym *sl_rsym; /* referencing symbol */ 10655220Srie uchar_t sl_rtype; /* relocation type associate with */ 10665220Srie /* symbol */ 10675220Srie uchar_t sl_bind; /* symbols binding (returned) */ 10680Sstevel@tonic-gate uint_t sl_flags; /* lookup flags */ 10698598SRod.Evans@Sun.COM }; 10700Sstevel@tonic-gate 10715950Srie #define SLOOKUP_INIT(sl, name, cmap, imap, id, hash, rsymndx, rsym, rtype, \ 10725950Srie flags) \ 10735950Srie (void) (sl.sl_name = (name), sl.sl_cmap = (cmap), sl.sl_imap = (imap), \ 10745950Srie sl.sl_id = (id), sl.sl_hash = (hash), sl.sl_rsymndx = (rsymndx), \ 10755950Srie sl.sl_rsym = (rsym), sl.sl_rtype = (rtype), sl.sl_bind = 0, \ 10765950Srie sl.sl_flags = (flags)) 10770Sstevel@tonic-gate 10785950Srie /* 107911827SRod.Evans@Sun.COM * After a symbol lookup has been resolved, the runtime linker needs to retain 108011827SRod.Evans@Sun.COM * information regarding the bound definition. An Sresult data structure is 108111827SRod.Evans@Sun.COM * used to provide this information. 108211827SRod.Evans@Sun.COM * 108311827SRod.Evans@Sun.COM * The symbol name (sr_name) may differ from the original referenced symbol if 108411827SRod.Evans@Sun.COM * a symbol capabilities family member has resolved the binding. The defining 108511827SRod.Evans@Sun.COM * object (sr_dmap) indicates the object in which the definition has been found. 108611827SRod.Evans@Sun.COM * The symbol table entry (sr_sym) defines the bound symbol definition. 108711827SRod.Evans@Sun.COM * 108811827SRod.Evans@Sun.COM * Note, a symbol lookup may start with one Sresult buffer, but underlying 108911827SRod.Evans@Sun.COM * routines (for example, those that probe filters) might employ their own 109011827SRod.Evans@Sun.COM * Sresult buffer. If a binding is allowed, the latter buffer may get inherited 109111827SRod.Evans@Sun.COM * by the former. Along with this chain of requests, binding info (binfo) and 109211827SRod.Evans@Sun.COM * not-found information (in_nfavl), may be passed between all the associated 109311827SRod.Evans@Sun.COM * functions. Hence, the binfo and in_nfavl data is not maintained as part of 109411827SRod.Evans@Sun.COM * a Sresult structure. 109511827SRod.Evans@Sun.COM */ 109611827SRod.Evans@Sun.COM struct sresult { 109711827SRod.Evans@Sun.COM const char *sr_name; /* symbol definition name */ 109811827SRod.Evans@Sun.COM Rt_map *sr_dmap; /* defining objects link-map */ 109911827SRod.Evans@Sun.COM Sym *sr_sym; /* symbol table pointer */ 110011827SRod.Evans@Sun.COM }; 110111827SRod.Evans@Sun.COM 110211827SRod.Evans@Sun.COM #define SRESULT_INIT(sr, name) \ 110311827SRod.Evans@Sun.COM (void) (sr.sr_name = (name), sr.sr_dmap = NULL, sr.sr_sym = NULL) 110411827SRod.Evans@Sun.COM 110511827SRod.Evans@Sun.COM /* 110611827SRod.Evans@Sun.COM * Define a system capabilities structure for maintaining the various 110711827SRod.Evans@Sun.COM * capabilities of the system. This structure follows the Objcapset definition 110811827SRod.Evans@Sun.COM * from libld.h, however the system can only have one platform or machine 110911827SRod.Evans@Sun.COM * hardware name, thus this structure is a little simpler. 111011827SRod.Evans@Sun.COM */ 111111827SRod.Evans@Sun.COM typedef struct { 111211827SRod.Evans@Sun.COM elfcap_mask_t sc_hw_1; /* CA_SUNW_HW_1 capabilities */ 111311827SRod.Evans@Sun.COM elfcap_mask_t sc_sf_1; /* CA_SUNW_SF_1 capabilities */ 111411827SRod.Evans@Sun.COM elfcap_mask_t sc_hw_2; /* CA_SUNW_HW_2 capabilities */ 111511827SRod.Evans@Sun.COM char *sc_plat; /* CA_SUNW_PLAT capability */ 111611827SRod.Evans@Sun.COM size_t sc_platsz; /* and size */ 111711827SRod.Evans@Sun.COM char *sc_mach; /* CA_SUNW_MACH capability */ 111811827SRod.Evans@Sun.COM size_t sc_machsz; /* and size */ 111911827SRod.Evans@Sun.COM } Syscapset; 112011827SRod.Evans@Sun.COM 112111827SRod.Evans@Sun.COM /* 11225950Srie * Define a number of .plt lookup outcomes, for use in binding diagnostics. 11235950Srie */ 11240Sstevel@tonic-gate typedef enum { 11250Sstevel@tonic-gate PLT_T_NONE = 0, 11260Sstevel@tonic-gate PLT_T_21D, 11270Sstevel@tonic-gate PLT_T_24D, 11280Sstevel@tonic-gate PLT_T_U32, 11290Sstevel@tonic-gate PLT_T_U44, 11300Sstevel@tonic-gate PLT_T_FULL, 11310Sstevel@tonic-gate PLT_T_FAR, 11320Sstevel@tonic-gate PLT_T_NUM /* Must be last */ 11330Sstevel@tonic-gate } Pltbindtype; 11340Sstevel@tonic-gate 11350Sstevel@tonic-gate /* 11360Sstevel@tonic-gate * Prototypes. 11370Sstevel@tonic-gate */ 11385950Srie extern ulong_t ld_entry_cnt; /* counter bumped on each entry to */ 11395950Srie /* ld.so.1. */ 11400Sstevel@tonic-gate extern Lm_list lml_main; /* main's link map list */ 11410Sstevel@tonic-gate extern Lm_list lml_rtld; /* rtld's link map list */ 11420Sstevel@tonic-gate extern Lm_list *lml_list[]; 11430Sstevel@tonic-gate 11440Sstevel@tonic-gate extern Pltbindtype elf_plt_write(uintptr_t, uintptr_t, void *, uintptr_t, 11450Sstevel@tonic-gate Xword); 11466387Srie extern Rt_map *is_so_loaded(Lm_list *, const char *, int *); 114711827SRod.Evans@Sun.COM extern int lookup_sym(Slookup *, Sresult *, uint_t *, int *); 11480Sstevel@tonic-gate extern int rt_dldump(Rt_map *, const char *, int, Addr); 11490Sstevel@tonic-gate 11500Sstevel@tonic-gate #ifdef __cplusplus 11510Sstevel@tonic-gate } 11520Sstevel@tonic-gate #endif 11530Sstevel@tonic-gate 11540Sstevel@tonic-gate #endif /* _RTLD_H */ 1155