xref: /illumos-gate/usr/src/cmd/sgs/rtld/common/_a.out.h (revision 4870e0a7)
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
59aa23310Srie  * Common Development and Distribution License (the "License").
69aa23310Srie  * 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  */
2156deab07SRod Evans 
227c478bd9Sstevel@tonic-gate /*
232020b2b6SRod Evans  * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate #ifndef	_A_DOT_OUT_DOT_H
267c478bd9Sstevel@tonic-gate #define	_A_DOT_OUT_DOT_H
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #include <sys/types.h>
29*4870e0a7SRichard PALO #include <sys/null.h>
3056deab07SRod Evans #include <sys/mman.h>
317c478bd9Sstevel@tonic-gate #include <a.out.h>
327c478bd9Sstevel@tonic-gate #include <_rtld.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #define	max(a, b)	((a) < (b) ? (b) : (a))
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate typedef struct link_dynamic	Link_dynamic;
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Extern functions for a.out format file class.
447c478bd9Sstevel@tonic-gate  */
457c478bd9Sstevel@tonic-gate extern	ulong_t	aout_bndr(caddr_t);
4656deab07SRod Evans extern	int	aout_get_mmap(Lm_list *, mmapobj_result_t *);
4708278a5eSRod Evans extern	int	aout_lookup_sym(Slookup *, Sresult *, uint_t *, int *);
4856deab07SRod Evans extern	Rt_map	*aout_new_lmp(Lm_list *, Aliste, Fdesc *, Addr, size_t, void *,
492020b2b6SRod Evans 		    Rt_map *, int *);
507c478bd9Sstevel@tonic-gate extern	void	aout_plt_write(caddr_t, ulong_t);
5156deab07SRod Evans extern	int	aout_reloc(Rt_map *, uint_t, int *, APlist **);
527c478bd9Sstevel@tonic-gate extern	void	aout_rtbndr(caddr_t);
5356deab07SRod Evans extern	Fct	*aout_verify(caddr_t, size_t, Fdesc *, const char *,
5456deab07SRod Evans 		    Rej_desc *);
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * Private data for an a.out format file class.
587c478bd9Sstevel@tonic-gate  */
597c478bd9Sstevel@tonic-gate typedef struct _rt_aout_private {
607c478bd9Sstevel@tonic-gate 	struct link_dynamic	*lm_ld;		/* 4.x aout dynamic pointer */
617c478bd9Sstevel@tonic-gate 	struct ld_private	*lm_lpd;	/* private aout object area */
627c478bd9Sstevel@tonic-gate } Rt_aoutp;
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * Special defines for a.out format file class.
667c478bd9Sstevel@tonic-gate  */
677c478bd9Sstevel@tonic-gate #define	N_UNDF	0x0		/* undefined */
687c478bd9Sstevel@tonic-gate #define	N_ABS	0x2		/* absolute */
697c478bd9Sstevel@tonic-gate #define	N_COMM	0x12		/* common (internal to ld) */
707c478bd9Sstevel@tonic-gate #define	N_EXT	01		/* external bit, or'ed in */
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate /*
737c478bd9Sstevel@tonic-gate  * Format of a symbol table entry.
747c478bd9Sstevel@tonic-gate  */
757c478bd9Sstevel@tonic-gate struct	nlist {
767c478bd9Sstevel@tonic-gate 	union {
777c478bd9Sstevel@tonic-gate 		char	*n_name;		/* for use when in-core */
787c478bd9Sstevel@tonic-gate 		long	n_strx;		/* index into file string table */
797c478bd9Sstevel@tonic-gate 	} n_un;
807c478bd9Sstevel@tonic-gate 	uchar_t 	n_type;		/* type flag (N_TEXT,..)  */
817c478bd9Sstevel@tonic-gate 	char		n_other;	/* unused */
827c478bd9Sstevel@tonic-gate 	short		n_desc;		/* see <stab.h> */
837c478bd9Sstevel@tonic-gate 	ulong_t		n_value;	/* value of symbol (or sdb offset) */
847c478bd9Sstevel@tonic-gate };
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /*
877c478bd9Sstevel@tonic-gate  * Link editor public definitions.
887c478bd9Sstevel@tonic-gate  */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #ifndef _link_h
917c478bd9Sstevel@tonic-gate #define	_link_h
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Structure describing logical name and requirements on an object
957c478bd9Sstevel@tonic-gate  * which is to be loaded dynamically.
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate struct old_link_object {
987c478bd9Sstevel@tonic-gate 	char	*lo_name;		/* name of object */
997c478bd9Sstevel@tonic-gate 	int	lo_library : 1,		/* searched for by library rules */
1007c478bd9Sstevel@tonic-gate 		lo_unused : 31;
1017c478bd9Sstevel@tonic-gate 	short	lo_major;		/* major version number */
1027c478bd9Sstevel@tonic-gate 	short	lo_minor;		/* minor version number */
1037c478bd9Sstevel@tonic-gate };
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate struct link_object {
1067c478bd9Sstevel@tonic-gate 	long	lo_name;		/* name (often relative) */
1077c478bd9Sstevel@tonic-gate 	int	lo_library : 1,		/* searched for by library rules */
1087c478bd9Sstevel@tonic-gate 		lo_unused : 31;
1097c478bd9Sstevel@tonic-gate 	short	lo_major;		/* major version number */
1107c478bd9Sstevel@tonic-gate 	short	lo_minor;		/* minor version number */
1117c478bd9Sstevel@tonic-gate 	long	lo_next;		/* next one (often relative) */
1127c478bd9Sstevel@tonic-gate };
1137c478bd9Sstevel@tonic-gate typedef	struct	link_object Lnk_obj;
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * Structure describing name and placement of dynamically loaded
1177c478bd9Sstevel@tonic-gate  * objects in a process' address space.
1187c478bd9Sstevel@tonic-gate  */
1197c478bd9Sstevel@tonic-gate typedef struct a_link_map	A_link_map;
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate struct a_link_map {
1227c478bd9Sstevel@tonic-gate 	caddr_t	lm_addr;		/* address at which object mapped */
1237c478bd9Sstevel@tonic-gate 	char	*lm_name;		/* full name of loaded object */
1247c478bd9Sstevel@tonic-gate 	struct	a_link_map *lm_next;	/* next object in map */
1257c478bd9Sstevel@tonic-gate 	struct	link_object *lm_lop;	/* link object that got us here */
1267c478bd9Sstevel@tonic-gate 	caddr_t lm_lob;			/* base address for said link object */
1277c478bd9Sstevel@tonic-gate 	int	lm_rwt : 1;		/* text is read/write */
1287c478bd9Sstevel@tonic-gate 	struct	link_dynamic *lm_ld;	/* dynamic structure */
1297c478bd9Sstevel@tonic-gate 	caddr_t	lm_lpd;			/* loader private data */
1307c478bd9Sstevel@tonic-gate };
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  * Version 1 of dynamic linking information.  With the exception of
1347c478bd9Sstevel@tonic-gate  * ld_loaded (determined at execution time) and ld_stab_hash (a special
1357c478bd9Sstevel@tonic-gate  * case of relocation handled at execution time), the values in this
1367c478bd9Sstevel@tonic-gate  * structure reflect offsets from the containing link_dynamic structure.
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate struct link_dynamic_1 {
1397c478bd9Sstevel@tonic-gate 	struct	a_link_map *ld_loaded;	/* list of loaded objects */
1407c478bd9Sstevel@tonic-gate 	long	ld_need;		/* list of needed objects */
1417c478bd9Sstevel@tonic-gate 	long	ld_rules;		/* search rules for library objects */
1427c478bd9Sstevel@tonic-gate 	long	ld_got;			/* global offset table */
1437c478bd9Sstevel@tonic-gate 	long	ld_plt;			/* procedure linkage table */
1447c478bd9Sstevel@tonic-gate 	long	ld_rel;			/* relocation table */
1457c478bd9Sstevel@tonic-gate 	long	ld_hash;		/* symbol hash table */
1467c478bd9Sstevel@tonic-gate 	long	ld_stab;		/* symbol table itself */
1477c478bd9Sstevel@tonic-gate 	long	(*ld_stab_hash)();	/* "pointer" to symbol hash function */
1487c478bd9Sstevel@tonic-gate 	long	ld_buckets;		/* number of hash buckets */
1497c478bd9Sstevel@tonic-gate 	long	ld_symbols;		/* symbol strings */
1507c478bd9Sstevel@tonic-gate 	long	ld_symb_size;		/* size of symbol strings */
1517c478bd9Sstevel@tonic-gate 	long	ld_text;		/* size of text area */
1527c478bd9Sstevel@tonic-gate };
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate struct link_dynamic_2 {
1557c478bd9Sstevel@tonic-gate 	struct	a_link_map *ld_loaded;	/* list of loaded objects */
1567c478bd9Sstevel@tonic-gate 	long	ld_need;		/* list of needed objects */
1577c478bd9Sstevel@tonic-gate 	long	ld_rules;		/* search rules for library objects */
1587c478bd9Sstevel@tonic-gate 	long	ld_got;			/* global offset table */
1597c478bd9Sstevel@tonic-gate 	long	ld_plt;			/* procedure linkage table */
1607c478bd9Sstevel@tonic-gate 	long	ld_rel;			/* relocation table */
1617c478bd9Sstevel@tonic-gate 	long	ld_hash;		/* symbol hash table */
1627c478bd9Sstevel@tonic-gate 	long	ld_stab;		/* symbol table itself */
1637c478bd9Sstevel@tonic-gate 	long	(*ld_stab_hash)();	/* "pointer" to symbol hash function */
1647c478bd9Sstevel@tonic-gate 	long	ld_buckets;		/* number of hash buckets */
1657c478bd9Sstevel@tonic-gate 	long	ld_symbols;		/* symbol strings */
1667c478bd9Sstevel@tonic-gate 	long	ld_symb_size;		/* size of symbol strings */
1677c478bd9Sstevel@tonic-gate 	long	ld_text;		/* size of text area */
1687c478bd9Sstevel@tonic-gate 	long	ld_plt_sz;		/* size of procedure linkage table */
1697c478bd9Sstevel@tonic-gate };
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate /*
1727c478bd9Sstevel@tonic-gate  * Structure pointing to run time allocated common symbols and
1737c478bd9Sstevel@tonic-gate  * its string.
1747c478bd9Sstevel@tonic-gate  */
1757c478bd9Sstevel@tonic-gate struct rtc_symb {
1767c478bd9Sstevel@tonic-gate 	struct	nlist *rtc_sp;		/* symbol for common */
1777c478bd9Sstevel@tonic-gate 	struct	rtc_symb *rtc_next;	/* next common */
1787c478bd9Sstevel@tonic-gate };
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate /*
1817c478bd9Sstevel@tonic-gate  * Debugger interface structure.
1827c478bd9Sstevel@tonic-gate  */
1837c478bd9Sstevel@tonic-gate struct 	ld_debug {
1847c478bd9Sstevel@tonic-gate 	int	ldd_version;		/* version # of interface */
1857c478bd9Sstevel@tonic-gate 	int	ldd_in_debugger;	/* a debugger is running us */
1867c478bd9Sstevel@tonic-gate 	int	ldd_sym_loaded;		/* we loaded some symbols */
1877c478bd9Sstevel@tonic-gate 	char    *ldd_bp_addr;		/* place for ld-generated bpt */
1887c478bd9Sstevel@tonic-gate 	int	ldd_bp_inst;		/* instruction which was there */
1897c478bd9Sstevel@tonic-gate 	struct rtc_symb *ldd_cp;	/* commons we built */
1907c478bd9Sstevel@tonic-gate };
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate /*
1937c478bd9Sstevel@tonic-gate  * Structure associated with each object which may be or which requires
1947c478bd9Sstevel@tonic-gate  * execution-time link editing.  Used by the run-time linkage editor to
1957c478bd9Sstevel@tonic-gate  * identify needed objects and symbol definitions and references.
1967c478bd9Sstevel@tonic-gate  */
1977c478bd9Sstevel@tonic-gate struct 	old_link_dynamic {
1987c478bd9Sstevel@tonic-gate 	int	ld_version;		/* version # of this structure */
1997c478bd9Sstevel@tonic-gate 	union {
2007c478bd9Sstevel@tonic-gate 		struct link_dynamic_1 ld_1;
2017c478bd9Sstevel@tonic-gate 	} ld_un;
2027c478bd9Sstevel@tonic-gate 
2037c478bd9Sstevel@tonic-gate 	int	in_debugging;
2047c478bd9Sstevel@tonic-gate 	int	sym_loaded;
2057c478bd9Sstevel@tonic-gate 	char    *bp_addr;
2067c478bd9Sstevel@tonic-gate 	int	bp_inst;
2077c478bd9Sstevel@tonic-gate 	struct rtc_symb *cp; 		/* pointer to an array of runtime */
2087c478bd9Sstevel@tonic-gate 					/* allocated common symbols. */
2097c478bd9Sstevel@tonic-gate };
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate struct	link_dynamic {
2127c478bd9Sstevel@tonic-gate 	int	ld_version;		/* version # of this structure */
2137c478bd9Sstevel@tonic-gate 	struct 	ld_debug *ldd;
2147c478bd9Sstevel@tonic-gate 	union {
2157c478bd9Sstevel@tonic-gate 		struct link_dynamic_1 *ld_1;
2167c478bd9Sstevel@tonic-gate 		struct link_dynamic_2 *ld_2;
2177c478bd9Sstevel@tonic-gate 	} ld_un;
2187c478bd9Sstevel@tonic-gate };
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate /*
2227c478bd9Sstevel@tonic-gate  * Get size of relocations.
2237c478bd9Sstevel@tonic-gate  */
2247c478bd9Sstevel@tonic-gate #define	GETGOTSZ(x)	(x->ld_version < 2 ?				\
2257c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_plt -	\
2267c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_got :	\
2277c478bd9Sstevel@tonic-gate 			(x)->v2->ld_plt - (x)->v2->ld_got)
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate #define	GETPLTSZ(x)	(x->ld_version < 2 ?				\
2307c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_rel -	\
2317c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_plt :	\
2327c478bd9Sstevel@tonic-gate 			(x)->v2->ld_rel - (x)->v2->ld_plt)
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate #define	GETRELSZ(x)	(x->ld_version < 2 ?				\
2357c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_hash -	\
2367c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_rel :	\
2377c478bd9Sstevel@tonic-gate 			(x)->v2->ld_hash - (x)->v2->ld_rel)
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate #define	GETHASHSZ(x)	(x->ld_version < 2 ?				\
2407c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_stab -	\
2417c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_hash :	\
2427c478bd9Sstevel@tonic-gate 			(x)->v2->ld_stab - (x)->v2->ld_hash)
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate #define	GETSTABSZ(x)	(x->ld_version < 2 ?				\
2457c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_symbols -\
2467c478bd9Sstevel@tonic-gate 			((struct old_link_dynamic *)x)->v1.ld_stab :	\
2477c478bd9Sstevel@tonic-gate 			(x)->v2->ld_symbols - (x)->v2->ld_stab)
2487c478bd9Sstevel@tonic-gate 
2497c478bd9Sstevel@tonic-gate #undef v2
2507c478bd9Sstevel@tonic-gate #undef v1
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate #endif /* !_link_h */
2537c478bd9Sstevel@tonic-gate 
2547c478bd9Sstevel@tonic-gate #define	MAIN_BASE 0x2000	/* base address of a.out in 4.x system */
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate /*
2577c478bd9Sstevel@tonic-gate  * Macros for getting to linker a.out format private data.
2587c478bd9Sstevel@tonic-gate  */
2597c478bd9Sstevel@tonic-gate #define	AOUTPRV(X)	((X)->rt_priv)
2607c478bd9Sstevel@tonic-gate #define	AOUTDYN(X)	(((Rt_aoutp *)(X)->rt_priv)->lm_ld)
2617c478bd9Sstevel@tonic-gate #define	LM2LP(X)	((struct ld_private *)((Rt_aoutp *) \
2627c478bd9Sstevel@tonic-gate 				(X)->rt_priv)->lm_lpd)
2637c478bd9Sstevel@tonic-gate #define	TEXTBASE(X)	(LM2LP(X)->lp_textbase)
2647c478bd9Sstevel@tonic-gate 
26556deab07SRod Evans /*
26656deab07SRod Evans  * Most of the above macros are used from AOUT specific routines, however there
26756deab07SRod Evans  * are a couple of instances where we need to ensure the file being processed
26856deab07SRod Evans  * is AOUT before dereferencing the macro.
26956deab07SRod Evans  */
27056deab07SRod Evans #define	THIS_IS_AOUT(X)		(FCT(X) == &aout_fct)
27156deab07SRod Evans 
2727c478bd9Sstevel@tonic-gate /*
2737c478bd9Sstevel@tonic-gate  * Code collapsing macros.
2747c478bd9Sstevel@tonic-gate  */
2757c478bd9Sstevel@tonic-gate #define	v2 ld_un.ld_2
2767c478bd9Sstevel@tonic-gate #define	v1 ld_un.ld_1
2777c478bd9Sstevel@tonic-gate #define	JMPOFF(x)	(x)->v2->ld_plt
2787c478bd9Sstevel@tonic-gate #define	RELOCOFF(x)	(x)->v2->ld_rel
2797c478bd9Sstevel@tonic-gate #define	HASHOFF(x)	(x)->v2->ld_hash
2807c478bd9Sstevel@tonic-gate #define	SYMOFF(x)	(x)->v2->ld_stab
2817c478bd9Sstevel@tonic-gate #define	STROFF(x)	(x)->v2->ld_symbols
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate struct jbind {
2847c478bd9Sstevel@tonic-gate 	int	jb_inst[3];	/* need 4 instructions for jump slot */
2857c478bd9Sstevel@tonic-gate };
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate struct fshash {
2887c478bd9Sstevel@tonic-gate 	int	fssymbno;	/* ordinal symbol number */
2897c478bd9Sstevel@tonic-gate 	int	next;		/* index to the hash array pointed by fs_hash */
2907c478bd9Sstevel@tonic-gate };
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate /*
2937c478bd9Sstevel@tonic-gate  * Sparc relocation types.
2947c478bd9Sstevel@tonic-gate  */
2957c478bd9Sstevel@tonic-gate enum reloc_type
2967c478bd9Sstevel@tonic-gate {
2977c478bd9Sstevel@tonic-gate 	RELOC_8,	RELOC_16,	RELOC_32,	/* simplest relocs */
2987c478bd9Sstevel@tonic-gate 	RELOC_DISP8,	RELOC_DISP16,	RELOC_DISP32,	/* Disp's (pc-rel) */
2997c478bd9Sstevel@tonic-gate 	RELOC_WDISP30,	RELOC_WDISP22,			/* SR word disp's */
3007c478bd9Sstevel@tonic-gate 	RELOC_HI22,	RELOC_22,			/* SR 22-bit relocs */
3017c478bd9Sstevel@tonic-gate 	RELOC_13,	RELOC_LO10,			/* SR 13&10-bit reloc */
3027c478bd9Sstevel@tonic-gate 	RELOC_SFA_BASE,	RELOC_SFA_OFF13,		/* SR S.F.A. relocs */
3037c478bd9Sstevel@tonic-gate 	RELOC_BASE10,	RELOC_BASE13,	RELOC_BASE22,	/* base_relative pic */
3047c478bd9Sstevel@tonic-gate 	RELOC_PC10,	RELOC_PC22,			/* special pc-rel pic */
3057c478bd9Sstevel@tonic-gate 	RELOC_JMP_TBL,					/* jmp_tbl_rel in pic */
3067c478bd9Sstevel@tonic-gate 	RELOC_SEGOFF16,					/* Shlib off-in-seg */
3077c478bd9Sstevel@tonic-gate 	RELOC_GLOB_DAT, RELOC_JMP_SLOT, RELOC_RELATIVE	/* rtld relocs */
3087c478bd9Sstevel@tonic-gate };
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate /*
3117c478bd9Sstevel@tonic-gate  * Format of a relocation datum.
3127c478bd9Sstevel@tonic-gate  */
3137c478bd9Sstevel@tonic-gate #define	r_symbolnum 	r_index
3147c478bd9Sstevel@tonic-gate 
3157c478bd9Sstevel@tonic-gate struct	relocation_info		/* used when header.a_machtype == M_SPARC */
3167c478bd9Sstevel@tonic-gate {
3177c478bd9Sstevel@tonic-gate 	ulong_t		r_address;	/* relocation addr (offset in seg) */
3187c478bd9Sstevel@tonic-gate 	uint_t 		r_index   :24;	/* segment index or symbol index */
3197c478bd9Sstevel@tonic-gate 	uint_t 		r_extern  : 1;	/* if F, r_index==SEG#; if T, SYM idx */
3207c478bd9Sstevel@tonic-gate 	int			  : 2;	/* <unused> */
3217c478bd9Sstevel@tonic-gate 	enum reloc_type r_type    : 5;	/* type of relocation to perform */
3227c478bd9Sstevel@tonic-gate 	long		r_addend;	/* addend for relocation value */
3237c478bd9Sstevel@tonic-gate };
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate struct ld_private {
3267c478bd9Sstevel@tonic-gate 	struct	jbind *lp_plt;		/* procedure linkage table */
3277c478bd9Sstevel@tonic-gate 	struct	relocation_info *lp_rp;	/* relocation table */
3287c478bd9Sstevel@tonic-gate 	struct	fshash *lp_hash;	/* hash table */
3297c478bd9Sstevel@tonic-gate 	struct	nlist *lp_symtab;	/* symbol table */
3307c478bd9Sstevel@tonic-gate 	char	*lp_symstr;		/* symbol strings */
3317c478bd9Sstevel@tonic-gate 	caddr_t	lp_textbase;		/* base address for text addressing */
3327c478bd9Sstevel@tonic-gate 	struct	nlist *(*lp_interp)();	/* link map interpreter */
3337c478bd9Sstevel@tonic-gate 	long	lp_refcnt;		/* reference count of link map */
3347c478bd9Sstevel@tonic-gate 	struct 	dl_object *lp_dlp;	/* pointer to a dlopen object */
3357c478bd9Sstevel@tonic-gate 	caddr_t	lp_symbol_base;		/* base address for symbols */
3367c478bd9Sstevel@tonic-gate };
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 
3397c478bd9Sstevel@tonic-gate /*
3407c478bd9Sstevel@tonic-gate  * Offsets of various sections of an object file.
3417c478bd9Sstevel@tonic-gate  */
3427c478bd9Sstevel@tonic-gate #define	PAGSIZ		0x02000
3437c478bd9Sstevel@tonic-gate #define	SEGSIZ		PAGSIZ
3447c478bd9Sstevel@tonic-gate 
3457c478bd9Sstevel@tonic-gate #define	N_TXTOFF(x) \
3467c478bd9Sstevel@tonic-gate 	/* text segment */ \
3477c478bd9Sstevel@tonic-gate 	((x).a_magic == ZMAGIC ? 0 : sizeof (struct exec))
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate #define	N_SYMOFF(x) \
3507c478bd9Sstevel@tonic-gate 	/* symbol table */ \
3517c478bd9Sstevel@tonic-gate 	(N_TXTOFF(x) + (x).a_text + (x).a_data + (x).a_trsize + (x).a_drsize)
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate #define	SIZE(x) \
3547c478bd9Sstevel@tonic-gate 	/* round to segment size */ \
3557c478bd9Sstevel@tonic-gate 	(M_SROUND((x).a_text) + (x).a_data + (x).a_bss)
3567c478bd9Sstevel@tonic-gate 
3577c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
3587c478bd9Sstevel@tonic-gate }
3597c478bd9Sstevel@tonic-gate #endif
3607c478bd9Sstevel@tonic-gate 
3617c478bd9Sstevel@tonic-gate #endif	/* _A_DOT_OUT_DOT_H */
362