xref: /titanic_41/usr/src/cmd/sgs/include/libld.h (revision fd9cb95cbb2f626355a60efb9d02c5f0a33c10e6)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  *	Copyright (c) 1988 AT&T
25  *	  All Rights Reserved
26  *
27  *
28  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
29  * Use is subject to license terms.
30  */
31 
32 #ifndef	_LIBLD_H
33 #define	_LIBLD_H
34 
35 #pragma ident	"%Z%%M%	%I%	%E% SMI"
36 
37 #include <stdlib.h>
38 #include <libelf.h>
39 #include <sgs.h>
40 #include <machdep.h>
41 #include <string_table.h>
42 #include <sys/avl.h>
43 #include <alist.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * Default directory search path manipulation for the link-editor.  YLDIR
51  * indicates which directory in LIBPATH is replaced by the -YL option to cc
52  * and ld.  YUDIR indicates which directory is replaced by -YU.
53  */
54 #define	YLDIR	1
55 #define	YUDIR	2
56 
57 /*
58  * Define a hash value that can never be returned from elf_hash().
59  */
60 #define	SYM_NOHASH	(~(Word)0)
61 
62 /*
63  * Define MACROs to be used for input sections to flagout
64  * when matching sections.
65  */
66 #define	ALL_SHF_ORDER	(SHF_ORDERED | SHF_LINK_ORDER)
67 #define	ALL_SHF_IGNORE	(ALL_SHF_ORDER | SHF_GROUP)
68 
69 /*
70  * Define symbol reference types for use in symbol resolution.
71  */
72 typedef enum {
73 	REF_DYN_SEEN,			/* a .so symbol has been seen */
74 	REF_DYN_NEED,			/* a .so symbol satisfies a .o symbol */
75 	REF_REL_NEED,			/* a .o symbol */
76 	REF_NUM				/* the number of symbol references */
77 } Symref;
78 
79 
80 /*
81  * GOT reference models
82  */
83 typedef enum {
84 	GOT_REF_GENERIC,	/* generic symbol reference */
85 	GOT_REF_TLSIE,		/* TLS initial exec (gnu) reference */
86 	GOT_REF_TLSLD,		/* TLS local dynamic reference */
87 	GOT_REF_TLSGD		/* TLS general dynamic reference */
88 } Gotref;
89 
90 typedef struct {
91 	Xword		gn_addend;	/* addend associated with GOT entry */
92 	Sword		gn_gotndx;	/* GOT table index */
93 	Gotref		gn_gotref;
94 } Gotndx;
95 
96 /*
97  * Got debugging structure.  The got index is defined as a signed value as we
98  * do so much mucking around with negative and positive gots on SPARC, and sign
99  * extension is necessary when building 64-bit objects.  On intel we explicitly
100  * cast this variable to an unsigned value.
101  */
102 typedef struct {
103 	Sym_desc *	gt_sym;
104 	Gotndx		gt_gndx;
105 } Gottable;
106 
107 
108 /*
109  * Output file processing structure
110  */
111 struct ofl_desc {
112 	char		*ofl_sgsid;	/* link-editor identification */
113 	const char	*ofl_name;	/* full file name */
114 	Elf		*ofl_elf;	/* elf_memory() elf descriptor */
115 	Elf		*ofl_welf;	/* ELF_C_WRITE elf descriptor */
116 	Ehdr		*ofl_ehdr;	/* elf header describing this file */
117 	Phdr		*ofl_phdr;	/* program header descriptor */
118 	Phdr		*ofl_tlsphdr;	/* TLS phdr */
119 	int		ofl_fd;		/* file descriptor */
120 	size_t		ofl_size;	/* image size */
121 	List		ofl_maps;	/* list of input mapfiles */
122 	List		ofl_segs;	/* list of segments */
123 	List		ofl_ents;	/* list of entrance descriptors */
124 	List		ofl_objs;	/* relocatable object file list */
125 	Word		ofl_objscnt;	/* 	and count */
126 	List		ofl_ars;	/* archive library list */
127 	Word		ofl_arscnt;	/* 	and count */
128 	List		ofl_sos;	/* shared object list */
129 	Word		ofl_soscnt;	/* 	and count */
130 	List		ofl_soneed;	/* list of implicitly required .so's */
131 	List		ofl_socntl;	/* list of .so control definitions */
132 	List		ofl_outrels;	/* list of output relocations */
133 	Word		ofl_outrelscnt;	/* 	and count */
134 	List		ofl_actrels;	/* list of relocations to perform */
135 	Word		ofl_actrelscnt;	/* 	and count */
136 	Word		ofl_entrelscnt;	/* no of relocations entered */
137 	List		ofl_copyrels;	/* list of copy relocations */
138 	List		ofl_ordered;	/* list of shf_ordered sections */
139 	List		ofl_syminfsyms;	/* list of interesting syms */
140 					/*	for syminfo processing */
141 	List		ofl_ismove;	/* list of .SUNW_move sections */
142 	List		ofl_mvrelisdescs; /* list of relocation input section */
143 					/* targeting to expanded area */
144 	List		ofl_parsym; 	/* list of Parsym_info */
145 	List		ofl_extrarels;	/* relocation sections which have */
146 					/*    a NULL sh_info */
147 	avl_tree_t	*ofl_groups;	/* pointer to head of Groups AVL tree */
148 	List		ofl_initarray;	/* list of init array func names */
149 	List		ofl_finiarray;	/* list of fini array func names */
150 	List		ofl_preiarray;	/* list of preinit array func names */
151 	List		ofl_rtldinfo;	/* list of rtldinfo syms */
152 	List		ofl_osgroups;	/* list of output GROUP sections */
153 	List		ofl_ostlsseg;	/* pointer to sections in TLS segment */
154 #if (defined(__i386) || defined(__amd64)) && defined(_ELF64)
155 	List		ofl_unwind;	/* list of unwind output sections */
156 	Os_desc		*ofl_unwindhdr;	/* Unwind hdr */
157 #endif
158 	avl_tree_t	ofl_symavl;	/* pointer to head of Syms AVL tree */
159 	Sym_desc	**ofl_regsyms;	/* array of potential register */
160 	Word		ofl_regsymsno;	/*    symbols and array count */
161 	Word		ofl_regsymcnt;	/* no. of output register symbols */
162 	Word		ofl_lregsymcnt;	/* no. of local register symbols */
163 	Sym_desc	*ofl_dtracesym;	/* ld -zdtrace= */
164 	Half		ofl_e_machine;	/* elf header e_machine field setting */
165 	Word		ofl_e_flags;	/* elf header e_flags field setting */
166 	Word		ofl_libver;	/* max version that libelf can handle */
167 	Word		ofl_flags;	/* various state bits, args etc. */
168 	Word		ofl_flags1;	/*	more flags */
169 	Xword		ofl_segorigin;	/* segment origin (start) */
170 	void		*ofl_entry;	/* entry point (-e and Sym_desc *) */
171 	char		*ofl_filtees;	/* shared objects we are a filter for */
172 	const char	*ofl_soname;	/* (-h option) output file name for */
173 					/*	dynamic structure */
174 	const char	*ofl_interp;	/* interpreter name used by exec() */
175 	char		*ofl_rpath;	/* run path to store in .dynamic */
176 	char		*ofl_config;	/* config path to store in .dynamic */
177 	List		ofl_ulibdirs;	/* user supplied library search list */
178 	List		ofl_dlibdirs;	/* default library search list */
179 	Word		ofl_vercnt;	/* number of versions to generate */
180 	List		ofl_verdesc;	/* list of version descriptors */
181 	size_t		ofl_verdefsz;	/* size of version definition section */
182 	size_t		ofl_verneedsz;	/* size of version needed section */
183 	Word		ofl_entercnt;	/* no. of global symbols entered */
184 	Word		ofl_globcnt;	/* no. of global symbols to output */
185 	Word		ofl_scopecnt;	/* no. of scoped symbols to output */
186 	Word		ofl_elimcnt;	/* no. of eliminated symbols */
187 	Word		ofl_locscnt;	/* no. of local symbols to output */
188 	Word		ofl_dynshdrcnt;	/* no. of output section in .dynsym */
189 	Word		ofl_shdrcnt;	/* no. of output sections */
190 	Str_tbl		*ofl_shdrsttab;	/* Str_tbl for shdr strtab */
191 	Str_tbl		*ofl_strtab;	/* Str_tbl for symtab strtab */
192 	Str_tbl		*ofl_dynstrtab;	/* Str_tbl for dymsym strtab */
193 	Gotndx		*ofl_tlsldgotndx; /* index to LD TLS_index structure */
194 	Xword		ofl_relocsz;	/* size of output relocations */
195 	Xword		ofl_relocgotsz;	/* size of .got relocations */
196 	Xword		ofl_relocpltsz;	/* size of .plt relocations */
197 	Xword		ofl_relocbsssz;	/* size of .bss (copy) relocations */
198 	Xword		ofl_relocrelsz;	/* size of .rel[a] relocations */
199 	Word		ofl_relocincnt;	/* no. of input relocations */
200 	Word		ofl_reloccnt;	/* tot number of output relocations */
201 	Word		ofl_reloccntsub; /* tot numb of output relocations to */
202 					/*	skip (-zignore) */
203 	Word		ofl_relocrelcnt; /* tot number of relative */
204 					/*	relocations */
205 	Word		ofl_gotcnt;	/* no. of .got entries */
206 	Word		ofl_pltcnt;	/* no. of .plt entries */
207 	Word		ofl_pltpad;	/* no. of .plt padd entries */
208 	Word		ofl_hashbkts;	/* no. of hash buckets required */
209 	Is_desc		*ofl_isbss;	/* .bss input section (globals) */
210 	Is_desc		*ofl_islbss;	/* .lbss input section (globals) */
211 	Is_desc		*ofl_istlsbss;	/* .tlsbss input section (globals) */
212 	Is_desc		*ofl_issunwdata1; /* .data input section */
213 					/* 	partially expanded. */
214 	Is_desc		*ofl_issunwbss;	/* .SUNW_bss input section (globals) */
215 	Os_desc		*ofl_osdynamic;	/* .dynamic output section */
216 	Os_desc		*ofl_osdynsym;	/* .dynsym output section */
217 	Os_desc		*ofl_osdynstr;	/* .dynstr output section */
218 	Os_desc		*ofl_osgot;	/* .got output section */
219 	Os_desc		*ofl_oshash;	/* .hash output section */
220 	Os_desc		*ofl_osinitarray; /* .initarray output section */
221 	Os_desc		*ofl_osfiniarray; /* .finiarray output section */
222 	Os_desc		*ofl_ospreinitarray; /* .preinitarray output section */
223 	Os_desc		*ofl_osinterp;	/* .interp output section */
224 	Os_desc		*ofl_oscap;	/* .SUNW_cap output section */
225 	Os_desc		*ofl_osplt;	/* .plt output section */
226 	Os_desc		*ofl_osmove;	/* .SUNW_move output section */
227 	Os_desc		*ofl_osrelhead;	/* first relocation section */
228 	Os_desc		*ofl_osrel;	/* .rel[a] relocation section */
229 	Os_desc		*ofl_osshstrtab; /* .shstrtab output section */
230 	Os_desc		*ofl_osstrtab;	/* .strtab output section */
231 	Os_desc		*ofl_ossymtab;	/* .symtab output section */
232 	Os_desc		*ofl_ossymshndx; /* .symtab_shndx output section */
233 	Os_desc		*ofl_osdynshndx; /* .dynsym_shndx output section */
234 	Os_desc		*ofl_osverdef;	/* .version definition output section */
235 	Os_desc		*ofl_osverneed;	/* .version needed output section */
236 	Os_desc		*ofl_osversym;	/* .version symbol ndx output section */
237 	Word		ofl_dtflags_1;	/* DT_FLAGS_1 entries */
238 	Word		ofl_dtflags;	/* DT_FLAGS entries */
239 	Os_desc		*ofl_ossyminfo;	/* .SUNW_syminfo output section */
240 	Half		ofl_sunwdata1ndx; /* section index for sunwdata1  */
241 					/* Ref. at perform_outreloc() in */
242 					/* libld/{mach}/machrel.c */
243 	Xword		*ofl_checksum;	/* DT_CHECKSUM value address */
244 	char		*ofl_depaudit;	/* dependency auditing required (-P) */
245 	char		*ofl_audit;	/* object auditing required (-p) */
246 	Alist		*ofl_symfltrs;	/* per-symbol filtees and their */
247 	Alist		*ofl_dtsfltrs;	/*	associated .dynamic/.dynstrs */
248 	Xword		ofl_hwcap_1;	/* hardware capabilities */
249 	Xword		ofl_sfcap_1;	/* software capabilities */
250 };
251 
252 #define	FLG_OF_DYNAMIC	0x00000001	/* generate dynamic output module */
253 #define	FLG_OF_STATIC	0x00000002	/* generate static output module */
254 #define	FLG_OF_EXEC	0x00000004	/* generate an executable */
255 #define	FLG_OF_RELOBJ	0x00000008	/* generate a relocatable object */
256 #define	FLG_OF_SHAROBJ	0x00000010	/* generate a shared object */
257 #define	FLG_OF_BFLAG	0x00000020	/* do no special plt building: -b */
258 #define	FLG_OF_IGNENV	0x00000040	/* ignore LD_LIBRARY_PATH: -i */
259 #define	FLG_OF_STRIP	0x00000080	/* strip output: -s */
260 #define	FLG_OF_NOWARN	0x00000100	/* disable symbol warnings: -t */
261 #define	FLG_OF_NOUNDEF	0x00000200	/* allow no undefined symbols: -zdefs */
262 #define	FLG_OF_PURETXT	0x00000400	/* allow no text relocations: -ztext  */
263 #define	FLG_OF_GENMAP	0x00000800	/* generate a memory map: -m */
264 #define	FLG_OF_DYNLIBS	0x00001000	/* dynamic input allowed: -Bdynamic */
265 #define	FLG_OF_SYMBOLIC	0x00002000	/* bind global symbols: -Bsymbolic */
266 #define	FLG_OF_ADDVERS	0x00004000	/* add version stamp: -Qy */
267 #define	FLG_OF_MEMORY	0x00008000	/* produce a memory model */
268 #define	FLG_OF_SEGORDER	0x00010000	/* segment ordering is required */
269 #define	FLG_OF_SEGSORT	0x00020000	/* segment sorting is required */
270 #define	FLG_OF_TEXTREL	0x00040000	/* text relocations have been found */
271 #define	FLG_OF_MULDEFS	0x00080000	/* multiple symbols are allowed */
272 #define	FLG_OF_TLSPHDR	0x00100000	/* a TLS program header is required */
273 #define	FLG_OF_BLDGOT	0x00200000	/* build GOT table */
274 #define	FLG_OF_VERDEF	0x00400000	/* record version definitions */
275 #define	FLG_OF_VERNEED	0x00800000	/* record version dependencies */
276 #define	FLG_OF_NOVERSEC 0x01000000	/* don't record version sections */
277 #define	FLG_OF_AUTOLCL	0x02000000	/* automatically reduce unspecified */
278 					/*	global symbols to locals */
279 #define	FLG_OF_PROCRED	0x04000000	/* process any symbol reductions by */
280 					/*	effecting the symbol table */
281 					/*	output and relocations */
282 #define	FLG_OF_SYMINFO	0x08000000	/* create a syminfo section */
283 #define	FLG_OF_AUX	0x10000000	/* ofl_filter is an auxiliary filter */
284 #define	FLG_OF_FATAL	0x20000000	/* fatal error during input */
285 #define	FLG_OF_WARN	0x40000000	/* warning during input processing. */
286 #define	FLG_OF_VERBOSE	0x80000000	/* -z verbose flag set */
287 
288 /*
289  * In the flags1 arena, establish any options that are applicable to archive
290  * extraction first, and associate a mask.  These values are recorded with any
291  * archive descriptor so that they may be reset should the archive require a
292  * rescan to try and resolve undefined symbols.
293  */
294 #define	FLG_OF1_ALLEXRT	0x00000001	/* extract all members from an */
295 					/*	archive file */
296 #define	FLG_OF1_WEAKEXT	0x00000002	/* allow archive extraction to */
297 					/*	resolve weak references */
298 #define	MSK_OF1_ARCHIVE	0x0000000f	/* archive flags mask */
299 
300 #define	FLG_OF1_ZDIRECT	0x00000010	/* -z direct flag set */
301 #define	FLG_OF1_NDIRECT	0x00000020	/* no-direct bindings specified */
302 #define	FLG_OF1_OVHWCAP	0x00000040	/* override any input hardware or */
303 #define	FLG_OF1_OVSFCAP	0x00000080	/*	software capabilities */
304 #define	FLG_OF1_RELDYN	0x00000100	/* process .dynamic in rel obj */
305 #define	FLG_OF1_REDLSYM	0x00000200	/* reduce local symbols */
306 #define	FLG_OF1_AUTOELM	0x00000400	/* automatically eliminate  */
307 					/*	unspecified global symbols */
308 #define	FLG_OF1_IGNORE	0x00000800	/* ignore unused dependencies */
309 #define	FLG_OF1_RELCNT	0x00001000	/* enable DT_RELACNT tracking */
310 #define	FLG_OF1_TEXTOFF 0x00002000	/* text relocations are ok */
311 #define	FLG_OF1_ABSEXEC	0x00004000	/* -zabsexec set */
312 #define	FLG_OF1_LAZYLD	0x00008000	/* lazy loading of objects enabled */
313 #define	FLG_OF1_GRPPRM	0x00010000	/* dependencies are to have */
314 					/*	GROUPPERM enabled */
315 #define	FLG_OF1_OVRFLW	0x00020000	/* size exceeds 32-bit limitation */
316 					/*	of 32-bit libld */
317 #define	FLG_OF1_NOPARTI	0x00040000	/* -znopartial set */
318 #define	FLG_OF1_BSSOREL	0x00080000	/* output relocation against bss */
319 					/*	section */
320 #define	FLG_OF1_TLSOREL	0x00100000	/* output relocation against .tlsbss */
321 					/*	section */
322 #define	FLG_OF1_DEMANGL	0x00200000	/* demangle C++ sym name diagnostics */
323 
324 #define	FLG_OF1_NOHDR	0x00800000	/* no elf header/phdr alignment */
325 					/*	needed */
326 #define	FLG_OF1_VADDR	0x01000000	/* vaddr was explicitly set */
327 #define	FLG_OF1_EXTRACT	0x02000000	/* archive member has been extracted */
328 #define	FLG_OF1_RESCAN	0x04000000	/* any archives should be rescanned */
329 #define	FLG_OF1_IGNPRC	0x08000000	/* ignore processing required */
330 #define	FLG_OF1_NCSTTAB	0x10000000	/* -znocompstrtab set */
331 #define	FLG_OF1_DONE	0x20000000	/* link-editor processing complete */
332 #define	FLG_OF1_NONREG	0x40000000	/* non-regular file specified as */
333 					/*	the output file */
334 #define	FLG_OF1_ALNODIR	0x80000000	/* establish NODIRECT for all */
335 					/*	exported interfaces. */
336 
337 /*
338  * Relocation (active & output) processing structure - transparent to common
339  * code.
340  */
341 struct rel_desc {
342 	Os_desc		*rel_osdesc;	/* output section reloc is against */
343 	Is_desc		*rel_isdesc;	/* input section reloc is against */
344 	const char	*rel_sname;	/* symbol name (may be "unknown") */
345 	Sym_desc	*rel_sym;	/* sym relocation is against */
346 	Sym_desc	*rel_usym;	/* strong sym if this is a weak pair */
347 	Mv_desc		*rel_move;	/* move table information */
348 	Word		rel_flags;	/* misc. flags for relocations */
349 	Word		rel_rtype;	/* relocation type */
350 	Xword		rel_roffset;	/* relocation offset */
351 	Sxword		rel_raddend;	/* addend from input relocation */
352 	Word		rel_typedata;	/* ELF_R_TYPE_DATA(info) */
353 };
354 
355 /*
356  * common flags used on the Rel_desc structure (defined in machrel.h).
357  */
358 #define	FLG_REL_GOT	0x00000001	/* relocation against GOT */
359 #define	FLG_REL_PLT	0x00000002	/* relocation against PLT */
360 #define	FLG_REL_BSS	0x00000004	/* relocation against BSS */
361 #define	FLG_REL_LOAD	0x00000008	/* section loadable */
362 #define	FLG_REL_SCNNDX	0x00000010	/* use section index for symbol ndx */
363 #define	FLG_REL_CLVAL	0x00000020	/* clear VALUE for active relocation */
364 #define	FLG_REL_ADVAL	0x00000040	/* add VALUE for output relocation, */
365 					/*	only relevent to SPARC and */
366 					/*	R_SPARC_RELATIVE */
367 #define	FLG_REL_GOTCL	0x00000080	/* clear the GOT entry.  This is */
368 					/* relevant to RELA relocations, */
369 					/* not REL (i386) relocations */
370 #define	FLG_REL_MOVETAB	0x00000100	/* Relocation against .SUNW_move */
371 					/*	adjustments required before */
372 					/*	actual relocation */
373 #define	FLG_REL_NOINFO	0x00000200	/* Relocation comes from a section */
374 					/*	with a null sh_info field */
375 #define	FLG_REL_REG	0x00000400	/* Relocation target is reg sym */
376 #define	FLG_REL_FPTR	0x00000800	/* relocation against func. desc. */
377 #define	FLG_REL_RFPTR1	0x00001000	/* Relative relocation against */
378 					/*   1st part of FD */
379 #define	FLG_REL_RFPTR2	0x00002000	/* Relative relocation against */
380 					/*   2nd part of FD */
381 #define	FLG_REL_DISP	0x00004000	/* *disp* relocation */
382 #define	FLG_REL_STLS	0x00008000	/* IE TLS reference to */
383 					/*	static TLS GOT index */
384 #define	FLG_REL_DTLS	0x00010000	/* GD TLS reference relative to */
385 					/*	dynamic TLS GOT index */
386 #define	FLG_REL_MTLS	0x00020000	/* LD TLS reference against GOT */
387 #define	FLG_REL_STTLS	0x00040000	/* LE TLS reference directly */
388 					/*	to static tls index */
389 #define	FLG_REL_TLSFIX	0x00080000	/* relocation points to TLS instr. */
390 					/*	which needs updating */
391 #define	FLG_REL_RELA	0x00100000	/* descripter captures a Rela */
392 #define	FLG_REL_GOTFIX	0x00200000	/* relocation points to GOTOP instr. */
393 					/*	which needs updating */
394 
395 /*
396  * Structure to hold a cache of Relocations.
397  */
398 struct rel_cache {
399 	Rel_desc	*rc_end;
400 	Rel_desc	*rc_free;
401 };
402 
403 /*
404  * Symbol value descriptor.  For relocatable objects, each symbols value is
405  * its offset within its associated section.  Therefore, to uniquely define
406  * each symbol within a reloctable object, record and sort the sh_offset and
407  * symbol value.  This information is used to seach for displacement
408  * relocations as part of copy relocation validation.
409  */
410 typedef struct {
411 	Addr		ssv_value;
412 	Sym_desc	*ssv_sdp;
413 } Ssv_desc;
414 
415 /*
416  * Input file processing structures.
417  */
418 struct ifl_desc {			/* input file descriptor */
419 	const char	*ifl_name;	/* full file name */
420 	const char	*ifl_soname;	/* shared object name */
421 	dev_t		ifl_stdev;	/* device id and inode number for .so */
422 	ino_t		ifl_stino;	/*	multiple inclusion checks */
423 	Ehdr		*ifl_ehdr;	/* elf header describing this file */
424 	Elf		*ifl_elf;	/* elf descriptor for this file */
425 	Sym_desc	**ifl_oldndx;	/* original symbol table indices */
426 	Sym_desc	*ifl_locs;	/* symbol desc version of locals */
427 	Ssv_desc	*ifl_sortsyms;	/* sorted list of symbols by value */
428 	Word		ifl_locscnt;	/* no. of local symbols to process */
429 	Word		ifl_symscnt;	/* total no. of symbols to process */
430 	Word		ifl_sortcnt;	/* no. of sorted symbols to process */
431 	Word		ifl_shnum;	/* number of sections in file */
432 	Word		ifl_shstrndx;	/* index to .shstrtab */
433 	Word		ifl_vercnt;	/* number of versions in file */
434 	Is_desc		**ifl_isdesc;	/* isdesc[scn ndx] = Is_desc ptr */
435 	Sdf_desc	*ifl_sdfdesc;	/* control definition */
436 	Versym		*ifl_versym;	/* version symbol table array */
437 	Ver_index	*ifl_verndx;	/* verndx[ver ndx] = Ver_index */
438 	List		ifl_verdesc;	/* version descriptor list */
439 	List		ifl_relsect;	/* relocation section list */
440 	Alist		*ifl_groups;	/* SHT_GROUP section list */
441 	Half		ifl_neededndx;	/* index to NEEDED in .dyn section */
442 	Half		ifl_flags;	/* Explicit/implicit reference */
443 };
444 
445 #define	FLG_IF_CMDLINE	0x00001		/* full filename specified from the */
446 					/*	command line (no -l) */
447 #define	FLG_IF_NEEDED	0x00002		/* shared object should be recorded */
448 #define	FLG_IF_DIRECT	0x00004		/* establish direct bindings to this */
449 					/*	object */
450 #define	FLG_IF_EXTRACT	0x00008		/* file extracted from an archive */
451 #define	FLG_IF_VERNEED	0x00010		/* version dependency information is */
452 					/*	required */
453 #define	FLG_IF_DEPREQD	0x00020		/* dependency is required to satisfy */
454 					/*	symbol references */
455 #define	FLG_IF_NEEDSTR	0x00040		/* dependency specified by -Nn */
456 					/*	flag */
457 #define	FLG_IF_IGNORE	0x00080		/* ignore unused dependencies */
458 #define	FLG_IF_NODIRECT	0x00100		/* object contains symbols that */
459 					/*	cannot be directly bound to. */
460 #define	FLG_IF_LAZYLD	0x00200		/* bindings to this object should be */
461 					/*	lazy loaded */
462 #define	FLG_IF_GRPPRM	0x00400		/* this dependency should have the */
463 					/*	DF_P1_GROUPPERM flag set */
464 #define	FLG_IF_DISPPEND 0x00800		/* displacement relocation done */
465 					/*	in the ld time. */
466 #define	FLG_IF_DISPDONE 0x01000		/* displacement relocation done */
467 					/* 	at the run time */
468 #define	FLG_IF_MAPFILE	0x02000		/* file is a mapfile */
469 #define	FLG_IF_HSTRTAB	0x04000		/* file has a string section */
470 #define	FLG_IF_FILEREF	0x08000		/* file contains a section which */
471 					/*	is included in the output */
472 					/*	allocatable image */
473 
474 struct is_desc {			/* input section descriptor */
475 	const char	*is_name;	/* the section name */
476 	const char	*is_basename;	/* original section name (without */
477 					/*	.<sect>%<func> munging */
478 	Shdr		*is_shdr;	/* the elf section header */
479 	Ifl_desc	*is_file;	/* infile desc for this section */
480 	Os_desc		*is_osdesc;	/* new output section for this */
481 					/*	input section */
482 	Elf_Data	*is_indata;	/* input sections raw data */
483 	Is_desc		*is_symshndx;	/* related SHT_SYM_SHNDX section */
484 	Word		is_scnndx;	/* original section index in file */
485 	Word		is_txtndx;	/* Index for section.  Used to decide */
486 					/*	where to insert section when */
487 					/* 	reordering sections */
488 	Word		is_ident;	/* preserved IDENT used for ordered */
489 					/*	sections. */
490 	uint_t		is_namehash;	/* hash on section name */
491 	Half		is_key;		/* Used for SHF_ORDERED */
492 	Half		is_flags;	/* Various flags */
493 };
494 
495 #define	FLG_IS_ORDERED	0x0001		/* This is a SHF_ORDERED section */
496 #define	FLG_IS_KEY	0x0002		/* This is a section pointed by */
497 					/* sh_info of a SHF_ORDERED section */
498 #define	FLG_IS_DISCARD	0x0004		/* section is to be discarded */
499 #define	FLG_IS_RELUPD	0x0008		/* symbol defined here may have moved */
500 #define	FLG_IS_SECTREF	0x0010		/* section has been referenced */
501 #define	FLG_IS_GDATADEF	0x0020		/* section contains global data sym */
502 #define	FLG_IS_EXTERNAL	0x0040		/* isp from an user file */
503 
504 
505 /*
506  * Map file and output file processing structures
507  */
508 struct os_desc {			/* Output section descriptor */
509 	const char	*os_name;	/* the section name */
510 	Elf_Scn		*os_scn;	/* the elf section descriptor */
511 	Shdr		*os_shdr;	/* the elf section header */
512 	Os_desc		*os_relosdesc;	/* the output relocation section */
513 	List		os_relisdescs;	/* reloc input section descriptors */
514 					/*	for this output section */
515 	List		os_isdescs;	/* list of input sections in output */
516 	Sort_desc	*os_sort;	/* used for sorting sections */
517 	Sg_desc		*os_sgdesc;	/* segment os_desc is placed on */
518 	Elf_Data	*os_outdata;	/* output sections raw data */
519 	List		os_comdats;	/* list of COMDAT sections present */
520 					/*	in current output section */
521 	Word		os_scnsymndx;	/* index in output symtab of section */
522 					/*	symbol for this section */
523 	Word		os_txtndx;	/* Index for section.  Used to decide */
524 					/*	where to insert section when */
525 					/* 	reordering sections */
526 	Xword		os_szoutrels;	/* size of output relocation section */
527 	uint_t		os_namehash;	/* hash on section name */
528 	uchar_t		os_flags;	/* various flags */
529 };
530 
531 #define	FLG_OS_ORDER_KEY	0x01	/* include a sort key section */
532 #define	FLG_OS_OUTREL		0x02	/* output rel against this section */
533 #define	FLG_OS_SECTREF		0x04	/* isps are not affected by -zignore */
534 
535 /*
536  * For sorting sections.
537  */
538 struct sort_desc {
539 	Is_desc		**st_order;
540 	Word		st_ordercnt;
541 	Is_desc		**st_before;
542 	Word		st_beforecnt;
543 	Is_desc		**st_after;
544 	Word		st_aftercnt;
545 };
546 
547 struct sg_desc {			/* output segment descriptor */
548 	Phdr		sg_phdr;	/* segment header for output file */
549 	const char	*sg_name;	/* segment name */
550 	Xword		sg_round;	/* data rounding required (mapfile) */
551 	Xword		sg_length;	/* maximum segment length; if 0 */
552 					/*	segment is not specified */
553 	List		sg_osdescs;	/* list of output section descriptors */
554 	List		sg_secorder;	/* List of section ordering */
555 					/*	which specify section */
556 					/*	ordering for the segment */
557 	Half		sg_flags;
558 	Sym_desc	*sg_sizesym;	/* size symbol for this segment */
559 	Xword		sg_addralign;	/* LCM of sh_addralign */
560 	Elf_Scn		*sg_fscn;	/* the SCN of the first section. */
561 };
562 
563 
564 #define	FLG_SG_VADDR	0x0001		/* vaddr segment attribute set */
565 #define	FLG_SG_PADDR	0x0002		/* paddr segment attribute set */
566 #define	FLG_SG_LENGTH	0x0004		/* length segment attribute set */
567 #define	FLG_SG_ALIGN	0x0008		/* align segment attribute set */
568 #define	FLG_SG_ROUND	0x0010		/* round segment attribute set */
569 #define	FLG_SG_FLAGS	0x0020		/* flags segment attribute set */
570 #define	FLG_SG_TYPE	0x0040		/* type segment attribute set */
571 #define	FLG_SG_ORDER	0x0080		/* has ordering been turned on for */
572 					/* 	this segment. */
573 					/*	i.e. ?[O] option in mapfile */
574 #define	FLG_SG_NOHDR	0x0100		/* don't map ELF or phdrs into */
575 					/* 	this segment */
576 #define	FLG_SG_EMPTY	0x0200		/* an empty segment specification */
577 					/*	no input sections will be */
578 					/*	associated to this section */
579 #define	FLG_SG_KEY	0x0400		/* include a key section */
580 #define	FLG_SG_DISABLED	0x0800		/* this segment is disabled */
581 #define	FLG_SG_PHREQ	0x1000		/* this segment requires a program */
582 					/* header */
583 
584 struct sec_order {
585 	const char	*sco_secname;	/* section name to be ordered */
586 	Word		sco_index;	/* ordering index for section */
587 	Half		sco_flags;
588 };
589 
590 #define	FLG_SGO_USED	0x0001		/* was ordering used? */
591 
592 struct ent_desc {			/* input section entrance criteria */
593 	List		ec_files;	/* files from which to accept */
594 					/*	sections */
595 	const char	*ec_name;	/* name to match (NULL if none) */
596 	Word		ec_type;	/* section type */
597 	Word		ec_attrmask;	/* section attribute mask (AWX) */
598 	Word		ec_attrbits;	/* sections attribute bits */
599 	Sg_desc		*ec_segment;	/* output segment to enter if matched */
600 	Word		ec_ndx;		/* index to determine where section */
601 					/*	meeting this criteria should */
602 					/*	inserted. Used for reordering */
603 					/*	of sections. */
604 	Half		ec_flags;
605 };
606 
607 #define	FLG_EC_USED	0x0001		/* entrance criteria met? */
608 
609 /*
610  *  Move supplementary structures
611  *	Sorted by symbol local/global and then by name.
612  */
613 typedef struct psym_info {
614 	Sym_desc	*psym_symd;	/* partially initialized symbol */
615 	Word 		psym_num;	/* number of move entires */
616 	Half 		psym_flag;	/* various flag */
617 	List 		psym_mvs;	/* the list of move entries */
618 } Psym_info;
619 
620 #define	FLG_PSYM_OVERLAP	0x01	/* Overlapping */
621 
622 /*
623  * One structure is allocated for a move entry.
624  */
625 typedef struct mv_itm {
626 	Xword		mv_start;	/* start position */
627 	Xword		mv_length;	/* The length of initialization */
628 	Half		mv_flag;	/* various flags */
629 	Is_desc		*mv_isp;	/* input desc. this entry is from */
630 	Move		*mv_ientry;	/* Input Move_entry */
631 	Word 		mv_oidx;	/* Output Move_entry index */
632 } Mv_itm;
633 
634 #define	FLG_MV_OUTSECT	0x01	/* Will be in move section */
635 
636 /*
637  * Define a move descripter used within relocation structures.
638  */
639 struct mv_desc {
640 	Move		*mvd_move;
641 	Sym_desc	*mvd_sym;
642 };
643 
644 struct sym_desc {
645 	List		sd_GOTndxs;	/* list of associated GOT entries */
646 	Sym		*sd_sym;	/* pointer to symbol table entry */
647 	Sym		*sd_osym;	/* copy of the original symbol entry */
648 					/* Used only for local partial */
649 	Psym_info	*sd_psyminfo;	/* If this is partial symbol, this */
650 					/* field holds the pointer to */
651 					/* parsym_info */
652 	const char	*sd_name;	/* symbols name */
653 	Ifl_desc	*sd_file;	/* file where symbol is taken */
654 	Is_desc		*sd_isc;	/* input section of symbol definition */
655 	Sym_aux		*sd_aux;	/* auxiliary global symbol info. */
656 	Word		sd_symndx;	/* index in output symbol table */
657 	Word		sd_shndx;	/* sect. index sym is associated w/ */
658 	Word		sd_flags;	/* state flags */
659 	Half		sd_flags1;	/* more symbol flags */
660 	Half		sd_ref;		/* reference definition of symbol */
661 };
662 
663 /*
664  * The auxiliary symbol descriptor contains the additional information (beyond
665  * the symbol descriptor) required to process global symbols.  These symbols are
666  * accessed via an internal symbol hash table where locality of reference is
667  * important for performance.
668  */
669 struct sym_aux {
670 	List 		sa_dfiles;	/* files where symbol is defined */
671 	Sym		sa_sym;		/* copy of symtab entry */
672 	const char	*sa_vfile;	/* first unavailable definition */
673 	Ifl_desc	*sa_bindto;	/* symbol to bind to - for translator */
674 	const char	*sa_rfile;	/* file with first symbol referenced */
675 	Word		sa_hash;	/* the pure hash value of symbol */
676 	Word		sa_PLTndx;	/* index into PLT for symbol */
677 	Word		sa_PLTGOTndx;	/* GOT entry indx for PLT indirection */
678 	Word		sa_linkndx;	/* index of associated symbol */
679 	Half		sa_symspec;	/* special symbol ids */
680 	Half		sa_overndx;	/* output file versioning index */
681 	Half		sa_dverndx;	/* dependency versioning index */
682 };
683 
684 
685 /*
686  * Nodes used to track symbols in the global AVL symbol dictionary.
687  */
688 struct sym_avlnode {
689 	avl_node_t	sav_node;	/* AVL node */
690 	Word		sav_hash;	/* symbol hash value */
691 	const char	*sav_name;	/* symbol name */
692 	Sym_desc	*sav_symdesc;	/* SymDesc entry */
693 };
694 
695 /*
696  * These are the ids for processing of `Special symbols'.  They are used
697  * to set the sym->sd_aux->sa_symspec field.
698  */
699 #define	SDAUX_ID_ETEXT	1		/* etext && _etext symbol */
700 #define	SDAUX_ID_EDATA	2		/* edata && _edata symbol */
701 #define	SDAUX_ID_END	3		/* end, _end, && _END_ symbol */
702 #define	SDAUX_ID_DYN	4		/* DYNAMIC && _DYNAMIC symbol */
703 #define	SDAUX_ID_PLT	5		/* _PROCEDURE_LINKAGE_TABLE_ symbol */
704 #define	SDAUX_ID_GOT	6		/* _GLOBAL_OFFSET_TABLE_ symbol */
705 #define	SDAUX_ID_START	7		/* START_ && _START_ symbol */
706 
707 /*
708  * Flags for sym_desc.sd_flags
709  */
710 #define	FLG_SY_MVTOCOMM	0x00000001	/* assign symbol to common (.bss) */
711 					/*	this is a result of a */
712 					/*	copy reloc against sym */
713 #define	FLG_SY_GLOBREF	0x00000002	/* a global reference has been seen */
714 #define	FLG_SY_WEAKDEF	0x00000004	/* a weak definition has been used */
715 #define	FLG_SY_CLEAN	0x00000008	/* `Sym' entry points to original */
716 					/*	input file (read-only). */
717 #define	FLG_SY_UPREQD	0x00000010	/* symbol value update is required, */
718 					/*	either it's used as an entry */
719 					/*	point or for relocation, but */
720 					/*	it must be updated even if */
721 					/*	the -s flag is in effect */
722 #define	FLG_SY_NOTAVAIL	0x00000020	/* symbol is not available to the */
723 					/*	application either because it */
724 					/*	originates from an implicitly */
725 					/* 	referenced shared object, or */
726 					/*	because it is not part of a */
727 					/*	specified version. */
728 #define	FLG_SY_REDUCED	0x00000040	/* a global is reduced to local */
729 #define	FLG_SY_VERSPROM	0x00000080	/* version definition has been */
730 					/*	promoted to output file */
731 #define	FLG_SY_PROT	0x00000100	/* stv_protected visibility seen */
732 
733 #define	FLG_SY_MAPREF	0x00000200	/* symbol reference generated by user */
734 					/*	from mapfile */
735 #define	FLG_SY_REFRSD	0x00000400	/* symbols sd_ref has been raised */
736 					/* 	due to a copy-relocs */
737 					/*	weak-strong pairing */
738 
739 #define	FLG_SY_INVALID	0x00001000	/* unwanted/erroneous symbol */
740 #define	FLG_SY_SMGOT	0x00002000	/* small got index assigned to symbol */
741 					/*	sparc only */
742 #define	FLG_SY_PARENT	0x00004000	/* symbol to be found in parent */
743 					/*    only used with direct bindings */
744 #define	FLG_SY_LAZYLD	0x00008000	/* symbol to cause lazyloading of */
745 					/*	parent object */
746 #define	FLG_SY_ISDISC	0x00010000	/* symbol is a member of a DISCARDED */
747 					/*	section (COMDAT) */
748 #define	FLG_SY_PAREXPN	0x00020000	/* partially init. symbol to be */
749 					/*	expanded */
750 #define	FLG_SY_PLTPAD	0x00040000	/* pltpadding has been allocated for */
751 					/*	this symbol */
752 #define	FLG_SY_REGSYM	0x00080000	/* REGISTER symbol (sparc only) */
753 #define	FLG_SY_SOFOUND	0x00100000	/* compared against an SO definition */
754 #define	FLG_SY_EXTERN	0x00200000	/* symbol is external, allows -zdefs */
755 					/*    error suppression */
756 #define	FLG_SY_MAPUSED	0x00400000	/* mapfile symbol used (occurred */
757 					/*    within a relocatable object) */
758 #define	FLG_SY_COMMEXP	0x00800000	/* COMMON symbol which has been */
759 					/*	allocated */
760 #define	FLG_SY_CMDREF	0x01000000	/* symbol was referenced from the */
761 					/*	command line.  (ld -u <>, */
762 					/*	ld -zrtldinfo=<>, ...) */
763 #define	FLG_SY_SPECSEC	0x02000000	/* section index is reserved value */
764 					/*	ABS, COMMON, ... */
765 #define	FLG_SY_TENTSYM	0x04000000	/* tentative symbol */
766 #define	FLG_SY_VISIBLE	0x08000000	/* symbols visibility determined */
767 #define	FLG_SY_STDFLTR	0x10000000	/* symbol is a standard filter */
768 #define	FLG_SY_AUXFLTR	0x20000000	/* symbol is an auxiliary filter */
769 
770 /*
771  * Sym_desc.sd_flags1
772  */
773 #define	FLG_SY1_GLOB	0x00000001	/* global symbol, remain global */
774 #define	FLG_SY1_PROT	0x00000002	/* global symbol, reduce to protected */
775 #define	FLG_SY1_LOCL	0x00000004	/* global symbol, reduce to local */
776 #define	FLG_SY1_DIR	0x00000008	/* global symbol, direct bindings */
777 #define	FLG_SY1_NDIR	0x00000010	/* global symbol, nondirect bindings */
778 #define	FLG_SY1_ELIM	0x00000020	/* global symbol, eliminate */
779 #define	FLG_SY1_IGNORE	0x00000040	/* symbol should be ignored */
780 
781 #define	MSK_SY1_DEFINED	(FLG_SY1_GLOB | FLG_SY1_PROT | FLG_SY1_LOCL)
782 					/* The above mask indicates that */
783 					/*    a symbol has been explicitly */
784 					/*    scoped, and therefore is not */
785 					/*    a candidate for auto-reduction */
786 
787 /*
788  * create a mask for (Sym.St_other & visibility) since the
789  * gABI does not yet define a ELF*_ST_OTHER macro.
790  */
791 #define	MSK_SYM_VISIBILITY	0x03
792 
793 /*
794  * Structure to manage the shared object definition lists.  There are two lists
795  * that use this structure:
796  *
797  *  o	ofl_soneed; maintain the list of implicitly required dependencies
798  *	(ie. shared objects needed by other shared objects).  These definitions
799  *	may include RPATH's required to locate the dependencies, and any
800  *	version requirements.
801  *
802  *  o	ofl_socntl; maintains the shared object control definitions.  These are
803  *	provided by the user (via a mapfile) and are used to indicate any
804  *	SONAME translations and verion control requirements.
805  */
806 struct	sdf_desc {
807 	const char	*sdf_name;	/* the shared objects file name */
808 	const char	*sdf_soname;	/* the shared objects SONAME */
809 	char		*sdf_rpath;	/* library search path DT_RPATH */
810 	const char	*sdf_rfile;	/* referencing file for diagnostics */
811 	Ifl_desc	*sdf_file;	/* the final input file descriptor */
812 	List		sdf_vers;	/* list of versions that are required */
813 					/*	from this object */
814 	List		sdf_verneed;	/* list of VERNEEDS to create for */
815 					/*	this object (via SPECVERS or */
816 					/*	ADDVERS) */
817 	Word		sdf_flags;
818 };
819 
820 #define	FLG_SDF_SONAME	0x02		/* An alternative SONAME is supplied */
821 #define	FLG_SDF_SELECT	0x04		/* version control selection required */
822 #define	FLG_SDF_VERIFY	0x08		/* version definition verification */
823 					/*	required */
824 #define	FLG_SDF_SPECVER	0x10		/* specify VERNEEDS */
825 #define	FLG_SDF_ADDVER	0x20		/* add VERNEED references */
826 
827 /*
828  * Structure to manage shared object version usage requirements.
829  */
830 struct	sdv_desc {
831 	const char	*sdv_name;	/* version name */
832 	const char	*sdv_ref;	/* versions reference */
833 	Word		sdv_flags;	/* flags */
834 };
835 
836 #define	FLG_SDV_MATCHED	0x01		/* VERDEF found and matched */
837 
838 /*
839  * Structures to manage versioning information.  Two versioning structures are
840  * defined:
841  *
842  *   o	a version descriptor maintains a linked list of versions and their
843  *	associated dependencies.  This is used to build the version definitions
844  *	for an image being created (see map_symbol), and to determine the
845  *	version dependency graph for any input files that are versioned.
846  *
847  *   o	a version index array contains each version of an input file that is
848  *	being processed.  It informs us which versions are available for
849  *	binding, and is used to generate any version dependency information.
850  */
851 struct	ver_desc {
852 	const char	*vd_name;	/* version name */
853 	Word		vd_hash;	/* hash value of name */
854 	Ifl_desc	*vd_file;	/* file that defined version */
855 	Half		vd_ndx;		/* coordinates with symbol index */
856 	Half		vd_flags;	/* version information */
857 	List		vd_deps;	/* version dependencies */
858 	Ver_desc	*vd_ref;	/* dependency's first reference */
859 };
860 
861 struct	ver_index {
862 	const char	*vi_name;	/* dependency version name */
863 	Half		vi_flags;	/* communicates availability */
864 	Ver_desc	*vi_desc;	/* cross reference to descriptor */
865 };
866 
867 /*
868  * Define any internal version descriptor flags ([vd|vi]_flags).  Note that the
869  * first byte is reserved for user visible flags (refer VER_FLG's in link.h).
870  */
871 #define	MSK_VER_USER	0x0f		/* mask for user visible flags */
872 
873 #define	FLG_VER_AVAIL	0x10		/* version is available for binding */
874 #define	FLG_VER_REFER	0x20		/* version has been referenced */
875 #define	FLG_VER_SELECT	0x40		/* version has been selected by user */
876 #define	FLG_VER_CYCLIC	0x80		/* a member of cyclic dependency */
877 
878 
879 /*
880  * isalist(1) descriptor - used to break an isalist string into its component
881  * options.
882  */
883 struct	isa_opt {
884 	char		*isa_name;	/* individual isa option name */
885 	size_t		isa_namesz;	/*	and associated size */
886 };
887 
888 struct	isa_desc {
889 	char		*isa_list;	/* sysinfo(SI_ISALIST) list */
890 	size_t		isa_listsz;	/*	and associated size */
891 	Isa_opt		*isa_opt;	/* table of individual isa options */
892 	size_t		isa_optno;	/*	and associated number */
893 };
894 
895 /*
896  * uname(2) descriptor - used to break a utsname structure into its component
897  * options (at least those that we're interested in).
898  */
899 struct	uts_desc {
900 	char		*uts_osname;	/* operating system name */
901 	size_t		uts_osnamesz;	/*	and associated size */
902 	char		*uts_osrel;	/* operating system release */
903 	size_t		uts_osrelsz;	/*	and associated size */
904 };
905 
906 
907 /*
908  * SHT_GROUP descriptor - used to track group sections at the global
909  * level to resolve conflicts/determine which to keep.
910  */
911 struct group_desc {
912 	const char	*gd_gsectname;	/* group section name */
913 	const char	*gd_symname;	/* symbol name */
914 	Word		*gd_data;	/* data for group section */
915 	size_t		gd_scnndx;	/* group section index */
916 	size_t		gd_cnt;		/* number of entries in group data */
917 	Word		gd_flags;
918 };
919 
920 #define	GRP_FLG_DISCARD	0x0001		/* group is to be discarded */
921 
922 /*
923  * Indexes into the ld_support_funcs[] table.
924  */
925 typedef enum {
926 	LDS_VERSION = 0,
927 	LDS_INPUT_DONE,
928 	LDS_START,
929 	LDS_ATEXIT,
930 	LDS_FILE,
931 	LDS_INP_SECTION,
932 	LDS_SECTION,
933 	LDS_NUM
934 } Support_ndx;
935 
936 
937 /*
938  * Structure to manage archive member caching.  Each archive has an archive
939  * descriptor (Ar_desc) associated with it.  This contains pointers to the
940  * archive symbol table (obtained by elf_getarsyms(3e)) and an auxiliary
941  * structure (Ar_uax[]) that parallels this symbol table.  The member element
942  * of this auxiliary table indicates whether the archive member associated with
943  * the symbol offset has already been extracted (AREXTRACTED) or partially
944  * processed (refer process_member()).
945  */
946 typedef struct ar_mem {
947 	Elf		*am_elf;	/* elf descriptor for this member */
948 	char		*am_name;	/* members name */
949 	char		*am_path;	/* path (ie. lib(foo.o)) */
950 	Sym		*am_syms;	/* start of global symbols */
951 	char		*am_strs;	/* associated string table start */
952 	Xword		am_symn;	/* no. of global symbols */
953 } Ar_mem;
954 
955 typedef struct ar_aux {
956 	Sym_desc	*au_syms;	/* internal symbol descriptor */
957 	Ar_mem		*au_mem;	/* associated member */
958 } Ar_aux;
959 
960 #define	FLG_ARMEM_PROC	(Ar_mem *)-1
961 
962 typedef struct ar_desc {
963 	const char	*ad_name;	/* archive file name */
964 	Elf		*ad_elf;	/* elf descriptor for the archive */
965 	Elf_Arsym	*ad_start;	/* archive symbol table start */
966 	Ar_aux		*ad_aux;	/* auxiliary symbol information */
967 	dev_t		ad_stdev;	/* device id and inode number for */
968 	ino_t		ad_stino;	/*	multiple inclusion checks */
969 	Word		ad_flags;	/* archive specific cmd line flags */
970 } Ar_desc;
971 
972 /*
973  * Define any archive descriptor flags.  NOTE, make sure they do not clash with
974  * any output file descriptor archive extraction flags, as these are saved in
975  * the same entry (see MSK_OF1_ARCHIVE).
976  */
977 #define	FLG_ARD_EXTRACT	0x00010000	/* archive member has been extracted */
978 
979 
980 /*
981  * Function Declarations
982  */
983 extern char		*add_string(char *, char *);
984 extern uintptr_t	create_outfile(Ofl_desc *);
985 extern Elf64_Off	_elf_getxoff(Elf_Data *);
986 extern uintptr_t	ent_setup(Ofl_desc *, Xword);
987 extern void		eprintf(Error, const char *, ...);
988 extern uintptr_t	finish_libs(Ofl_desc *);
989 extern int		ld_main(int, char **);
990 extern uintptr_t	ld_support_loadso(const char *);
991 extern void		lds_start(const char *, const Half, const char *);
992 extern void		lds_atexit(int);
993 extern void		lds_file(const char *, const Elf_Kind,
994 			    int flags, Elf *);
995 extern uintptr_t	lds_input_section(const char *, Shdr **, Word,
996 			    const char *, Elf_Scn *, Elf *, Ofl_desc *);
997 extern void		lds_input_done(void);
998 extern void		lds_section(const char *, Shdr *, Word, Elf_Data *,
999 			    Elf *);
1000 extern Listnode		*list_appendc(List *, const void *);
1001 extern Listnode		*list_insertc(List *, const void *, Listnode *);
1002 extern Listnode		*list_prependc(List *, const void *);
1003 extern Listnode		*list_where(List *, Word);
1004 extern uintptr_t	make_sections(Ofl_desc *);
1005 extern void		ofl_cleanup(Ofl_desc *);
1006 extern uintptr_t	open_outfile(Ofl_desc *);
1007 extern Ifl_desc		*process_open(const char *, size_t, int, Ofl_desc *,
1008 			    Half, Rej_desc *);
1009 extern uintptr_t	reloc_init(Ofl_desc *);
1010 extern uintptr_t	reloc_process(Ofl_desc *);
1011 extern Sdf_desc		*sdf_find(const char *, List *);
1012 extern Sdf_desc		*sdf_add(const char *, List *);
1013 extern void		sec_validate(Ofl_desc *);
1014 extern uintptr_t	sunwmove_preprocess(Ofl_desc *);
1015 extern Sym_desc		*sym_add_u(const char *, Ofl_desc *);
1016 extern Sym_desc		*sym_enter(const char *, Sym *, Word, Ifl_desc *,
1017 			    Ofl_desc *, Word, Word, Word, Half,
1018 			    avl_index_t *);
1019 extern Sym_desc		*sym_find(const char *, Word, avl_index_t *,
1020 			    Ofl_desc *);
1021 extern uintptr_t	sym_validate(Ofl_desc *);
1022 extern uintptr_t	update_outfile(Ofl_desc *);
1023 extern Ver_desc		*vers_base(Ofl_desc *);
1024 extern uintptr_t	vers_check_defs(Ofl_desc *);
1025 extern Ver_desc		*vers_desc(const char *, Word, List *);
1026 extern Ver_desc		*vers_find(const char *, Word, List *);
1027 
1028 #ifdef	__cplusplus
1029 }
1030 #endif
1031 
1032 #endif	/* _LIBLD_H */
1033