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