xref: /titanic_51/usr/src/cmd/sgs/libld/common/_libld.h (revision 15d9d0b528387242011cdcc6190c9e598cfe3a07)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  *	Copyright (c) 1988 AT&T
24  *	  All Rights Reserved
25  *
26  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 /*
31  * Local include file for ld library.
32  */
33 
34 #ifndef	_LIBLD_DOT_H
35 #define	_LIBLD_DOT_H
36 
37 #pragma ident	"%Z%%M%	%I%	%E% SMI"
38 
39 #include <libld.h>
40 #include <_libelf.h>
41 #include <debug.h>
42 #include <conv.h>
43 #include <msg.h>
44 
45 #ifdef	__cplusplus
46 extern "C" {
47 #endif
48 
49 /*
50  * Types of segment index.
51  */
52 typedef enum {
53 	LD_PHDR,	LD_INTERP,	LD_SUNWCAP,	LD_TEXT,
54 	LD_DATA,	LD_BSS,
55 #if	defined(__x86) && defined(_ELF64)
56 	LD_LRODATA,	LD_LDATA,
57 #endif
58 	LD_DYN,		LD_DTRACE,	 LD_SUNWBSS,	LD_TLS,
59 #if	defined(__x86) && defined(_ELF64)
60 	LD_UNWIND,
61 #endif
62 	LD_NOTE,	LD_EXTRA,
63 	LD_NUM
64 } Segment_ndx;
65 
66 /*
67  * Types of bss sections
68  */
69 typedef enum {
70 	MAKE_BSS,
71 	MAKE_LBSS,
72 	MAKE_TLS
73 } Bss_Type;
74 
75 /*
76  * Structure to manage the update of weak symbols from their associated alias.
77  */
78 typedef	struct wk_desc {
79 	Sym		*wk_symtab;	/* the .symtab entry */
80 	Sym		*wk_dynsym;	/* the .dynsym entry */
81 	Sym_desc	*wk_weak;	/* the original weak symbol */
82 	Sym_desc	*wk_alias;	/* the real symbol */
83 } Wk_desc;
84 
85 /*
86  * Structure to manage the support library interfaces.
87  */
88 typedef struct func_list {
89 	const char	*fl_obj;	/* name of support object */
90 					/*	function is from */
91 	void		(*fl_fptr)();	/* function pointer */
92 	uint_t		fl_version;	/* ld_version() level */
93 } Func_list;
94 
95 typedef	struct support_list {
96 	const char	*sup_name;	/* ld_support function name */
97 	List		sup_funcs;	/* list of support functions */
98 } Support_list;
99 
100 /*
101  * Structure to manage a sorted output relocation list.
102  *
103  *	rl_key1		->	pointer to needed ndx
104  *	rl_key2		->	pointer to symbol relocation is against
105  *	rl_key3		->	virtual offset of relocation
106  */
107 typedef struct reloc_list {
108 	Sym_desc	*rl_key2;
109 	Xword		rl_key3;
110 	Rel_desc	*rl_rsp;
111 	Half		rl_key1;
112 } Reloc_list;
113 
114 
115 typedef struct sym_s_list {
116 	Word		sl_hval;
117 	Sym_desc *	sl_sdp;
118 } Sym_s_list;
119 
120 /*
121  * ld heap management structure
122  */
123 typedef struct _ld_heap Ld_heap;
124 struct _ld_heap {
125 	Ld_heap		*lh_next;
126 	void		*lh_free;
127 	void		*lh_end;
128 };
129 
130 #define	HEAPBLOCK	0x68000		/* default allocation block size */
131 #define	HEAPALIGN	0x8		/* heap blocks alignment requirement */
132 
133 /*
134  * Dynamic per-symbol filtee string table descriptor.  This associates filtee
135  * strings that will be created in the .dynstr, with .dynamic entries.
136  */
137 typedef struct {
138 	char		*dft_str;	/* dynstr string */
139 	Word		dft_flag;	/* auxiliary/filtee type */
140 	Half		dft_ndx;	/* eventual ndx into .dynamic */
141 } Dfltr_desc;
142 
143 /*
144  * Per-symbol filtee descriptor.  This associates symbol definitions with
145  * their filtees.
146  */
147 typedef struct {
148 	Sym_desc	*sft_sdp;	/* symbol descriptor */
149 	Aliste		sft_idx;	/* index into dtstr descriptor */
150 } Sfltr_desc;
151 
152 /*
153  * Define Alist initialization sizes.
154  */
155 #define	AL_CNT_IFL_GROUPS	20	/* ifl_groups initial alist count */
156 #define	AL_CNT_OFL_DTSFLTRS	4	/* ofl_dtsfltrs initial alist count */
157 #define	AL_CNT_OFL_SYMFLTRS	20	/* ofl_symfltrs initial alist count */
158 #define	AL_CNT_OS_MSTRISDESCS	10	/* os_mstrisdescs */
159 #define	AL_CNT_SG_OSDESC	40	/* sg_osdescs initial alist count */
160 #define	AL_CNT_SG_SECORDER	40	/* sg_secorder initial alist count */
161 #define	AL_CNT_STRMRGREL	500	/* ld_make_strmerge() reloc alist cnt */
162 #define	AL_CNT_STRMRGSYM	20	/* ld_make_strmerge() sym alist cnt */
163 
164 /*
165  * Return codes for {tls|got}_fixups() routines
166  */
167 typedef enum {
168 	FIX_ERROR,	/* fatal error - time to punt */
169 	FIX_DONE,	/* relocation done - no further processing required */
170 	FIX_RELOC	/* do_reloc() relocation processing required */
171 } Fixupret;
172 
173 #ifndef	FILENAME_MAX
174 #define	FILENAME_MAX	BUFSIZ		/* maximum length of a path name */
175 #endif
176 
177 /*
178  * We pad the end of the .dynstr section with a block of DYNSTR_EXTRA_PAD
179  * bytes, and we insert DYNAMIC_EXTRA_ELTS unused items into the
180  * .dynamic section (with value DT_NULL). This provides the resources needed
181  * to add and/or alter string items in the .dynamic section, such as runpath.
182  */
183 #define	DYNSTR_EXTRA_PAD	512
184 #define	DYNAMIC_EXTRA_ELTS	10
185 
186 /*
187  * Relocation buckets are sized based on the number of input relocations and
188  * the following constants.
189  */
190 #define	REL_HAIDESCNO	1000		/* high water mark active buckets */
191 #define	REL_LAIDESCNO	50		/* low water mark active buckets */
192 #define	REL_HOIDESCNO	500		/* high water mark output buckets */
193 #define	REL_LOIDESCNO	10		/* low water mark output buckets */
194 
195 extern char		*Plibpath;
196 extern char		*Llibdir;
197 extern char		*Ulibdir;
198 extern Ld_heap		*ld_heap;
199 extern List		lib_support;
200 extern int		demangle_flag;
201 extern const Msg	reject[];
202 extern int		Verbose;
203 extern const int	ldynsym_symtype[STT_NUM];
204 extern const int	dynsymsort_symtype[STT_NUM];
205 
206 /*
207  * Given a symbol of a type that is allowed within a .SUNW_dynsymsort or
208  * .SUNW_dyntlssort section, examine the symbol attributes to determine
209  * if this particular symbol should be included or not.
210  *
211  * entry:
212  *	The symbol must have an allowed type: Either a type verified by
213  *	dynsymsort_symtype[] or STT_TLS.
214  *
215  *	_sdp - Pointer to symbol descriptor
216  *	_sym - Pointer to symbol referenced by _sdp.
217  *
218  *	_sym is derivable from _sdp: _sdp->sd_sym
219  *	However, most callers assign it to a local variable for efficiency,
220  *	and this macro allows such a variable to be used within. If you
221  *	don't have such a variable, supply _sdp->sd_sym.
222  *
223  * The tests used require some explanation:
224  *
225  *	(_sdp->sd_flags & FLG_SY_DYNSORT)
226  *		Some special symbols are kept even if they don't meet the
227  *		usual requirements. These symbols have the FLG_SY_DYNSORT
228  *		bit set. If this bit isn't set then we look at the other
229  *		attributes.
230  *
231  *	((_sdp->sd_ref != REF_DYN_NEED) || (_sdp->sd_flags & FLG_SY_MVTOCOMM))
232  *		We do not want to include symbols that are not defined within
233  *		the object we are creating. REF_DYN_NEED corresponds to those
234  *		UNDEF items. However, if the symbol is the target of a copy
235  *		relocation, then it effectively becomes defined within the
236  *		object after all. FLG_SY_MVTOCOMM indicates a copy relocation,
237  *		and prevents us from culling those exceptions.
238  *
239  *	(_sym->st_size != 0)
240  *		Symbols with 0 length are labels injected by the compilers
241  *		or the linker for purposes of code generation, and do
242  *		not directly correspond to actual code. In fact, most of the
243  *		symbols we mark with FLG_SY_DYNSORT need that flag set because
244  *		they have size 0. This size test filters out the others.
245  *
246  *	!(_sdp->sd_flags & FLG_SY_NODYNSORT)
247  *		Some symbols are not kept, even though they do meet the usual
248  *		requirements. These symbols have FLG_SY_NODYNSORT set.
249  *		For example, if there are weak and non-weak versions of a given
250  *		symbol, we only want to keep one of them. So, we set
251  *		FLG_SY_NODYNSORT on the one we don't want.
252  */
253 #define	DYNSORT_TEST_ATTR(_sdp, _sym) \
254 	((_sdp->sd_flags & FLG_SY_DYNSORT) || \
255 	(((_sdp->sd_ref != REF_DYN_NEED) || \
256 		(_sdp->sd_flags & FLG_SY_MVTOCOMM)) && \
257 	(_sym->st_size != 0) && \
258 	!(_sdp->sd_flags & FLG_SY_NODYNSORT)))
259 
260 /*
261  * We use output section descriptor counters to add up the number of
262  * symbol indexes to put in the .SUNW_dynsort and .SUNW_dyntlssort sections.
263  * Non-TLS symbols are counted by ofl->ofl_dynsymsortcnt, while TLS symbols are
264  * counted by ofl->ofl_dyntlssortcnt. This computation is done inline in
265  * several places. The DYNSORT_COUNT macro allows us to generate this from
266  * a single description.
267  *
268  * entry:
269  *	_sdp, _sym - As per DYNSORT_TEST_ATTR
270  *	_type - Type of symbol (STT_*)
271  *	_inc_or_dec_op - Either ++, or --. This specifies the operation
272  *		to be applied to the counter, and determines whether we
273  *		are adding, or removing, a symbol from .SUNW_dynsymsort.
274  *
275  * Note that _type is derivable from _sym: ELF_ST_TYPE(_sdp->sd_sym->st_info).
276  * Most callers already have it in a variable, so this allows us to use that
277  * variable. If you don't have such a variable, use ELF_ST_TYPE() as shown.
278  */
279 #define	DYNSORT_COUNT(_sdp, _sym, _type, _inc_or_dec_op) \
280 { \
281 	Word *_cnt_var; \
282 	\
283 	if (dynsymsort_symtype[_type]) {	/* Non-TLS counter */ \
284 		_cnt_var = &ofl->ofl_dynsymsortcnt; \
285 	} else if ((_type) == STT_TLS) {	/* TLS counter */ \
286 		_cnt_var = &ofl->ofl_dyntlssortcnt; \
287 	} else {				/* Don't count this symbol */ \
288 		_cnt_var = NULL; \
289 	} \
290 	if ((_cnt_var != NULL) && DYNSORT_TEST_ATTR(_sdp, _sym)) \
291 		(*_cnt_var)_inc_or_dec_op;	/* Increment/Decrement */ \
292 }
293 
294 
295 /*
296  * For backward compatibility provide a /dev/zero file descriptor.
297  */
298 extern int		dz_fd;
299 
300 /*
301  * Local functions.
302  */
303 extern char		*add_string(char *, char *);
304 extern const char	*demangle(const char *);
305 
306 extern void		lds_atexit(Ofl_desc *, int);
307 
308 extern void		libld_free(void *);
309 extern void		*libld_malloc(size_t);
310 extern void		*libld_realloc(void *, size_t);
311 
312 extern Listnode		*list_appendc(List *, const void *);
313 extern Listnode		*list_insertc(List *, const void *, Listnode *);
314 extern Listnode		*list_prependc(List *, const void *);
315 extern Listnode		*list_where(List *, Word num);
316 
317 extern Sdf_desc		*sdf_add(const char *, List *);
318 extern Sdf_desc		*sdf_find(const char *, List *);
319 
320 #if	defined(_ELF64)
321 
322 #define	ld_add_actrel		ld64_add_actrel
323 #define	ld_add_libdir		ld64_add_libdir
324 #define	ld_add_outrel		ld64_add_outrel
325 #define	ld_adj_movereloc	ld64_adj_movereloc
326 #if	defined(__sparc)
327 #define	ld_allocate_got		ld64_allocate_got
328 #endif
329 #define	ld_am_I_partial		ld64_am_I_partial
330 #define	ld_append_isp		ld64_append_isp
331 #define	ld_ar_member		ld64_ar_member
332 #define	ld_ar_setup		ld64_ar_setup
333 #define	ld_assign_got		ld64_assign_got
334 #define	ld_assign_got_ndx	ld64_assign_got_ndx
335 #define	ld_assign_got_TLS	ld64_assign_got_TLS
336 #define	ld_assign_plt_ndx	ld64_assign_plt_ndx
337 #define	ld_byteswap_Xword	ld64_byteswap_Xword
338 #define	ld_calc_got_offset	ld64_calc_got_offset
339 #define	ld_calc_plt_addr	ld64_calc_plt_addr
340 #define	ld_disp_errmsg		ld64_disp_errmsg
341 #define	ld_do_activerelocs	ld64_do_activerelocs
342 #define	ld_ent_check		ld64_ent_check
343 #define	ld_exit			ld64_exit
344 #define	ld_fillin_gotplt	ld64_fillin_gotplt
345 #define	ld_find_gotndx		ld64_find_gotndx
346 #define	ld_find_library		ld64_find_library
347 #define	ld_finish_libs		ld64_finish_libs
348 #define	ld_get_group		ld64_get_group
349 #define	ld_lib_setup		ld64_lib_setup
350 #define	ld_init			ld64_init
351 #define	ld_init_rel		ld64_init_rel
352 #define	ld_is_regsym		ld64_is_regsym
353 #define	ld_lcm			ld64_lcm
354 #define	ld_mach_update_odynamic	ld64_mach_update_odynamic
355 #define	ld_mach_eflags		ld64_mach_eflags
356 #define	ld_mach_make_dynamic	ld64_mach_make_dynamic
357 #define	ld_mach_sym_typecheck	ld64_mach_sym_typecheck
358 #define	ld_make_bss		ld64_make_bss
359 #define	ld_make_data		ld64_make_data
360 #define	ld_make_got		ld64_make_got
361 #define	ld_make_sunwbss		ld64_make_sunwbss
362 #define	ld_make_sunwdata	ld64_make_sunwdata
363 #define	ld_make_sunwmove	ld64_make_sunmove
364 #define	ld_make_text		ld64_make_text
365 #define	ld_map_out		ld64_map_out
366 #define	ld_map_parse		ld64_map_parse
367 #define	ld_open_outfile		ld64_open_outfile
368 #define	ld_perform_outreloc	ld64_perform_outreloc
369 #define	ld_place_section	ld64_place_section
370 #define	ld_process_archive	ld64_process_archive
371 #define	ld_process_files	ld64_process_files
372 #define	ld_process_flags	ld64_process_flags
373 #define	ld_process_ifl		ld64_process_ifl
374 #define	ld_process_ordered	ld64_process_ordered
375 #define	ld_process_sym_reloc	ld64_process_sym_reloc
376 #define	ld_reloc_local		ld64_reloc_local
377 #define	ld_reloc_GOT_relative	ld64_reloc_GOT_relative
378 #define	ld_reloc_GOTOP		ld64_reloc_GOTOP
379 #define	ld_reloc_plt		ld64_reloc_plt
380 #define	ld_reloc_register	ld64_reloc_register
381 #define	ld_reloc_remain_entry	ld64_reloc_remain_entry
382 #define	ld_reloc_TLS		ld64_reloc_TLS
383 #define	ld_reloc_targval_get	ld64_reloc_targval_get
384 #define	ld_reloc_targval_set	ld64_reloc_targval_set
385 #define	ld_reg_check		ld64_reg_check
386 #define	ld_reg_enter		ld64_reg_enter
387 #define	ld_reg_find		ld64_reg_find
388 #define	ld_sec_validate		ld64_sec_validate
389 #define	ld_section_reld_name	ld64_section_reld_name
390 #define	ld_sort_ordered		ld64_sort_ordered
391 #define	ld_sort_seg_list	ld64_sort_seg_list
392 #define	ld_sunwmove_preprocess	ld64_sunwmove_preprocess
393 #define	ld_sup_atexit		ld64_sup_atexit
394 #define	ld_sup_open		ld64_sup_open
395 #define	ld_sup_file		ld64_sup_file
396 #define	ld_sup_loadso		ld64_sup_loadso
397 #define	ld_sup_input_done	ld64_sup_input_done
398 #define	ld_sup_input_section	ld64_sup_input_section
399 #define	ld_sup_section		ld64_sup_section
400 #define	ld_sup_start		ld64_sup_start
401 #define	ld_sym_add_u		ld64_sym_add_u
402 #define	ld_sym_adjust_vis	ld64_sym_adjust_vis
403 #define	ld_sym_avl_comp		ld64_sym_avl_comp
404 #define	ld_sym_copy		ld64_sym_copy
405 #define	ld_sym_enter		ld64_sym_enter
406 #define	ld_sym_find		ld64_sym_find
407 #define	ld_sym_nodirect		ld64_sym_nodirect
408 #define	ld_sym_process		ld64_sym_process
409 #define	ld_sym_resolve		ld64_sym_resolve
410 #define	ld_sym_spec		ld64_sym_spec
411 #define	ld_vers_base		ld64_vers_base
412 #define	ld_vers_check_defs	ld64_vers_check_defs
413 #define	ld_vers_check_need	ld64_vers_check_need
414 #define	ld_vers_def_process	ld64_vers_def_process
415 #define	ld_vers_desc		ld64_vers_desc
416 #define	ld_vers_find		ld64_vers_find
417 #define	ld_vers_need_process	ld64_vers_need_process
418 #define	ld_vers_promote		ld64_vers_promote
419 #define	ld_vers_sym_process	ld64_vers_sym_process
420 #define	ld_vers_verify		ld64_vers_verify
421 
422 #else
423 
424 #define	ld_add_actrel		ld32_add_actrel
425 #define	ld_add_libdir		ld32_add_libdir
426 #define	ld_add_outrel		ld32_add_outrel
427 #define	ld_adj_movereloc	ld32_adj_movereloc
428 #if	defined(__sparc)
429 #define	ld_allocate_got		ld32_allocate_got
430 #endif
431 #define	ld_am_I_partial		ld32_am_I_partial
432 #define	ld_append_isp		ld32_append_isp
433 #define	ld_ar_member		ld32_ar_member
434 #define	ld_ar_setup		ld32_ar_setup
435 #define	ld_assign_got		ld32_assign_got
436 #define	ld_assign_got_ndx	ld32_assign_got_ndx
437 #define	ld_assign_got_TLS	ld32_assign_got_TLS
438 #define	ld_assign_plt_ndx	ld32_assign_plt_ndx
439 #define	ld_byteswap_Xword	ld32_byteswap_Xword
440 #define	ld_calc_got_offset	ld32_calc_got_offset
441 #define	ld_calc_plt_addr	ld32_calc_plt_addr
442 #define	ld_disp_errmsg		ld32_disp_errmsg
443 #define	ld_do_activerelocs	ld32_do_activerelocs
444 #define	ld_ent_check		ld32_ent_check
445 #define	ld_exit			ld32_exit
446 #define	ld_fillin_gotplt	ld32_fillin_gotplt
447 #define	ld_find_gotndx		ld32_find_gotndx
448 #define	ld_find_library		ld32_find_library
449 #define	ld_finish_libs		ld32_finish_libs
450 #define	ld_section_reld_name	ld32_section_reld_name
451 #define	ld_get_group		ld32_get_group
452 #define	ld_lib_setup		ld32_lib_setup
453 #define	ld_init			ld32_init
454 #define	ld_init_rel		ld32_init_rel
455 #define	ld_is_regsym		ld32_is_regsym
456 #define	ld_lcm			ld32_lcm
457 #define	ld_mach_update_odynamic	ld32_mach_update_odynamic
458 #define	ld_mach_eflags		ld32_mach_eflags
459 #define	ld_mach_make_dynamic	ld32_mach_make_dynamic
460 #define	ld_mach_sym_typecheck	ld32_mach_sym_typecheck
461 #define	ld_make_bss		ld32_make_bss
462 #define	ld_make_data		ld32_make_data
463 #define	ld_make_got		ld32_make_got
464 #define	ld_make_sunwbss		ld32_make_sunwbss
465 #define	ld_make_sunwdata	ld32_make_sunwdata
466 #define	ld_make_sunwmove	ld32_make_sunmove
467 #define	ld_make_text		ld32_make_text
468 #define	ld_map_out		ld32_map_out
469 #define	ld_map_parse		ld32_map_parse
470 #define	ld_open_outfile		ld32_open_outfile
471 #define	ld_perform_outreloc	ld32_perform_outreloc
472 #define	ld_place_section	ld32_place_section
473 #define	ld_process_archive	ld32_process_archive
474 #define	ld_process_files	ld32_process_files
475 #define	ld_process_flags	ld32_process_flags
476 #define	ld_process_ifl		ld32_process_ifl
477 #define	ld_process_ordered	ld32_process_ordered
478 #define	ld_process_sym_reloc	ld32_process_sym_reloc
479 #define	ld_reloc_local		ld32_reloc_local
480 #define	ld_reloc_GOT_relative	ld32_reloc_GOT_relative
481 #define	ld_reloc_GOTOP		ld32_reloc_GOTOP
482 #define	ld_reloc_plt		ld32_reloc_plt
483 #define	ld_reloc_register	ld32_reloc_register
484 #define	ld_reloc_remain_entry	ld32_reloc_remain_entry
485 #define	ld_reloc_TLS		ld32_reloc_TLS
486 #define	ld_reloc_targval_get	ld32_reloc_targval_get
487 #define	ld_reloc_targval_set	ld32_reloc_targval_set
488 #define	ld_reg_check		ld32_reg_check
489 #define	ld_reg_enter		ld32_reg_enter
490 #define	ld_reg_find		ld32_reg_find
491 #define	ld_sec_validate		ld32_sec_validate
492 #define	ld_sort_ordered		ld32_sort_ordered
493 #define	ld_sort_seg_list	ld32_sort_seg_list
494 #define	ld_sunwmove_preprocess	ld32_sunwmove_preprocess
495 #define	ld_sup_atexit		ld32_sup_atexit
496 #define	ld_sup_open		ld32_sup_open
497 #define	ld_sup_file		ld32_sup_file
498 #define	ld_sup_loadso		ld32_sup_loadso
499 #define	ld_sup_input_done	ld32_sup_input_done
500 #define	ld_sup_input_section	ld32_sup_input_section
501 #define	ld_sup_section		ld32_sup_section
502 #define	ld_sup_start		ld32_sup_start
503 #define	ld_sym_add_u		ld32_sym_add_u
504 #define	ld_sym_adjust_vis	ld32_sym_adjust_vis
505 #define	ld_sym_avl_comp		ld32_sym_avl_comp
506 #define	ld_sym_copy		ld32_sym_copy
507 #define	ld_sym_enter		ld32_sym_enter
508 #define	ld_sym_find		ld32_sym_find
509 #define	ld_sym_nodirect		ld32_sym_nodirect
510 #define	ld_sym_process		ld32_sym_process
511 #define	ld_sym_resolve		ld32_sym_resolve
512 #define	ld_sym_spec		ld32_sym_spec
513 #define	ld_vers_base		ld32_vers_base
514 #define	ld_vers_check_defs	ld32_vers_check_defs
515 #define	ld_vers_check_need	ld32_vers_check_need
516 #define	ld_vers_def_process	ld32_vers_def_process
517 #define	ld_vers_desc		ld32_vers_desc
518 #define	ld_vers_find		ld32_vers_find
519 #define	ld_vers_need_process	ld32_vers_need_process
520 #define	ld_vers_promote		ld32_vers_promote
521 #define	ld_vers_sym_process	ld32_vers_sym_process
522 #define	ld_vers_verify		ld32_vers_verify
523 
524 #endif
525 
526 extern uintptr_t	dbg_setup(const char *, Dbg_desc *, const char **, int);
527 
528 extern uintptr_t	ld_add_actrel(Word, Rel_desc *, Ofl_desc *);
529 extern uintptr_t	ld_add_libdir(Ofl_desc *, const char *);
530 extern uintptr_t	ld_add_outrel(Word, Rel_desc *, Ofl_desc *);
531 extern void 		ld_adj_movereloc(Ofl_desc *, Rel_desc *);
532 extern Sym_desc * 	ld_am_I_partial(Rel_desc *, Xword);
533 extern int		ld_append_isp(Ofl_desc *, Os_desc *, Is_desc *, int);
534 extern void		ld_ar_member(Ar_desc *, Elf_Arsym *, Ar_aux *,
535 			    Ar_mem *);
536 extern Ar_desc		*ld_ar_setup(const char *, Elf *, Ofl_desc *);
537 #if	defined(__sparc)
538 extern uintptr_t	ld_allocate_got(Ofl_desc *);
539 #endif
540 extern uintptr_t	ld_assign_got(Ofl_desc *, Sym_desc *);
541 extern uintptr_t	ld_assign_got_ndx(List *, Gotndx *, Gotref, Ofl_desc *,
542 			    Rel_desc *, Sym_desc *);
543 extern uintptr_t	ld_assign_got_TLS(Boolean, Rel_desc *, Ofl_desc *,
544 			    Sym_desc *, Gotndx *, Gotref, Word, Word,
545 			    Word, Word);
546 extern void		ld_assign_plt_ndx(Sym_desc *, Ofl_desc *);
547 
548 extern Xword		ld_byteswap_Xword(Xword);
549 extern Xword		ld_calc_got_offset(Rel_desc *, Ofl_desc *);
550 extern Xword		ld_calc_plt_addr(Sym_desc *, Ofl_desc *);
551 
552 extern void		ld_disp_errmsg(const char *, Rel_desc *, Ofl_desc *);
553 extern uintptr_t	ld_do_activerelocs(Ofl_desc *);
554 
555 extern void		ld_ent_check(Ofl_desc *);
556 extern int		ld_exit(Ofl_desc *);
557 
558 extern uintptr_t	ld_fillin_gotplt(Ofl_desc *);
559 extern Gotndx *		ld_find_gotndx(List *, Gotref, Ofl_desc *, Rel_desc *);
560 extern uintptr_t	ld_find_library(const char *, Ofl_desc *);
561 extern uintptr_t	ld_finish_libs(Ofl_desc *);
562 
563 extern const char	*ld_section_reld_name(Sym_desc *, Is_desc *);
564 
565 extern Group_desc	*ld_get_group(Ofl_desc *, Is_desc *);
566 
567 extern uintptr_t	ld_lib_setup(Ofl_desc *);
568 
569 extern void		ld_init(Ofl_desc *);
570 extern Word		ld_init_rel(Rel_desc *, void *);
571 extern const char	*ld_is_regsym(Ofl_desc *, Ifl_desc *, Sym *,
572 			    const char *, int, Word, const char *, Word *);
573 
574 extern Xword		ld_lcm(Xword, Xword);
575 
576 extern void		ld_mach_update_odynamic(Ofl_desc *, Dyn **);
577 extern void		ld_mach_eflags(Ehdr *, Ofl_desc *);
578 extern void		ld_mach_make_dynamic(Ofl_desc *, size_t *);
579 extern int		ld_mach_sym_typecheck(Sym_desc *, Sym *, Ifl_desc *,
580 			    Ofl_desc *);
581 extern uintptr_t	ld_make_bss(Ofl_desc *, Xword, Xword, Bss_Type);
582 extern Is_desc		*ld_make_data(Ofl_desc *, size_t);
583 extern uintptr_t	ld_make_got(Ofl_desc *);
584 extern uintptr_t	ld_make_sunwbss(Ofl_desc *, size_t, Xword);
585 extern uintptr_t	ld_make_sunwdata(Ofl_desc *, size_t, Xword);
586 extern uintptr_t	ld_make_sunwmove(Ofl_desc *, int);
587 extern Is_desc		*ld_make_text(Ofl_desc *, size_t);
588 extern void		ld_map_out(Ofl_desc *);
589 extern uintptr_t	ld_map_parse(const char *, Ofl_desc *);
590 
591 extern uintptr_t	ld_open_outfile(Ofl_desc *);
592 
593 extern uintptr_t	ld_perform_outreloc(Rel_desc *, Ofl_desc *);
594 extern Os_desc *	ld_place_section(Ofl_desc *, Is_desc *, int, Word);
595 extern uintptr_t	ld_process_archive(const char *, int, Ar_desc *,
596 			    Ofl_desc *);
597 extern uintptr_t	ld_process_files(Ofl_desc *, int, char **);
598 extern uintptr_t	ld_process_flags(Ofl_desc *, int, char **);
599 extern Ifl_desc		*ld_process_ifl(const char *, const char *, int, Elf *,
600 			    Word, Ofl_desc *, Rej_desc *);
601 extern uintptr_t	ld_process_ordered(Ifl_desc *, Ofl_desc *, Word, Word);
602 extern uintptr_t	ld_process_sym_reloc(Ofl_desc *, Rel_desc *, Rel *,
603 			    Is_desc *, const char *);
604 
605 extern uintptr_t	ld_reloc_local(Rel_desc *, Ofl_desc *);
606 extern uintptr_t	ld_reloc_GOT_relative(Boolean, Rel_desc *, Ofl_desc *);
607 extern uintptr_t	ld_reloc_GOTOP(Boolean, Rel_desc *, Ofl_desc *);
608 extern uintptr_t	ld_reloc_plt(Rel_desc *, Ofl_desc *);
609 extern uintptr_t	ld_reloc_register(Rel_desc *, Is_desc *, Ofl_desc *);
610 extern void		ld_reloc_remain_entry(Rel_desc *, Os_desc *,
611 			    Ofl_desc *);
612 extern uintptr_t	ld_reloc_TLS(Boolean, Rel_desc *, Ofl_desc *);
613 extern int		ld_reloc_targval_get(Ofl_desc *, Rel_desc *,
614 			    uchar_t *, Xword *);
615 extern int		ld_reloc_targval_set(Ofl_desc *, Rel_desc *,
616 			    uchar_t *, Xword);
617 extern int		ld_reg_check(Sym_desc *, Sym *, const char *,
618 			    Ifl_desc *, Ofl_desc *);
619 extern int		ld_reg_enter(Sym_desc *, Ofl_desc *);
620 extern Sym_desc *	ld_reg_find(Sym *, Ofl_desc *);
621 
622 extern void		ld_sec_validate(Ofl_desc *);
623 extern uintptr_t	ld_sort_ordered(Ofl_desc *);
624 extern uintptr_t	ld_sort_seg_list(Ofl_desc *);
625 extern uintptr_t	ld_sunwmove_preprocess(Ofl_desc *);
626 extern void		ld_sup_atexit(Ofl_desc *, int);
627 extern void		ld_sup_open(Ofl_desc *, const char **, const char **,
628 			    int *, int, Elf **, Elf *ref, size_t,
629 			    const Elf_Kind);
630 extern void		ld_sup_file(Ofl_desc *, const char *, const Elf_Kind,
631 			    int flags, Elf *);
632 extern uintptr_t	ld_sup_loadso(Ofl_desc *, const char *);
633 extern void		ld_sup_input_done(Ofl_desc *);
634 extern void		ld_sup_section(Ofl_desc *, const char *, Shdr *, Word,
635 			    Elf_Data *, Elf *);
636 extern uintptr_t	ld_sup_input_section(Ofl_desc*, Ifl_desc *,
637 			    const char *, Shdr **, Word, Elf_Scn *, Elf *);
638 extern void		ld_sup_start(Ofl_desc *, const Half, const char *);
639 extern Sym_desc		*ld_sym_add_u(const char *, Ofl_desc *, Msg);
640 extern void		ld_sym_adjust_vis(Sym_desc *, Ofl_desc *);
641 extern int		ld_sym_avl_comp(const void *, const void *);
642 extern uintptr_t	ld_sym_copy(Sym_desc *);
643 extern Sym_desc		*ld_sym_enter(const char *, Sym *, Word, Ifl_desc *,
644 			    Ofl_desc *, Word, Word, Word, Half, avl_index_t *);
645 extern Sym_desc		*ld_sym_find(const char *, Word, avl_index_t *,
646 			    Ofl_desc *);
647 extern uintptr_t	ld_sym_nodirect(Is_desc *, Ifl_desc *, Ofl_desc *);
648 extern uintptr_t	ld_sym_process(Is_desc *, Ifl_desc *, Ofl_desc *);
649 extern uintptr_t	ld_sym_resolve(Sym_desc *, Sym *, Ifl_desc *,
650 			    Ofl_desc *, int, Word, Word);
651 extern uintptr_t	ld_sym_spec(Ofl_desc *);
652 
653 extern Ver_desc		*ld_vers_base(Ofl_desc *);
654 extern uintptr_t	ld_vers_check_defs(Ofl_desc *);
655 extern uintptr_t	ld_vers_check_need(Ofl_desc *);
656 extern uintptr_t	ld_vers_def_process(Is_desc *, Ifl_desc *, Ofl_desc *);
657 extern Ver_desc		*ld_vers_desc(const char *, Word, List *);
658 extern Ver_desc		*ld_vers_find(const char *, Word, List *);
659 extern uintptr_t	ld_vers_need_process(Is_desc *, Ifl_desc *, Ofl_desc *);
660 extern void		ld_vers_promote(Sym_desc *, Word, Ifl_desc *,
661 			    Ofl_desc *);
662 extern int		ld_vers_sym_process(Lm_list *, Is_desc *, Ifl_desc *);
663 extern int		ld_vers_verify(Ofl_desc *);
664 
665 extern uintptr_t	add_regsym(Sym_desc *, Ofl_desc *);
666 extern Word		hashbkts(Word);
667 extern Xword		lcm(Xword, Xword);
668 extern Listnode *	list_where(List *, Word);
669 
670 #if	defined(__x86) && defined(_ELF64)
671 extern uintptr_t	append_amd64_unwind(Os_desc *, Ofl_desc *);
672 extern uintptr_t	make_amd64_unwindhdr(Ofl_desc *);
673 extern uintptr_t	populate_amd64_unwindhdr(Ofl_desc *);
674 #endif
675 
676 #ifdef	__cplusplus
677 }
678 #endif
679 
680 #endif /* _LIBLD_DOT_H */
681