xref: /titanic_54/usr/src/head/link.h (revision 9acbbeaf2a1ffe5c14b244867d427714fab43c5c)
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
5*9acbbeafSnn35248  * Common Development and Distribution License (the "License").
6*9acbbeafSnn35248  * 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 /*
22*9acbbeafSnn35248  * 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);
497c478bd9Sstevel@tonic-gate extern void	ld_start(const char *, const Elf32_Half, const char *);
507c478bd9Sstevel@tonic-gate extern void	ld_atexit(int);
517c478bd9Sstevel@tonic-gate extern void	ld_file(const char *, const Elf_Kind, int, Elf *);
527c478bd9Sstevel@tonic-gate extern void	ld_input_section(const char *, Elf32_Shdr **, Elf32_Word,
537c478bd9Sstevel@tonic-gate 			Elf_Data *, Elf *, uint_t *);
547c478bd9Sstevel@tonic-gate extern void	ld_input_done(uint_t *);
557c478bd9Sstevel@tonic-gate extern void	ld_section(const char *, Elf32_Shdr *, Elf32_Word,
567c478bd9Sstevel@tonic-gate 			Elf_Data *, Elf *);
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
597c478bd9Sstevel@tonic-gate extern void	ld_start64(const char *, const Elf64_Half, const char *);
607c478bd9Sstevel@tonic-gate extern void	ld_atexit64(int);
617c478bd9Sstevel@tonic-gate extern void	ld_file64(const char *, const Elf_Kind, int, Elf *);
627c478bd9Sstevel@tonic-gate extern void	ld_input_section64(const char *, Elf64_Shdr **, Elf64_Word,
637c478bd9Sstevel@tonic-gate 			Elf_Data *, Elf *, uint_t *);
647c478bd9Sstevel@tonic-gate extern void	ld_section64(const char *, Elf64_Shdr *, Elf64_Word,
657c478bd9Sstevel@tonic-gate 			Elf_Data *, Elf *);
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
687c478bd9Sstevel@tonic-gate #else
697c478bd9Sstevel@tonic-gate extern void	ld_version();
707c478bd9Sstevel@tonic-gate extern void	ld_start();
717c478bd9Sstevel@tonic-gate extern void	ld_atexit();
727c478bd9Sstevel@tonic-gate extern void	ld_file();
737c478bd9Sstevel@tonic-gate extern void	ld_input_section();
747c478bd9Sstevel@tonic-gate extern void	ld_input_done();
757c478bd9Sstevel@tonic-gate extern void	ld_section();
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate #if defined(_LP64) || defined(_LONGLONG_TYPE)
787c478bd9Sstevel@tonic-gate extern void	ld_start64();
797c478bd9Sstevel@tonic-gate extern void	ld_atexit64();
807c478bd9Sstevel@tonic-gate extern void	ld_file64();
817c478bd9Sstevel@tonic-gate extern void	ld_section64();
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate #endif /* (defined(_LP64) || defined(_LONGLONG_TYPE) */
847c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * ld_version() version values
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate #define	LD_SUP_VNONE	0
907c478bd9Sstevel@tonic-gate #define	LD_SUP_VERSION1	1
917c478bd9Sstevel@tonic-gate #define	LD_SUP_VERSION2	2
927c478bd9Sstevel@tonic-gate #define	LD_SUP_VCURRENT	LD_SUP_VERSION2
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /*
967c478bd9Sstevel@tonic-gate  * flags passed to ld support calls
977c478bd9Sstevel@tonic-gate  */
987c478bd9Sstevel@tonic-gate #define	LD_SUP_DERIVED		0x1	/* derived filename */
997c478bd9Sstevel@tonic-gate #define	LD_SUP_INHERITED	0x2	/* file inherited from .so DT_NEEDED */
1007c478bd9Sstevel@tonic-gate #define	LD_SUP_EXTRACTED	0x4	/* file extracted from archive */
1017c478bd9Sstevel@tonic-gate #endif
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #define	LM_ID_BASE		0x00
1047c478bd9Sstevel@tonic-gate #define	LM_ID_LDSO		0x01
105*9acbbeafSnn35248 #define	LM_ID_BRAND		0x02	/* marks branded objs in rd_loadobj_t */
106*9acbbeafSnn35248 
107*9acbbeafSnn35248 #define	LM_ID_NUM		3
108*9acbbeafSnn35248 
1097c478bd9Sstevel@tonic-gate 
1107c478bd9Sstevel@tonic-gate #define	LM_ID_NEWLM		0xff	/* create a new link-map */
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate /*
1147c478bd9Sstevel@tonic-gate  * Run-Time Link-Edit Auditing
1157c478bd9Sstevel@tonic-gate  */
1167c478bd9Sstevel@tonic-gate #define	LAV_NONE		0
1177c478bd9Sstevel@tonic-gate #define	LAV_VERSION1		1
1187c478bd9Sstevel@tonic-gate #define	LAV_VERSION2		2
1197c478bd9Sstevel@tonic-gate #define	LAV_VERSION3		3
1207c478bd9Sstevel@tonic-gate #define	LAV_CURRENT		LAV_VERSION3
1217c478bd9Sstevel@tonic-gate #define	LAV_NUM			4
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate /*
1247c478bd9Sstevel@tonic-gate  * Flags that can be or'd into the la_objopen() return code
1257c478bd9Sstevel@tonic-gate  */
1267c478bd9Sstevel@tonic-gate #define	LA_FLG_BINDTO		0x0001	/* audit symbinds TO this object */
1277c478bd9Sstevel@tonic-gate #define	LA_FLG_BINDFROM		0x0002	/* audit symbinding FROM this object */
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate /*
1307c478bd9Sstevel@tonic-gate  * Flags that can be or'd into the 'flags' argument of la_symbind()
1317c478bd9Sstevel@tonic-gate  */
1327c478bd9Sstevel@tonic-gate #define	LA_SYMB_NOPLTENTER	0x0001	/* disable pltenter for this symbol */
1337c478bd9Sstevel@tonic-gate #define	LA_SYMB_NOPLTEXIT	0x0002	/* disable pltexit for this symbol */
1347c478bd9Sstevel@tonic-gate #define	LA_SYMB_STRUCTCALL	0x0004	/* this function call passes a */
1357c478bd9Sstevel@tonic-gate 					/*	structure as it's return code */
1367c478bd9Sstevel@tonic-gate #define	LA_SYMB_DLSYM		0x0008	/* this symbol bindings is due to */
1377c478bd9Sstevel@tonic-gate 					/*	a call to dlsym() */
1387c478bd9Sstevel@tonic-gate #define	LA_SYMB_ALTVALUE	0x0010	/* alternate symbol binding returned */
1397c478bd9Sstevel@tonic-gate 					/*	by la_symbind() */
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate /*
1427c478bd9Sstevel@tonic-gate  * Flags that describe the object passed to la_objsearch()
1437c478bd9Sstevel@tonic-gate  */
1447c478bd9Sstevel@tonic-gate #define	LA_SER_ORIG		0x001	/* original (needed) name */
1457c478bd9Sstevel@tonic-gate #define	LA_SER_LIBPATH		0x002	/* LD_LIBRARY_PATH entry prepended */
1467c478bd9Sstevel@tonic-gate #define	LA_SER_RUNPATH		0x004	/* runpath entry prepended */
1477c478bd9Sstevel@tonic-gate #define	LA_SER_CONFIG		0x008	/* configuration entry prepended */
1487c478bd9Sstevel@tonic-gate #define	LA_SER_DEFAULT		0x040	/* default path prepended */
1497c478bd9Sstevel@tonic-gate #define	LA_SER_SECURE		0x080	/* default (secure) path prepended */
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate #define	LA_SER_MASK		0xfff	/* mask of known flags */
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate  * Flags that describe the la_activity()
1557c478bd9Sstevel@tonic-gate  */
1567c478bd9Sstevel@tonic-gate #define	LA_ACT_CONSISTENT	0x00	/* add/deletion of objects complete */
1577c478bd9Sstevel@tonic-gate #define	LA_ACT_ADD		0x01	/* objects being added */
1587c478bd9Sstevel@tonic-gate #define	LA_ACT_DELETE		0x02	/* objects being deleted */
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 
1617c478bd9Sstevel@tonic-gate #ifndef	_KERNEL
1627c478bd9Sstevel@tonic-gate #ifndef	_ASM
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate #if defined(_LP64)
1657c478bd9Sstevel@tonic-gate typedef long	lagreg_t;
1667c478bd9Sstevel@tonic-gate #else
1677c478bd9Sstevel@tonic-gate typedef int	lagreg_t;
1687c478bd9Sstevel@tonic-gate #endif
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate struct _la_sparc_regs {
1717c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego0;
1727c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego1;
1737c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego2;
1747c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego3;
1757c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego4;
1767c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego5;
1777c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego6;
1787c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rego7;
1797c478bd9Sstevel@tonic-gate };
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate #if defined(_LP64)
1827c478bd9Sstevel@tonic-gate typedef struct _la_sparc_regs	La_sparcv9_regs;
1837c478bd9Sstevel@tonic-gate typedef struct {
1847c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rsp;
1857c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rbp;
1867c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rdi;	    /* arg1 */
1877c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rsi;	    /* arg2 */
1887c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rdx;	    /* arg3 */
1897c478bd9Sstevel@tonic-gate 	lagreg_t	lr_rcx;	    /* arg4 */
1907c478bd9Sstevel@tonic-gate 	lagreg_t	lr_r8;	    /* arg5 */
1917c478bd9Sstevel@tonic-gate 	lagreg_t	lr_r9;	    /* arg6 */
1927c478bd9Sstevel@tonic-gate } La_amd64_regs;
1937c478bd9Sstevel@tonic-gate #else
1947c478bd9Sstevel@tonic-gate typedef struct _la_sparc_regs	La_sparcv8_regs;
1957c478bd9Sstevel@tonic-gate typedef struct {
1967c478bd9Sstevel@tonic-gate 	lagreg_t	lr_esp;
1977c478bd9Sstevel@tonic-gate 	lagreg_t	lr_ebp;
1987c478bd9Sstevel@tonic-gate } La_i86_regs;
1997c478bd9Sstevel@tonic-gate #endif
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate #if	!defined(_SYS_INT_TYPES_H)
2027c478bd9Sstevel@tonic-gate #if	defined(_LP64) || defined(_I32LPx)
2037c478bd9Sstevel@tonic-gate typedef unsigned long		uintptr_t;
2047c478bd9Sstevel@tonic-gate #else
2057c478bd9Sstevel@tonic-gate typedef	unsigned int		uintptr_t;
2067c478bd9Sstevel@tonic-gate #endif
2077c478bd9Sstevel@tonic-gate #endif
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate #ifdef	__STDC__
2117c478bd9Sstevel@tonic-gate extern uint_t		la_version(uint_t);
2127c478bd9Sstevel@tonic-gate extern void		la_activity(uintptr_t *, uint_t);
2137c478bd9Sstevel@tonic-gate extern void		la_preinit(uintptr_t *);
2147c478bd9Sstevel@tonic-gate extern char		*la_objsearch(const char *, uintptr_t *, uint_t);
2157c478bd9Sstevel@tonic-gate extern uint_t		la_objopen(Link_map *, Lmid_t, uintptr_t *);
2167c478bd9Sstevel@tonic-gate extern uint_t		la_objclose(uintptr_t *);
2177c478bd9Sstevel@tonic-gate extern int		la_objfilter(uintptr_t *, const char *, uintptr_t *,
2187c478bd9Sstevel@tonic-gate 				uint_t);
2197c478bd9Sstevel@tonic-gate #if	defined(_LP64)
2207c478bd9Sstevel@tonic-gate extern uintptr_t	la_amd64_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
2217c478bd9Sstevel@tonic-gate 				uintptr_t *, La_amd64_regs *,	uint_t *,
2227c478bd9Sstevel@tonic-gate 				const char *);
2237c478bd9Sstevel@tonic-gate extern uintptr_t	la_symbind64(Elf64_Sym *, uint_t, uintptr_t *,
2247c478bd9Sstevel@tonic-gate 				uintptr_t *, uint_t *, const char *);
2257c478bd9Sstevel@tonic-gate extern uintptr_t	la_sparcv9_pltenter(Elf64_Sym *, uint_t, uintptr_t *,
2267c478bd9Sstevel@tonic-gate 				uintptr_t *, La_sparcv9_regs *,	uint_t *,
2277c478bd9Sstevel@tonic-gate 				const char *);
2287c478bd9Sstevel@tonic-gate extern uintptr_t	la_pltexit64(Elf64_Sym *, uint_t, uintptr_t *,
2297c478bd9Sstevel@tonic-gate 				uintptr_t *, uintptr_t, const char *);
2307c478bd9Sstevel@tonic-gate #else  /* !defined(_LP64) */
2317c478bd9Sstevel@tonic-gate extern uintptr_t	la_symbind32(Elf32_Sym *, uint_t, uintptr_t *,
2327c478bd9Sstevel@tonic-gate 				uintptr_t *, uint_t *);
2337c478bd9Sstevel@tonic-gate extern uintptr_t	la_sparcv8_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
2347c478bd9Sstevel@tonic-gate 				uintptr_t *, La_sparcv8_regs *, uint_t *);
2357c478bd9Sstevel@tonic-gate extern uintptr_t	la_i86_pltenter(Elf32_Sym *, uint_t, uintptr_t *,
2367c478bd9Sstevel@tonic-gate 				uintptr_t *, La_i86_regs *, uint_t *);
2377c478bd9Sstevel@tonic-gate extern uintptr_t	la_pltexit(Elf32_Sym *, uint_t, uintptr_t *,
2387c478bd9Sstevel@tonic-gate 				uintptr_t *, uintptr_t);
2397c478bd9Sstevel@tonic-gate #endif /* _LP64 */
2407c478bd9Sstevel@tonic-gate #else  /* __STDC__ */
2417c478bd9Sstevel@tonic-gate extern uint_t		la_version();
2427c478bd9Sstevel@tonic-gate extern void		la_preinit();
2437c478bd9Sstevel@tonic-gate extern uint_t		la_objopen();
2447c478bd9Sstevel@tonic-gate extern uint_t		la_objclose();
2457c478bd9Sstevel@tonic-gate extern int		la_objfilter();
2467c478bd9Sstevel@tonic-gate #if	defined(_LP64)
2477c478bd9Sstevel@tonic-gate extern uintptr_t	la_sparcv9_pltenter();
2487c478bd9Sstevel@tonic-gate extern uintptr_t	la_pltexit64();
2497c478bd9Sstevel@tonic-gate extern uintptr_t	la_symbind64();
2507c478bd9Sstevel@tonic-gate #else  /* _ILP32 */
2517c478bd9Sstevel@tonic-gate extern uintptr_t	la_sparcv8_pltenter();
2527c478bd9Sstevel@tonic-gate extern uintptr_t	la_i86_pltenter();
2537c478bd9Sstevel@tonic-gate extern uintptr_t	la_pltexit();
2547c478bd9Sstevel@tonic-gate extern uintptr_t	la_symbind32();
2557c478bd9Sstevel@tonic-gate #endif /* _LP64 */
2567c478bd9Sstevel@tonic-gate #endif /* __STDC__ */
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate #endif /* _ASM */
2607c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate #ifdef __cplusplus
2637c478bd9Sstevel@tonic-gate }
2647c478bd9Sstevel@tonic-gate #endif
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate #endif	/* _LINK_H */
267