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