xref: /titanic_50/usr/src/lib/libbc/inc/include/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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
23*7c478bd9Sstevel@tonic-gate 
24*7c478bd9Sstevel@tonic-gate /*
25*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1987 by Sun Microsystems, Inc.
26*7c478bd9Sstevel@tonic-gate  */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate /*
29*7c478bd9Sstevel@tonic-gate  * Link editor public definitions.
30*7c478bd9Sstevel@tonic-gate  */
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifndef _link_h
33*7c478bd9Sstevel@tonic-gate #define _link_h
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate /*
36*7c478bd9Sstevel@tonic-gate  * Structure describing logical name and requirements on an object
37*7c478bd9Sstevel@tonic-gate  * which is to be loaded dynamically.
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate struct old_link_object {
40*7c478bd9Sstevel@tonic-gate 	char	*lo_name;		/* name of object */
41*7c478bd9Sstevel@tonic-gate 	int	lo_library : 1,		/* searched for by library rules */
42*7c478bd9Sstevel@tonic-gate 		lo_unused : 31;
43*7c478bd9Sstevel@tonic-gate 	short	lo_major;		/* major version number */
44*7c478bd9Sstevel@tonic-gate 	short	lo_minor;		/* minor version number */
45*7c478bd9Sstevel@tonic-gate };
46*7c478bd9Sstevel@tonic-gate 
47*7c478bd9Sstevel@tonic-gate struct link_object {
48*7c478bd9Sstevel@tonic-gate 	long	lo_name;		/* name (often relative) */
49*7c478bd9Sstevel@tonic-gate 	int	lo_library : 1,		/* searched for by library rules */
50*7c478bd9Sstevel@tonic-gate 		lo_unused : 31;
51*7c478bd9Sstevel@tonic-gate 	short	lo_major;		/* major version number */
52*7c478bd9Sstevel@tonic-gate 	short	lo_minor;		/* minor version number */
53*7c478bd9Sstevel@tonic-gate 	long	lo_next;		/* next one (often relative) */
54*7c478bd9Sstevel@tonic-gate };
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate /*
57*7c478bd9Sstevel@tonic-gate  * Structure describing name and placement of dynamically loaded
58*7c478bd9Sstevel@tonic-gate  * objects in a process' address space.
59*7c478bd9Sstevel@tonic-gate  */
60*7c478bd9Sstevel@tonic-gate struct link_map {
61*7c478bd9Sstevel@tonic-gate 	caddr_t	lm_addr;		/* address at which object mapped */
62*7c478bd9Sstevel@tonic-gate 	char 	*lm_name;		/* full name of loaded object */
63*7c478bd9Sstevel@tonic-gate 	struct	link_map *lm_next;	/* next object in map */
64*7c478bd9Sstevel@tonic-gate 	struct	link_object *lm_lop;	/* link object that got us here */
65*7c478bd9Sstevel@tonic-gate 	caddr_t lm_lob;			/* base address for said link object */
66*7c478bd9Sstevel@tonic-gate 	int	lm_rwt : 1;		/* text is read/write */
67*7c478bd9Sstevel@tonic-gate 	struct	link_dynamic *lm_ld;	/* dynamic structure */
68*7c478bd9Sstevel@tonic-gate 	caddr_t	lm_lpd;			/* loader private data */
69*7c478bd9Sstevel@tonic-gate };
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate /*
72*7c478bd9Sstevel@tonic-gate  * Version 1 of dynamic linking information.  With the exception of
73*7c478bd9Sstevel@tonic-gate  * ld_loaded (determined at execution time) and ld_stab_hash (a special
74*7c478bd9Sstevel@tonic-gate  * case of relocation handled at execution time), the values in this
75*7c478bd9Sstevel@tonic-gate  * structure reflect offsets from the containing link_dynamic structure.
76*7c478bd9Sstevel@tonic-gate  */
77*7c478bd9Sstevel@tonic-gate struct link_dynamic_1 {
78*7c478bd9Sstevel@tonic-gate 	struct	link_map *ld_loaded;	/* list of loaded objects */
79*7c478bd9Sstevel@tonic-gate 	long	ld_need;		/* list of needed objects */
80*7c478bd9Sstevel@tonic-gate 	long	ld_rules;		/* search rules for library objects */
81*7c478bd9Sstevel@tonic-gate 	long	ld_got;			/* global offset table */
82*7c478bd9Sstevel@tonic-gate 	long	ld_plt;			/* procedure linkage table */
83*7c478bd9Sstevel@tonic-gate 	long	ld_rel;			/* relocation table */
84*7c478bd9Sstevel@tonic-gate 	long	ld_hash;		/* symbol hash table */
85*7c478bd9Sstevel@tonic-gate 	long	ld_stab;		/* symbol table itself */
86*7c478bd9Sstevel@tonic-gate 	long	(*ld_stab_hash)();	/* "pointer" to symbol hash function */
87*7c478bd9Sstevel@tonic-gate 	long	ld_buckets;		/* number of hash buckets */
88*7c478bd9Sstevel@tonic-gate 	long	ld_symbols;		/* symbol strings */
89*7c478bd9Sstevel@tonic-gate 	long	ld_symb_size;		/* size of symbol strings */
90*7c478bd9Sstevel@tonic-gate 	long	ld_text;		/* size of text area */
91*7c478bd9Sstevel@tonic-gate };
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate struct link_dynamic_2 {
94*7c478bd9Sstevel@tonic-gate 	struct	link_map *ld_loaded;	/* list of loaded objects */
95*7c478bd9Sstevel@tonic-gate 	long	ld_need;		/* list of needed objects */
96*7c478bd9Sstevel@tonic-gate 	long	ld_rules;		/* search rules for library objects */
97*7c478bd9Sstevel@tonic-gate 	long	ld_got;			/* global offset table */
98*7c478bd9Sstevel@tonic-gate 	long	ld_plt;			/* procedure linkage table */
99*7c478bd9Sstevel@tonic-gate 	long	ld_rel;			/* relocation table */
100*7c478bd9Sstevel@tonic-gate 	long	ld_hash;		/* symbol hash table */
101*7c478bd9Sstevel@tonic-gate 	long	ld_stab;		/* symbol table itself */
102*7c478bd9Sstevel@tonic-gate 	long	(*ld_stab_hash)();	/* "pointer" to symbol hash function */
103*7c478bd9Sstevel@tonic-gate 	long	ld_buckets;		/* number of hash buckets */
104*7c478bd9Sstevel@tonic-gate 	long	ld_symbols;		/* symbol strings */
105*7c478bd9Sstevel@tonic-gate 	long	ld_symb_size;		/* size of symbol strings */
106*7c478bd9Sstevel@tonic-gate 	long	ld_text;		/* size of text area */
107*7c478bd9Sstevel@tonic-gate 	long	ld_plt_sz;		/* size of procedure linkage table */
108*7c478bd9Sstevel@tonic-gate };
109*7c478bd9Sstevel@tonic-gate 
110*7c478bd9Sstevel@tonic-gate /*
111*7c478bd9Sstevel@tonic-gate  * Structure pointing to run time allocated common symbols and
112*7c478bd9Sstevel@tonic-gate  * its string.
113*7c478bd9Sstevel@tonic-gate  */
114*7c478bd9Sstevel@tonic-gate struct rtc_symb {
115*7c478bd9Sstevel@tonic-gate 	struct	nlist *rtc_sp;		/* symbol for common */
116*7c478bd9Sstevel@tonic-gate 	struct	rtc_symb *rtc_next;	/* next common */
117*7c478bd9Sstevel@tonic-gate };
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate /*
120*7c478bd9Sstevel@tonic-gate  * Debugger interface structure.
121*7c478bd9Sstevel@tonic-gate  */
122*7c478bd9Sstevel@tonic-gate struct 	ld_debug {
123*7c478bd9Sstevel@tonic-gate 	int	ldd_version;		/* version # of interface */
124*7c478bd9Sstevel@tonic-gate 	int	ldd_in_debugger;	/* a debugger is running us */
125*7c478bd9Sstevel@tonic-gate 	int	ldd_sym_loaded;		/* we loaded some symbols */
126*7c478bd9Sstevel@tonic-gate 	char    *ldd_bp_addr;		/* place for ld-generated bpt */
127*7c478bd9Sstevel@tonic-gate 	int	ldd_bp_inst;		/* instruction which was there */
128*7c478bd9Sstevel@tonic-gate 	struct rtc_symb *ldd_cp;	/* commons we built */
129*7c478bd9Sstevel@tonic-gate };
130*7c478bd9Sstevel@tonic-gate 
131*7c478bd9Sstevel@tonic-gate /*
132*7c478bd9Sstevel@tonic-gate  * Structure associated with each object which may be or which requires
133*7c478bd9Sstevel@tonic-gate  * execution-time link editing.  Used by the run-time linkage editor to
134*7c478bd9Sstevel@tonic-gate  * identify needed objects and symbol definitions and references.
135*7c478bd9Sstevel@tonic-gate  */
136*7c478bd9Sstevel@tonic-gate struct 	old_link_dynamic {
137*7c478bd9Sstevel@tonic-gate 	int	ld_version;		/* version # of this structure */
138*7c478bd9Sstevel@tonic-gate 	union {
139*7c478bd9Sstevel@tonic-gate 		struct link_dynamic_1 ld_1;
140*7c478bd9Sstevel@tonic-gate 	} ld_un;
141*7c478bd9Sstevel@tonic-gate 
142*7c478bd9Sstevel@tonic-gate 	int	in_debugging;
143*7c478bd9Sstevel@tonic-gate 	int	sym_loaded;
144*7c478bd9Sstevel@tonic-gate 	char    *bp_addr;
145*7c478bd9Sstevel@tonic-gate 	int	bp_inst;
146*7c478bd9Sstevel@tonic-gate 	struct rtc_symb *cp; 		/* pointer to an array of runtime */
147*7c478bd9Sstevel@tonic-gate 					/* allocated common symbols. */
148*7c478bd9Sstevel@tonic-gate };
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate struct	link_dynamic {
151*7c478bd9Sstevel@tonic-gate 	int	ld_version;		/* version # of this structure */
152*7c478bd9Sstevel@tonic-gate 	struct 	ld_debug *ldd;
153*7c478bd9Sstevel@tonic-gate 	union {
154*7c478bd9Sstevel@tonic-gate 		struct link_dynamic_1 *ld_1;
155*7c478bd9Sstevel@tonic-gate 		struct link_dynamic_2 *ld_2;
156*7c478bd9Sstevel@tonic-gate 	} ld_un;
157*7c478bd9Sstevel@tonic-gate };
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate #define v2 ld_un.ld_2
160*7c478bd9Sstevel@tonic-gate #define v1 ld_un.ld_1
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate /*
163*7c478bd9Sstevel@tonic-gate  * get size of relocations
164*7c478bd9Sstevel@tonic-gate  */
165*7c478bd9Sstevel@tonic-gate #define GETGOTSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_plt - ((struct old_link_dynamic *) x)->v1.ld_got : (x)->v2->ld_plt - (x)->v2->ld_got)
166*7c478bd9Sstevel@tonic-gate 
167*7c478bd9Sstevel@tonic-gate #define GETPLTSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_rel - ((struct old_link_dynamic *) x)->v1.ld_plt : (x)->v2->ld_rel - (x)->v2->ld_plt)
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate #define GETRELSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_hash - ((struct old_link_dynamic *) x)->v1.ld_rel : (x)->v2->ld_hash - (x)->v2->ld_rel)
170*7c478bd9Sstevel@tonic-gate 
171*7c478bd9Sstevel@tonic-gate #define GETHASHSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_stab - ((struct old_link_dynamic *) x)->v1.ld_hash : (x)->v2->ld_stab - (x)->v2->ld_hash)
172*7c478bd9Sstevel@tonic-gate 
173*7c478bd9Sstevel@tonic-gate #define GETSTABSZ(x) (x->ld_version < 2 ? ((struct old_link_dynamic *) x)->v1.ld_symbols - ((struct old_link_dynamic *) x)->v1.ld_stab : (x)->v2->ld_symbols - (x)->v2->ld_stab)
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate #undef v2
176*7c478bd9Sstevel@tonic-gate #undef v1
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate #endif /*!_link_h*/
179