xref: /onnv-gate/usr/src/head/link.h (revision 0)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _LINK_H
28*0Sstevel@tonic-gate #define	_LINK_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/link.h>
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #ifndef _ASM
35*0Sstevel@tonic-gate #include <libelf.h>
36*0Sstevel@tonic-gate #include <sys/types.h>
37*0Sstevel@tonic-gate #include <dlfcn.h>
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #ifdef	__cplusplus
41*0Sstevel@tonic-gate extern "C" {
42*0Sstevel@tonic-gate #endif
43*0Sstevel@tonic-gate 
44*0Sstevel@tonic-gate #ifndef _ASM
45*0Sstevel@tonic-gate /*
46*0Sstevel@tonic-gate  * ld support library calls
47*0Sstevel@tonic-gate  */
48*0Sstevel@tonic-gate #ifdef __STDC__
49*0Sstevel@tonic-gate extern uint_t	ld_version(uint_t);
50*0Sstevel@tonic-gate extern void	ld_start(const char *, const Elf32_Half, const char *);
51*0Sstevel@tonic-gate extern void	ld_atexit(int);
52*0Sstevel@tonic-gate extern void	ld_file(const char *, const Elf_Kind, int, Elf *);
53*0Sstevel@tonic-gate extern void	ld_input_section(const char *, Elf32_Shdr **, Elf32_Word,
54*0Sstevel@tonic-gate 			Elf_Data *, Elf *, uint_t *);
55*0Sstevel@tonic-gate extern void	ld_input_done(uint_t *);
56*0Sstevel@tonic-gate extern void	ld_section(const char *, Elf32_Shdr *, Elf32_Word,
57*0Sstevel@tonic-gate 			Elf_Data *, Elf *);
58*0Sstevel@tonic-gate 
59*0Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
60*0Sstevel@tonic-gate extern void	ld_start64(const char *, const Elf64_Half, const char *);
61*0Sstevel@tonic-gate extern void	ld_atexit64(int);
62*0Sstevel@tonic-gate extern void	ld_file64(const char *, const Elf_Kind, int, Elf *);
63*0Sstevel@tonic-gate extern void	ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word,
64*0Sstevel@tonic-gate 			Elf_Data *, Elf *, uint_t *);
65*0Sstevel@tonic-gate extern void	ld_section64(const char *, Elf64_Shdr *, Elf64_Word,
66*0Sstevel@tonic-gate 			Elf_Data *, Elf *);
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
69*0Sstevel@tonic-gate #else
70*0Sstevel@tonic-gate extern void	ld_version();
71*0Sstevel@tonic-gate extern void	ld_start();
72*0Sstevel@tonic-gate extern void	ld_atexit();
73*0Sstevel@tonic-gate extern void	ld_file();
74*0Sstevel@tonic-gate extern void	ld_input_section();
75*0Sstevel@tonic-gate extern void	ld_input_done();
76*0Sstevel@tonic-gate extern void	ld_section();
77*0Sstevel@tonic-gate 
78*0Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
79*0Sstevel@tonic-gate extern void	ld_start64();
80*0Sstevel@tonic-gate extern void	ld_atexit64();
81*0Sstevel@tonic-gate extern void	ld_file64();
82*0Sstevel@tonic-gate extern void	ld_section64();
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
85*0Sstevel@tonic-gate #endif /* __STDC__ */
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate /*
88*0Sstevel@tonic-gate  * ld_version() version values
89*0Sstevel@tonic-gate  */
90*0Sstevel@tonic-gate #define	LD_SUP_VNONE	0
91*0Sstevel@tonic-gate #define	LD_SUP_VERSION1	1
92*0Sstevel@tonic-gate #define	LD_SUP_VERSION2	2
93*0Sstevel@tonic-gate #define	LD_SUP_VCURRENT	LD_SUP_VERSION2
94*0Sstevel@tonic-gate 
95*0Sstevel@tonic-gate 
96*0Sstevel@tonic-gate /*
97*0Sstevel@tonic-gate  * flags passed to ld support calls
98*0Sstevel@tonic-gate  */
99*0Sstevel@tonic-gate #define	LD_SUP_DERIVED		0x1	/* derived filename */
100*0Sstevel@tonic-gate #define	LD_SUP_INHERITED	0x2	/* file inherited from .so DT_NEEDED */
101*0Sstevel@tonic-gate #define	LD_SUP_EXTRACTED	0x4	/* file extracted from archive */
102*0Sstevel@tonic-gate #endif
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate #define	LM_ID_BASE		0x00
105*0Sstevel@tonic-gate #define	LM_ID_LDSO		0x01
106*0Sstevel@tonic-gate #define	LM_ID_NUM		2
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate #define	LM_ID_NEWLM		0xff	/* create a new link-map */
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate 
111*0Sstevel@tonic-gate /*
112*0Sstevel@tonic-gate  * Run-Time Link-Edit Auditing
113*0Sstevel@tonic-gate  */
114*0Sstevel@tonic-gate #define	LAV_NONE		0
115*0Sstevel@tonic-gate #define	LAV_VERSION1		1
116*0Sstevel@tonic-gate #define	LAV_VERSION2		2
117*0Sstevel@tonic-gate #define	LAV_VERSION3		3
118*0Sstevel@tonic-gate #define	LAV_CURRENT		LAV_VERSION3
119*0Sstevel@tonic-gate #define	LAV_NUM			4
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate /*
122*0Sstevel@tonic-gate  * Flags that can be or'd into the la_objopen() return code
123*0Sstevel@tonic-gate  */
124*0Sstevel@tonic-gate #define	LA_FLG_BINDTO		0x0001	/* audit symbinds TO this object */
125*0Sstevel@tonic-gate #define	LA_FLG_BINDFROM		0x0002	/* audit symbinding FROM this object */
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate /*
128*0Sstevel@tonic-gate  * Flags that can be or'd into the 'flags' argument of la_symbind()
129*0Sstevel@tonic-gate  */
130*0Sstevel@tonic-gate #define	LA_SYMB_NOPLTENTER	0x0001	/* disable pltenter for this symbol */
131*0Sstevel@tonic-gate #define	LA_SYMB_NOPLTEXIT	0x0002	/* disable pltexit for this symbol */
132*0Sstevel@tonic-gate #define	LA_SYMB_STRUCTCALL	0x0004	/* this function call passes a */
133*0Sstevel@tonic-gate 					/*	structure as it's return code */
134*0Sstevel@tonic-gate #define	LA_SYMB_DLSYM		0x0008	/* this symbol bindings is due to */
135*0Sstevel@tonic-gate 					/*	a call to dlsym() */
136*0Sstevel@tonic-gate #define	LA_SYMB_ALTVALUE	0x0010	/* alternate symbol binding returned */
137*0Sstevel@tonic-gate 					/*	by la_symbind() */
138*0Sstevel@tonic-gate 
139*0Sstevel@tonic-gate /*
140*0Sstevel@tonic-gate  * Flags that describe the object passed to la_objsearch()
141*0Sstevel@tonic-gate  */
142*0Sstevel@tonic-gate #define	LA_SER_ORIG		0x001	/* original (needed) name */
143*0Sstevel@tonic-gate #define	LA_SER_LIBPATH		0x002	/* LD_LIBRARY_PATH entry prepended */
144*0Sstevel@tonic-gate #define	LA_SER_RUNPATH		0x004	/* runpath entry prepended */
145*0Sstevel@tonic-gate #define	LA_SER_CONFIG		0x008	/* configuration entry prepended */
146*0Sstevel@tonic-gate #define	LA_SER_DEFAULT		0x040	/* default path prepended */
147*0Sstevel@tonic-gate #define	LA_SER_SECURE		0x080	/* default (secure) path prepended */
148*0Sstevel@tonic-gate 
149*0Sstevel@tonic-gate #define	LA_SER_MASK		0xfff	/* mask of known flags */
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate /*
152*0Sstevel@tonic-gate  * Flags that describe the la_activity()
153*0Sstevel@tonic-gate  */
154*0Sstevel@tonic-gate #define	LA_ACT_CONSISTENT	0x00	/* add/deletion of objects complete */
155*0Sstevel@tonic-gate #define	LA_ACT_ADD		0x01	/* objects being added */
156*0Sstevel@tonic-gate #define	LA_ACT_DELETE		0x02	/* objects being deleted */
157*0Sstevel@tonic-gate 
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate #ifndef	_KERNEL
160*0Sstevel@tonic-gate #ifndef	_ASM
161*0Sstevel@tonic-gate 
162*0Sstevel@tonic-gate #if defined(_LP64)
163*0Sstevel@tonic-gate typedef long	lagreg_t;
164*0Sstevel@tonic-gate #else
165*0Sstevel@tonic-gate typedef int	lagreg_t;
166*0Sstevel@tonic-gate #endif
167*0Sstevel@tonic-gate 
168*0Sstevel@tonic-gate struct _la_sparc_regs {
169*0Sstevel@tonic-gate 	lagreg_t	lr_rego0;
170*0Sstevel@tonic-gate 	lagreg_t	lr_rego1;
171*0Sstevel@tonic-gate 	lagreg_t	lr_rego2;
172*0Sstevel@tonic-gate 	lagreg_t	lr_rego3;
173*0Sstevel@tonic-gate 	lagreg_t	lr_rego4;
174*0Sstevel@tonic-gate 	lagreg_t	lr_rego5;
175*0Sstevel@tonic-gate 	lagreg_t	lr_rego6;
176*0Sstevel@tonic-gate 	lagreg_t	lr_rego7;
177*0Sstevel@tonic-gate };
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate #if defined(_LP64)
180*0Sstevel@tonic-gate typedef struct _la_sparc_regs	La_sparcv9_regs;
181*0Sstevel@tonic-gate typedef struct {
182*0Sstevel@tonic-gate 	lagreg_t	lr_rsp;
183*0Sstevel@tonic-gate 	lagreg_t	lr_rbp;
184*0Sstevel@tonic-gate 	lagreg_t	lr_rdi;	    /* arg1 */
185*0Sstevel@tonic-gate 	lagreg_t	lr_rsi;	    /* arg2 */
186*0Sstevel@tonic-gate 	lagreg_t	lr_rdx;	    /* arg3 */
187*0Sstevel@tonic-gate 	lagreg_t	lr_rcx;	    /* arg4 */
188*0Sstevel@tonic-gate 	lagreg_t	lr_r8;	    /* arg5 */
189*0Sstevel@tonic-gate 	lagreg_t	lr_r9;	    /* arg6 */
190*0Sstevel@tonic-gate } La_amd64_regs;
191*0Sstevel@tonic-gate #else
192*0Sstevel@tonic-gate typedef struct _la_sparc_regs	La_sparcv8_regs;
193*0Sstevel@tonic-gate typedef struct {
194*0Sstevel@tonic-gate 	lagreg_t	lr_esp;
195*0Sstevel@tonic-gate 	lagreg_t	lr_ebp;
196*0Sstevel@tonic-gate } La_i86_regs;
197*0Sstevel@tonic-gate #endif
198*0Sstevel@tonic-gate 
199*0Sstevel@tonic-gate #if	!defined(_SYS_INT_TYPES_H)
200*0Sstevel@tonic-gate #if	defined(_LP64) || defined(_I32LPx)
201*0Sstevel@tonic-gate typedef unsigned long		uintptr_t;
202*0Sstevel@tonic-gate #else
203*0Sstevel@tonic-gate typedef	unsigned int		uintptr_t;
204*0Sstevel@tonic-gate #endif
205*0Sstevel@tonic-gate #endif
206*0Sstevel@tonic-gate 
207*0Sstevel@tonic-gate 
208*0Sstevel@tonic-gate #ifdef	__STDC__
209*0Sstevel@tonic-gate extern uint_t		la_version(uint_t);
210*0Sstevel@tonic-gate extern void		la_activity(uintptr_t *, uint_t);
211*0Sstevel@tonic-gate extern void		la_preinit(uintptr_t *);
212*0Sstevel@tonic-gate extern char		*la_objsearch(const char *, uintptr_t *, uint_t);
213*0Sstevel@tonic-gate extern uint_t		la_objopen(Link_map *, Lmid_t, uintptr_t *);
214*0Sstevel@tonic-gate extern uint_t		la_objclose(uintptr_t *);
215*0Sstevel@tonic-gate extern int		la_objfilter(uintptr_t *, const char *, uintptr_t *,
216*0Sstevel@tonic-gate 				uint_t);
217*0Sstevel@tonic-gate #if	defined(_LP64)
218*0Sstevel@tonic-gate extern uintptr_t	la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
219*0Sstevel@tonic-gate 				uintptr_t *, La_amd64_regs *,	uint_t *,
220*0Sstevel@tonic-gate 				const char *);
221*0Sstevel@tonic-gate extern uintptr_t	la_symbind64(Elf64_Sym *, uint_t, uintptr_t *,
222*0Sstevel@tonic-gate 				uintptr_t *, uint_t *, const char *);
223*0Sstevel@tonic-gate extern uintptr_t	la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
224*0Sstevel@tonic-gate 				uintptr_t *, La_sparcv9_regs *,	uint_t *,
225*0Sstevel@tonic-gate 				const char *);
226*0Sstevel@tonic-gate extern uintptr_t	la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *,
227*0Sstevel@tonic-gate 				uintptr_t *, uintptr_t, const char *);
228*0Sstevel@tonic-gate #else  /* !defined(_LP64) */
229*0Sstevel@tonic-gate extern uintptr_t	la_symbind32(Elf32_Sym *, uint_t, uintptr_t *,
230*0Sstevel@tonic-gate 				uintptr_t *, uint_t *);
231*0Sstevel@tonic-gate extern uintptr_t	la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
232*0Sstevel@tonic-gate 				uintptr_t *, La_sparcv8_regs *, uint_t *);
233*0Sstevel@tonic-gate extern uintptr_t	la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
234*0Sstevel@tonic-gate 				uintptr_t *, La_i86_regs *, uint_t *);
235*0Sstevel@tonic-gate extern uintptr_t	la_pltexit(Elf32_Sym *, uint_t, uintptr_t *,
236*0Sstevel@tonic-gate 				uintptr_t *, uintptr_t);
237*0Sstevel@tonic-gate #endif /* _LP64 */
238*0Sstevel@tonic-gate #else  /* __STDC__ */
239*0Sstevel@tonic-gate extern uint_t		la_version();
240*0Sstevel@tonic-gate extern void		la_preinit();
241*0Sstevel@tonic-gate extern uint_t		la_objopen();
242*0Sstevel@tonic-gate extern uint_t		la_objclose();
243*0Sstevel@tonic-gate extern int		la_objfilter();
244*0Sstevel@tonic-gate #if	defined(_LP64)
245*0Sstevel@tonic-gate extern uintptr_t	la_sparcv9_pltenter();
246*0Sstevel@tonic-gate extern uintptr_t	la_pltexit64();
247*0Sstevel@tonic-gate extern uintptr_t	la_symbind64();
248*0Sstevel@tonic-gate #else  /* _ILP32 */
249*0Sstevel@tonic-gate extern uintptr_t	la_sparcv8_pltenter();
250*0Sstevel@tonic-gate extern uintptr_t	la_i86_pltenter();
251*0Sstevel@tonic-gate extern uintptr_t	la_pltexit();
252*0Sstevel@tonic-gate extern uintptr_t	la_symbind32();
253*0Sstevel@tonic-gate #endif /* _LP64 */
254*0Sstevel@tonic-gate #endif /* __STDC__ */
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate #endif /* _ASM */
258*0Sstevel@tonic-gate #endif /* _KERNEL */
259*0Sstevel@tonic-gate 
260*0Sstevel@tonic-gate #ifdef __cplusplus
261*0Sstevel@tonic-gate }
262*0Sstevel@tonic-gate #endif
263*0Sstevel@tonic-gate 
264*0Sstevel@tonic-gate #endif	/* _LINK_H */
265