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 59acbbeafSnn35248 * Common Development and Distribution License (the "License"). 69acbbeafSnn35248 * 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 */ 217c478bd9Sstevel@tonic-gate /* 229acbbeafSnn35248 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _LINK_H 277c478bd9Sstevel@tonic-gate #define _LINK_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #include <sys/link.h> 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifndef _ASM 347c478bd9Sstevel@tonic-gate #include <libelf.h> 357c478bd9Sstevel@tonic-gate #include <sys/types.h> 367c478bd9Sstevel@tonic-gate #include <dlfcn.h> 377c478bd9Sstevel@tonic-gate #endif 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef __cplusplus 407c478bd9Sstevel@tonic-gate extern "C" { 417c478bd9Sstevel@tonic-gate #endif 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifndef _ASM 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * ld support library calls 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate #ifdef __STDC__ 487c478bd9Sstevel@tonic-gate extern uint_t ld_version(uint_t); 49*3906e0c2Srie extern void ld_input_done(uint_t *); 50*3906e0c2Srie 517c478bd9Sstevel@tonic-gate extern void ld_start(const char *, const Elf32_Half, const char *); 527c478bd9Sstevel@tonic-gate extern void ld_atexit(int); 53*3906e0c2Srie extern void ld_open(const char **, const char **, int *, int, Elf **, 54*3906e0c2Srie Elf *, size_t, const Elf_Kind); 557c478bd9Sstevel@tonic-gate extern void ld_file(const char *, const Elf_Kind, int, Elf *); 567c478bd9Sstevel@tonic-gate extern void ld_input_section(const char *, Elf32_Shdr **, Elf32_Word, 577c478bd9Sstevel@tonic-gate Elf_Data *, Elf *, uint_t *); 587c478bd9Sstevel@tonic-gate extern void ld_section(const char *, Elf32_Shdr *, Elf32_Word, 597c478bd9Sstevel@tonic-gate Elf_Data *, Elf *); 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 627c478bd9Sstevel@tonic-gate extern void ld_start64(const char *, const Elf64_Half, const char *); 637c478bd9Sstevel@tonic-gate extern void ld_atexit64(int); 64*3906e0c2Srie extern void ld_open64(const char **, const char **, int *, int, Elf **, 65*3906e0c2Srie Elf *, size_t, const Elf_Kind); 667c478bd9Sstevel@tonic-gate extern void ld_file64(const char *, const Elf_Kind, int, Elf *); 677c478bd9Sstevel@tonic-gate extern void ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word, 687c478bd9Sstevel@tonic-gate Elf_Data *, Elf *, uint_t *); 697c478bd9Sstevel@tonic-gate extern void ld_section64(const char *, Elf64_Shdr *, Elf64_Word, 707c478bd9Sstevel@tonic-gate Elf_Data *, Elf *); 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */ 737c478bd9Sstevel@tonic-gate #else 747c478bd9Sstevel@tonic-gate extern void ld_version(); 75*3906e0c2Srie extern void ld_input_done(); 76*3906e0c2Srie 777c478bd9Sstevel@tonic-gate extern void ld_start(); 787c478bd9Sstevel@tonic-gate extern void ld_atexit(); 79*3906e0c2Srie extern void ld_open(); 807c478bd9Sstevel@tonic-gate extern void ld_file(); 817c478bd9Sstevel@tonic-gate extern void ld_input_section(); 827c478bd9Sstevel@tonic-gate extern void ld_section(); 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE) 857c478bd9Sstevel@tonic-gate extern void ld_start64(); 867c478bd9Sstevel@tonic-gate extern void ld_atexit64(); 87*3906e0c2Srie extern void ld_open64(); 887c478bd9Sstevel@tonic-gate extern void ld_file64(); 89*3906e0c2Srie extern void ld_input_section64(); 907c478bd9Sstevel@tonic-gate extern void ld_section64(); 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */ 937c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* 96*3906e0c2Srie * ld_version() version values. 977c478bd9Sstevel@tonic-gate */ 987c478bd9Sstevel@tonic-gate #define LD_SUP_VNONE 0 997c478bd9Sstevel@tonic-gate #define LD_SUP_VERSION1 1 1007c478bd9Sstevel@tonic-gate #define LD_SUP_VERSION2 2 101*3906e0c2Srie #define LD_SUP_VERSION3 3 102*3906e0c2Srie #define LD_SUP_VCURRENT LD_SUP_VERSION3 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* 105*3906e0c2Srie * Flags passed to ld support calls. 1067c478bd9Sstevel@tonic-gate */ 1077c478bd9Sstevel@tonic-gate #define LD_SUP_DERIVED 0x1 /* derived filename */ 1087c478bd9Sstevel@tonic-gate #define LD_SUP_INHERITED 0x2 /* file inherited from .so DT_NEEDED */ 1097c478bd9Sstevel@tonic-gate #define LD_SUP_EXTRACTED 0x4 /* file extracted from archive */ 1107c478bd9Sstevel@tonic-gate #endif 1117c478bd9Sstevel@tonic-gate 112*3906e0c2Srie /* 113*3906e0c2Srie * Runtime link-map identifiers. 114*3906e0c2Srie */ 1157c478bd9Sstevel@tonic-gate #define LM_ID_BASE 0x00 1167c478bd9Sstevel@tonic-gate #define LM_ID_LDSO 0x01 1179acbbeafSnn35248 #define LM_ID_BRAND 0x02 /* marks branded objs in rd_loadobj_t */ 1189acbbeafSnn35248 1199acbbeafSnn35248 #define LM_ID_NUM 3 1209acbbeafSnn35248 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate #define LM_ID_NEWLM 0xff /* create a new link-map */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 125*3906e0c2Srie * Runtime Link-Edit Auditing. 1267c478bd9Sstevel@tonic-gate */ 1277c478bd9Sstevel@tonic-gate #define LAV_NONE 0 1287c478bd9Sstevel@tonic-gate #define LAV_VERSION1 1 1297c478bd9Sstevel@tonic-gate #define LAV_VERSION2 2 1307c478bd9Sstevel@tonic-gate #define LAV_VERSION3 3 1317c478bd9Sstevel@tonic-gate #define LAV_CURRENT LAV_VERSION3 1327c478bd9Sstevel@tonic-gate #define LAV_NUM 4 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* 1357c478bd9Sstevel@tonic-gate * Flags that can be or'd into the la_objopen() return code 1367c478bd9Sstevel@tonic-gate */ 1377c478bd9Sstevel@tonic-gate #define LA_FLG_BINDTO 0x0001 /* audit symbinds TO this object */ 1387c478bd9Sstevel@tonic-gate #define LA_FLG_BINDFROM 0x0002 /* audit symbinding FROM this object */ 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* 1417c478bd9Sstevel@tonic-gate * Flags that can be or'd into the 'flags' argument of la_symbind() 1427c478bd9Sstevel@tonic-gate */ 1437c478bd9Sstevel@tonic-gate #define LA_SYMB_NOPLTENTER 0x0001 /* disable pltenter for this symbol */ 1447c478bd9Sstevel@tonic-gate #define LA_SYMB_NOPLTEXIT 0x0002 /* disable pltexit for this symbol */ 1457c478bd9Sstevel@tonic-gate #define LA_SYMB_STRUCTCALL 0x0004 /* this function call passes a */ 1467c478bd9Sstevel@tonic-gate /* structure as it's return code */ 1477c478bd9Sstevel@tonic-gate #define LA_SYMB_DLSYM 0x0008 /* this symbol bindings is due to */ 1487c478bd9Sstevel@tonic-gate /* a call to dlsym() */ 1497c478bd9Sstevel@tonic-gate #define LA_SYMB_ALTVALUE 0x0010 /* alternate symbol binding returned */ 1507c478bd9Sstevel@tonic-gate /* by la_symbind() */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Flags that describe the object passed to la_objsearch() 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate #define LA_SER_ORIG 0x001 /* original (needed) name */ 1567c478bd9Sstevel@tonic-gate #define LA_SER_LIBPATH 0x002 /* LD_LIBRARY_PATH entry prepended */ 1577c478bd9Sstevel@tonic-gate #define LA_SER_RUNPATH 0x004 /* runpath entry prepended */ 1587c478bd9Sstevel@tonic-gate #define LA_SER_CONFIG 0x008 /* configuration entry prepended */ 1597c478bd9Sstevel@tonic-gate #define LA_SER_DEFAULT 0x040 /* default path prepended */ 1607c478bd9Sstevel@tonic-gate #define LA_SER_SECURE 0x080 /* default (secure) path prepended */ 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #define LA_SER_MASK 0xfff /* mask of known flags */ 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate /* 1657c478bd9Sstevel@tonic-gate * Flags that describe the la_activity() 1667c478bd9Sstevel@tonic-gate */ 1677c478bd9Sstevel@tonic-gate #define LA_ACT_CONSISTENT 0x00 /* add/deletion of objects complete */ 1687c478bd9Sstevel@tonic-gate #define LA_ACT_ADD 0x01 /* objects being added */ 1697c478bd9Sstevel@tonic-gate #define LA_ACT_DELETE 0x02 /* objects being deleted */ 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate 1727c478bd9Sstevel@tonic-gate #ifndef _KERNEL 1737c478bd9Sstevel@tonic-gate #ifndef _ASM 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate #if defined(_LP64) 1767c478bd9Sstevel@tonic-gate typedef long lagreg_t; 1777c478bd9Sstevel@tonic-gate #else 1787c478bd9Sstevel@tonic-gate typedef int lagreg_t; 1797c478bd9Sstevel@tonic-gate #endif 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate struct _la_sparc_regs { 1827c478bd9Sstevel@tonic-gate lagreg_t lr_rego0; 1837c478bd9Sstevel@tonic-gate lagreg_t lr_rego1; 1847c478bd9Sstevel@tonic-gate lagreg_t lr_rego2; 1857c478bd9Sstevel@tonic-gate lagreg_t lr_rego3; 1867c478bd9Sstevel@tonic-gate lagreg_t lr_rego4; 1877c478bd9Sstevel@tonic-gate lagreg_t lr_rego5; 1887c478bd9Sstevel@tonic-gate lagreg_t lr_rego6; 1897c478bd9Sstevel@tonic-gate lagreg_t lr_rego7; 1907c478bd9Sstevel@tonic-gate }; 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate #if defined(_LP64) 1937c478bd9Sstevel@tonic-gate typedef struct _la_sparc_regs La_sparcv9_regs; 1947c478bd9Sstevel@tonic-gate typedef struct { 1957c478bd9Sstevel@tonic-gate lagreg_t lr_rsp; 1967c478bd9Sstevel@tonic-gate lagreg_t lr_rbp; 1977c478bd9Sstevel@tonic-gate lagreg_t lr_rdi; /* arg1 */ 1987c478bd9Sstevel@tonic-gate lagreg_t lr_rsi; /* arg2 */ 1997c478bd9Sstevel@tonic-gate lagreg_t lr_rdx; /* arg3 */ 2007c478bd9Sstevel@tonic-gate lagreg_t lr_rcx; /* arg4 */ 2017c478bd9Sstevel@tonic-gate lagreg_t lr_r8; /* arg5 */ 2027c478bd9Sstevel@tonic-gate lagreg_t lr_r9; /* arg6 */ 2037c478bd9Sstevel@tonic-gate } La_amd64_regs; 2047c478bd9Sstevel@tonic-gate #else 2057c478bd9Sstevel@tonic-gate typedef struct _la_sparc_regs La_sparcv8_regs; 2067c478bd9Sstevel@tonic-gate typedef struct { 2077c478bd9Sstevel@tonic-gate lagreg_t lr_esp; 2087c478bd9Sstevel@tonic-gate lagreg_t lr_ebp; 2097c478bd9Sstevel@tonic-gate } La_i86_regs; 2107c478bd9Sstevel@tonic-gate #endif 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate #if !defined(_SYS_INT_TYPES_H) 2137c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_I32LPx) 2147c478bd9Sstevel@tonic-gate typedef unsigned long uintptr_t; 2157c478bd9Sstevel@tonic-gate #else 2167c478bd9Sstevel@tonic-gate typedef unsigned int uintptr_t; 2177c478bd9Sstevel@tonic-gate #endif 2187c478bd9Sstevel@tonic-gate #endif 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate #ifdef __STDC__ 2227c478bd9Sstevel@tonic-gate extern uint_t la_version(uint_t); 2237c478bd9Sstevel@tonic-gate extern void la_activity(uintptr_t *, uint_t); 2247c478bd9Sstevel@tonic-gate extern void la_preinit(uintptr_t *); 2257c478bd9Sstevel@tonic-gate extern char *la_objsearch(const char *, uintptr_t *, uint_t); 2267c478bd9Sstevel@tonic-gate extern uint_t la_objopen(Link_map *, Lmid_t, uintptr_t *); 2277c478bd9Sstevel@tonic-gate extern uint_t la_objclose(uintptr_t *); 2287c478bd9Sstevel@tonic-gate extern int la_objfilter(uintptr_t *, const char *, uintptr_t *, 2297c478bd9Sstevel@tonic-gate uint_t); 2307c478bd9Sstevel@tonic-gate #if defined(_LP64) 2317c478bd9Sstevel@tonic-gate extern uintptr_t la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *, 2327c478bd9Sstevel@tonic-gate uintptr_t *, La_amd64_regs *, uint_t *, 2337c478bd9Sstevel@tonic-gate const char *); 2347c478bd9Sstevel@tonic-gate extern uintptr_t la_symbind64(Elf64_Sym *, uint_t, uintptr_t *, 2357c478bd9Sstevel@tonic-gate uintptr_t *, uint_t *, const char *); 2367c478bd9Sstevel@tonic-gate extern uintptr_t la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *, 2377c478bd9Sstevel@tonic-gate uintptr_t *, La_sparcv9_regs *, uint_t *, 2387c478bd9Sstevel@tonic-gate const char *); 2397c478bd9Sstevel@tonic-gate extern uintptr_t la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *, 2407c478bd9Sstevel@tonic-gate uintptr_t *, uintptr_t, const char *); 2417c478bd9Sstevel@tonic-gate #else /* !defined(_LP64) */ 2427c478bd9Sstevel@tonic-gate extern uintptr_t la_symbind32(Elf32_Sym *, uint_t, uintptr_t *, 2437c478bd9Sstevel@tonic-gate uintptr_t *, uint_t *); 2447c478bd9Sstevel@tonic-gate extern uintptr_t la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *, 2457c478bd9Sstevel@tonic-gate uintptr_t *, La_sparcv8_regs *, uint_t *); 2467c478bd9Sstevel@tonic-gate extern uintptr_t la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *, 2477c478bd9Sstevel@tonic-gate uintptr_t *, La_i86_regs *, uint_t *); 2487c478bd9Sstevel@tonic-gate extern uintptr_t la_pltexit(Elf32_Sym *, uint_t, uintptr_t *, 2497c478bd9Sstevel@tonic-gate uintptr_t *, uintptr_t); 2507c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 2517c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 2527c478bd9Sstevel@tonic-gate extern uint_t la_version(); 2537c478bd9Sstevel@tonic-gate extern void la_preinit(); 2547c478bd9Sstevel@tonic-gate extern uint_t la_objopen(); 2557c478bd9Sstevel@tonic-gate extern uint_t la_objclose(); 2567c478bd9Sstevel@tonic-gate extern int la_objfilter(); 2577c478bd9Sstevel@tonic-gate #if defined(_LP64) 2587c478bd9Sstevel@tonic-gate extern uintptr_t la_sparcv9_pltenter(); 2597c478bd9Sstevel@tonic-gate extern uintptr_t la_pltexit64(); 2607c478bd9Sstevel@tonic-gate extern uintptr_t la_symbind64(); 2617c478bd9Sstevel@tonic-gate #else /* _ILP32 */ 2627c478bd9Sstevel@tonic-gate extern uintptr_t la_sparcv8_pltenter(); 2637c478bd9Sstevel@tonic-gate extern uintptr_t la_i86_pltenter(); 2647c478bd9Sstevel@tonic-gate extern uintptr_t la_pltexit(); 2657c478bd9Sstevel@tonic-gate extern uintptr_t la_symbind32(); 2667c478bd9Sstevel@tonic-gate #endif /* _LP64 */ 2677c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate #endif /* _ASM */ 2717c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2727c478bd9Sstevel@tonic-gate 2737c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2747c478bd9Sstevel@tonic-gate } 2757c478bd9Sstevel@tonic-gate #endif 2767c478bd9Sstevel@tonic-gate 2777c478bd9Sstevel@tonic-gate #endif /* _LINK_H */ 278