Print this page
3616 SHF_GROUP sections should not be discarded via other COMDAT mechanisms
3709 need sloppy relocation for GNU .debug_macro
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/libld/common/_libld.h
+++ new/usr/src/cmd/sgs/libld/common/_libld.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1988 AT&T
24 24 * All Rights Reserved
25 25 *
26 26 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
27 27 */
28 28
29 29 /*
30 30 * Local include file for ld library.
31 31 */
32 32
33 33 #ifndef _LIBLD_DOT_H
34 34 #define _LIBLD_DOT_H
35 35
36 36 #include <libld.h>
37 37 #include <_libelf.h>
38 38 #include <debug.h>
39 39 #include <conv.h>
40 40 #include <msg.h>
41 41 #include <reloc_defs.h>
42 42
43 43 #ifdef __cplusplus
44 44 extern "C" {
45 45 #endif
46 46
47 47 /*
48 48 * In order to allow for cross linking, we need to be able to build
49 49 * libld with support for multiple targets within a single object.
50 50 * This is done using a global variable (ld_targ) of type Target to
51 51 * access target-specific code for the current target via indirection.
52 52 */
53 53
54 54 /*
55 55 * Machine information for target
56 56 */
57 57 typedef struct {
58 58 Half m_mach; /* ELF machine code for target */
59 59 Half m_machplus; /* Alt ELF machine code for target */
60 60 /* Used for EM_SPARC32PLUS */
61 61 Word m_flagsplus; /* ELF header flags used to identify */
62 62 /* a machplus object */
63 63 uchar_t m_class; /* Target ELFCLASS */
64 64 uchar_t m_data; /* Target byte order */
65 65
66 66 Xword m_segm_align; /* segment alignment */
67 67 Xword m_segm_origin; /* Default 1st segment origin */
68 68 Xword m_segm_aorigin; /* Alternative 1st segment origin */
69 69 Word m_dataseg_perm; /* data segment permission mask */
70 70 Word m_stack_perm; /* ABI default stack permission mask */
71 71 Word m_word_align; /* alignment to use for Word sections */
72 72 const char *m_def_interp; /* Def. interpreter for dyn objects */
73 73
74 74 /* Relocation type codes */
75 75 Word m_r_arrayaddr;
76 76 Word m_r_copy;
77 77 Word m_r_glob_dat;
78 78 Word m_r_jmp_slot;
79 79 Word m_r_num;
80 80 Word m_r_none;
81 81 Word m_r_relative;
82 82 Word m_r_register;
83 83
84 84 /* Relocation related constants */
85 85 Word m_rel_dt_count; /* Either DT_REL or DT_RELA */
86 86 Word m_rel_dt_ent; /* Either DT_RELENT or DT_RELAENT */
87 87 Word m_rel_dt_size; /* Either DT_RELSZ or DT_RELASZ */
88 88 Word m_rel_dt_type; /* Either DT_RELCOUNT or DT_RELACOUNT */
89 89 Word m_rel_sht_type; /* Either SHT_REL or SHT_RELA */
90 90
91 91 /* GOT related constants */
92 92 Word m_got_entsize;
93 93 Word m_got_xnumber; /* reserved # of got ents */
94 94
95 95 /* PLT related constants */
96 96 Word m_plt_align;
97 97 Word m_plt_entsize;
98 98 Word m_plt_reservsz;
99 99 Word m_plt_shf_flags;
100 100
101 101 /* Section type of .eh_frame/.eh_frame_hdr sections */
102 102 Word m_sht_unwind;
103 103
104 104 Word m_dt_register;
105 105 } Target_mach;
106 106
107 107
108 108 /*
109 109 * Section identifiers, used to order sections in output object
110 110 */
111 111 typedef struct {
112 112 Word id_array;
113 113 Word id_bss;
114 114 Word id_cap;
115 115 Word id_capinfo;
116 116 Word id_capchain;
117 117 Word id_data;
118 118 Word id_dynamic;
119 119 Word id_dynsort;
120 120 Word id_dynstr;
121 121 Word id_dynsym;
122 122 Word id_dynsym_ndx;
123 123 Word id_got;
124 124 Word id_gotdata;
125 125 Word id_hash;
126 126 Word id_interp;
127 127 Word id_lbss;
128 128 Word id_ldynsym;
129 129 Word id_note;
130 130 Word id_null;
131 131 Word id_plt;
132 132 Word id_rel;
133 133 Word id_strtab;
134 134 Word id_syminfo;
135 135 Word id_symtab;
136 136 Word id_symtab_ndx;
137 137 Word id_text;
138 138 Word id_tls;
139 139 Word id_tlsbss;
140 140 Word id_unknown;
141 141 Word id_unwind;
142 142 Word id_unwindhdr;
143 143 Word id_user;
144 144 Word id_version;
145 145 } Target_machid;
146 146
147 147 /*
148 148 * Target_nullfunc supplies machine code for generating a
149 149 *
150 150 * void (*)(void)
151 151 *
152 152 * unnamed function. Such a function can be called, and returns
153 153 * immediately without doing any work. This is used to back FUNC
154 154 * symbol definitions added with a mapfile.
155 155 *
156 156 * The machine instructions are specified as an array of bytes rather
157 157 * than a larger integer type in order to avoid byte order issues that
158 158 * can otherwise occur in cross linking.
159 159 */
160 160 typedef struct {
161 161 const uchar_t *nf_template; /* Array of machine inst. bytes */
162 162 size_t nf_size; /* # bytes in nf_template */
163 163 } Target_nullfunc;
164 164
165 165 /*
166 166 * Target_fill supplies machine code for fill bytes in executable output
167 167 * sections. Normally, libelf fills the gaps caused by alignment and size
168 168 * requirements of the constituent input sections with 0. Depending on the
169 169 * target architecture, it may be desirable to instead fill with executable
170 170 * NOP instructions. There are two reasons to do this:
171 171 *
172 172 * - So that .init/.fini sections will not contain unexecutable gaps
173 173 * that cause the executing program to trap and die.
174 174 *
175 175 * - To eliminate confusing garbage instructions between sections containing
176 176 * executable code when viewed with a disassembler.
177 177 *
178 178 * The ff_execfill function is allowed to be NULL if the underlying target
179 179 * does not require a special fill for executable sections.
180 180 */
181 181 typedef struct {
182 182 _elf_execfill_func_t *ff_execfill;
183 183 } Target_fillfunc;
184 184
185 185 /*
186 186 * Target_machrel holds pointers to the reloc_table and machrel functions
187 187 * for a given target machine.
188 188 *
189 189 * The following function pointers are allowed to be NULL, if the
190 190 * underlying target does not require the specified operation. All
191 191 * other functions must be supplied:
192 192 *
193 193 * mr_assign_got
194 194 * mr_reloc_register
195 195 * mr_reloc_GOTOP
196 196 * mr_allocate_got
197 197 */
198 198 typedef struct {
199 199 const Rel_entry *mr_reloc_table;
200 200
201 201 Word (* mr_init_rel)(Rel_desc *, Word *, void *);
202 202 void (* mr_mach_eflags)(Ehdr *, Ofl_desc *);
203 203 void (* mr_mach_make_dynamic)(Ofl_desc *, size_t *);
204 204 void (* mr_mach_update_odynamic)(Ofl_desc *, Dyn **);
205 205 Xword (* mr_calc_plt_addr)(Sym_desc *, Ofl_desc *);
206 206 uintptr_t (* mr_perform_outreloc)(Rel_desc *, Ofl_desc *,
207 207 Boolean *);
208 208 uintptr_t (* mr_do_activerelocs)(Ofl_desc *);
209 209 uintptr_t (* mr_add_outrel)(Word, Rel_desc *, Ofl_desc *);
210 210 uintptr_t (* mr_reloc_register)(Rel_desc *, Is_desc *,
211 211 Ofl_desc *);
212 212 uintptr_t (* mr_reloc_local)(Rel_desc *, Ofl_desc *);
213 213 uintptr_t (* mr_reloc_GOTOP)(Boolean, Rel_desc *, Ofl_desc *);
214 214 uintptr_t (* mr_reloc_TLS)(Boolean, Rel_desc *, Ofl_desc *);
215 215 uintptr_t (* mr_assign_got)(Ofl_desc *, Sym_desc *);
216 216
217 217 Gotndx *(* mr_find_got_ndx)(Alist *, Gotref, Ofl_desc *,
218 218 Rel_desc *);
219 219 Xword (* mr_calc_got_offset)(Rel_desc *, Ofl_desc *);
220 220 uintptr_t (* mr_assign_got_ndx)(Alist **, Gotndx *, Gotref,
221 221 Ofl_desc *, Rel_desc *, Sym_desc *);
222 222 void (* mr_assign_plt_ndx)(Sym_desc *, Ofl_desc *);
223 223 uintptr_t (* mr_allocate_got)(Ofl_desc *);
224 224 uintptr_t (* mr_fillin_gotplt)(Ofl_desc *);
225 225 } Target_machrel;
226 226
227 227
228 228 /*
229 229 * Target_machsym holds pointers to the machsym functions
230 230 * for a given target machine.
231 231 *
232 232 * These fields are allowed to be NULL for targets that do not require
233 233 * special handling of register symbols. Register symbols are used by
234 234 * sparc targets. If any of these fields are non-NULL, all of them are
235 235 * required to be present (use empty stub routines if necessary).
236 236 */
237 237 typedef struct {
238 238 int (* ms_reg_check)(Sym_desc *, Sym *, const char *,
239 239 Ifl_desc *, Ofl_desc *);
240 240 int (* ms_mach_sym_typecheck)(Sym_desc *, Sym *,
241 241 Ifl_desc *, Ofl_desc *);
242 242 const char *(* ms_is_regsym)(Ofl_desc *, Ifl_desc *, Sym *,
243 243 const char *, int, Word, const char *, sd_flag_t *);
244 244 Sym_desc *(* ms_reg_find)(Sym * sym, Ofl_desc * ofl);
245 245 int (* ms_reg_enter)(Sym_desc *, Ofl_desc *);
246 246 } Target_machsym;
247 247
248 248 typedef struct {
249 249 Target_mach t_m;
250 250 Target_machid t_id;
251 251 Target_nullfunc t_nf;
252 252 Target_fillfunc t_ff;
253 253 Target_machrel t_mr;
254 254 Target_machsym t_ms;
255 255 } Target;
256 256
257 257 /*
258 258 * Structure to manage the update of weak symbols from their associated alias.
259 259 */
260 260 typedef struct wk_desc {
261 261 Sym *wk_symtab; /* the .symtab entry */
262 262 Sym *wk_dynsym; /* the .dynsym entry */
263 263 Sym_desc *wk_weak; /* the original weak symbol */
264 264 Sym_desc *wk_alias; /* the real symbol */
265 265 } Wk_desc;
266 266
267 267 /*
268 268 * Structure to manage the support library interfaces.
269 269 */
270 270 typedef struct func_list {
271 271 const char *fl_obj; /* name of support object */
272 272 /* function is from */
273 273 void (*fl_fptr)(); /* function pointer */
274 274 uint_t fl_version; /* ld_version() level */
275 275 } Func_list;
276 276
277 277 typedef struct support_list {
278 278 const char *sup_name; /* ld_support function name */
279 279 Alist *sup_funcs; /* list of support functions */
280 280 } Support_list;
281 281
282 282 /*
283 283 * Structure to manage a sorted output relocation list.
284 284 *
285 285 * rl_key1 -> pointer to needed ndx
286 286 * rl_key2 -> pointer to symbol relocation is against
287 287 * rl_key3 -> virtual offset of relocation
288 288 */
289 289 typedef struct reloc_list {
290 290 Sym_desc *rl_key2;
291 291 Xword rl_key3;
292 292 Rel_desc *rl_rsp;
293 293 Half rl_key1;
294 294 } Reloc_list;
295 295
296 296
297 297 typedef struct sym_s_list {
298 298 Word sl_hval;
299 299 Sym_desc *sl_sdp;
300 300 } Sym_s_list;
301 301
302 302 /*
303 303 * ld heap management structure
304 304 */
305 305 typedef struct _ld_heap Ld_heap;
306 306 struct _ld_heap {
307 307 Ld_heap *lh_next;
308 308 void *lh_free;
309 309 void *lh_end;
310 310 };
311 311
312 312 #define HEAPBLOCK 0x800000 /* default allocation block size */
313 313 #define HEAPALIGN 0x8 /* heap blocks alignment requirement */
314 314
315 315 /*
316 316 * Dynamic per-symbol filtee string table descriptor. This associates filtee
317 317 * strings that will be created in the .dynstr, with .dynamic entries.
318 318 */
319 319 typedef struct {
320 320 const char *dft_str; /* dynstr string */
321 321 Word dft_flag; /* auxiliary/filtee type */
322 322 Half dft_ndx; /* eventual ndx into .dynamic */
323 323 } Dfltr_desc;
324 324
325 325 /*
326 326 * Per-symbol filtee descriptor. This associates symbol definitions with
327 327 * their filtees.
328 328 */
329 329 typedef struct {
330 330 Sym_desc *sft_sdp; /* symbol descriptor */
331 331 Aliste sft_idx; /* index into dtstr descriptor */
332 332 } Sfltr_desc;
333 333
334 334 /*
335 335 * Capabilities descriptor, and capabilities group descriptor, used to track
336 336 * the symbol capabilities of any input files and the output file.
337 337 *
338 338 * A relocatable object input file may contain one or more symbol capabilities
339 339 * groups. The Cap_desc structures keep track of all unique groups that are
340 340 * collected for the output file. Relocatable objects that contain an object
341 341 * capabilities group, and the -z symbolcap option is in effect, have their
342 342 * object group translated to a symbol capabilities group.
343 343 *
344 344 * Individual capabilities groups are maintained with the Cap_group descriptor.
345 345 * A group can consist of one or more capabilities definitions. One or more
346 346 * symbols can be associated with each group.
347 347 *
348 348 * For the output file, capabilities families are used to track the symbols of
349 349 * a given family, each symbol being associated with a different group. This
350 350 * collection of data is used to create the final Capinfo structure, and for
351 351 * dynamic objects, the Capchain structure.
352 352 *
353 353 * For example, an object may contain two capabilities groups:
354 354 *
355 355 * CA_SUNW_MACH - sun4u CA_SUNW_MACH - sun4v
356 356 *
357 357 * Two symbols can be associated with each group:
358 358 *
359 359 * foo%sun4u foo%sun4v
360 360 * bar%sun4u bar%sun4v
361 361 *
362 362 * Two families are maintained, and include the generic, or lead, instance of
363 363 * the capabilities members:
364 364 *
365 365 * foo, foo%sun4u, foo%sun4v
366 366 * bar, bar%sun4u, bar%sun4v
367 367 */
368 368 struct cap_desc {
369 369 APlist *ca_groups; /* capabilities groups (Cap_group) */
370 370 APlist *ca_syms; /* copies of symbols that are being */
371 371 /* translated from object to */
372 372 }; /* symbol capabilities */
373 373
374 374 typedef struct {
375 375 Objcapset cg_set; /* unpacked SHT_SUNW_cap elements */
376 376 APlist *cg_secs; /* sections, and hence files, that */
377 377 /* use this descriptor */
378 378 Word cg_num; /* number of comparable elements in */
379 379 /* the group */
380 380 Word cg_ndx; /* final capability group index */
381 381 } Cap_group;
382 382
383 383 /*
384 384 * A Capabilities family node, extends a symbol node, and provides for tracking
385 385 * capabilities families. A family is defined by its lead symbol (for example,
386 386 * a generic, non-capabilities aware foo()), and one or more capabilities
387 387 * members (for example, capabilities instances foo%sun4u(), foo%sun4v(), etc.).
388 388 *
389 389 * Each member associates a symbol with its group using a Cap_sym structure.
390 390 */
391 391 typedef struct {
392 392 Sym_avlnode cn_symavlnode;
393 393 APlist *cn_members;
394 394 APlist *cn_aliases;
395 395 } Cap_avlnode;
396 396
397 397 typedef struct {
398 398 Sym_desc *cs_sdp; /* capabilities symbol descriptor */
399 399 Cap_group *cs_group; /* associated capabilities group */
400 400 } Cap_sym;
401 401
402 402 /*
403 403 * Define Alist initialization sizes.
404 404 */
405 405 #define AL_CNT_IFL_GROUPS 20 /* ifl_groups */
406 406 #define AL_CNT_IFL_RELSECS 6 /* ifl_relsect */
407 407
408 408 #define AL_CNT_CAP_DESCS 4 /* symbol capabilities descriptors */
409 409 #define AL_CNT_CAP_SYMS 20 /* capabilities symbols */
410 410 #define AL_CNT_CAP_SECS 10 /* capabilities sections */
411 411 #define AL_CNT_CAP_NAMES 10 /* Objcapset platform and machine */
412 412 /* names */
413 413 #define AL_CNT_CAP_MEMS 10 /* capability family members */
414 414 #define AL_CNT_CAP_PAIRS 10 /* capability symbol pairs */
415 415 #define AL_CNT_CAP_ALIASES 2 /* capability lead symbol aliases */
416 416
417 417 #define AL_CNT_OFL_DTSFLTRS 4 /* ofl_dtsfltrs */
418 418 #define AL_CNT_OFL_SYMFLTRS 20 /* ofl_symfltrs */
419 419 #define AL_CNT_OFL_MAPSECS 10 /* ofl_map{text|data} */
420 420 #define AL_CNT_OFL_OBJS 50 /* ofl_objs */
421 421 #define AL_CNT_OFL_LIBS 10 /* ofl_sos */
422 422 #define AL_CNT_OFL_LIBDIRS 10 /* ofl_[ud]libdirs */
423 423 #define AL_CNT_OFL_MAPFILES 6 /* ofl_maps */
424 424 #define AL_CNT_OFL_ENTRANCE 10 /* ofl_ents */
425 425 #define AL_CNT_OFL_RELS 4 /* ofl_outrels */
426 426 #define AL_CNT_OFL_COPYRELS 10 /* ofl_copyrels */
427 427 #define AL_CNT_OFL_ARRAYS 10 /* ofl_{init|fini|prei}array */
428 428 #define AL_CNT_OFL_OSGROUPS 10 /* ofl_osgroups */
429 429 #define AL_CNT_OFL_OSTLSSEG 4 /* ofl_ostlsseg */
430 430 #define AL_CNT_OFL_ORDERED 4 /* ofl_ordered */
431 431 #define AL_CNT_OFL_SYMINFOSYMS 50 /* ofl_syminfsyms */
432 432 #define AL_CNT_OFL_MOVE 10 /* ofl_ismove */
433 433 #define AL_CNT_OFL_UNWIND 1 /* ofl_unwind */
434 434 #define AL_CNT_OFL_PARSYMS 10 /* ofl_parsyms */
435 435
436 436 #define AL_CNT_OS_MSTRISDESCS 10 /* os_mstrisdescs */
437 437 #define AL_CNT_OS_RELISDESCS 100 /* os_relisdescs */
438 438 #define AL_CNT_OS_COMDATS 20 /* os_comdats */
439 439 #define AL_CNT_OS_ISDESCS_BA 4 /* os_isdesc: BEFORE|AFTER */
440 440 #define AL_CNT_OS_ISDESCS 60 /* os_isdesc: ORDERED|DEFAULT */
441 441
442 442 #define AL_CNT_SG_IS_ORDER 40 /* sg_is_order */
443 443 #define AL_CNT_SG_OSDESC 40 /* sg_osdescs */
444 444 #define AL_CNT_SG_SECORDER 40 /* sg_secorder */
445 445 #define AL_CNT_SG_SIZESYM 1 /* sg_sizesym */
446 446
447 447 #define AL_CNT_SDP_GOT 1 /* sd_GOTndxs */
448 448 #define AL_CNT_SDP_MOVE 1 /* sd_move */
449 449 #define AL_CNT_SDP_DFILES 1 /* sa_dfiles */
450 450
451 451 #define AL_CNT_SDF_VERSIONS 2 /* sdf_{vers|verneed} */
452 452
453 453 #define AL_CNT_EC_FILES 1 /* ec_files */
454 454
455 455 #define AL_CNT_VERDESCS 20 /* version desc */
456 456 #define AL_CNT_WEAK 20 /* weak desc */
457 457 #define AL_CNT_SUPPORT 2 /* support libraries */
458 458 #define AL_CNT_STRMRGREL 500 /* ld_make_strmerge() reloc alist cnt */
459 459 #define AL_CNT_STRMRGSYM 20 /* ld_make_strmerge() sym alist cnt */
460 460 #define AL_CNT_SEGMENTS 20 /* ofl_segs */
461 461
462 462 #define AL_CNT_ASSDEFLIB 4 /* ofl_assdeflib exceptions count */
463 463
464 464 /*
465 465 * Return codes for {tls|got}_fixups() routines
466 466 */
467 467 typedef enum {
468 468 FIX_ERROR, /* fatal error - time to punt */
469 469 FIX_DONE, /* relocation done - no further processing required */
470 470 FIX_RELOC /* do_reloc() relocation processing required */
471 471 } Fixupret;
472 472
473 473 #ifndef FILENAME_MAX
474 474 #define FILENAME_MAX BUFSIZ /* maximum length of a path name */
475 475 #endif
476 476
477 477 /*
478 478 * We pad the end of the .dynstr section with a block of DYNSTR_EXTRA_PAD
479 479 * bytes, and we insert DYNAMIC_EXTRA_ELTS unused items into the
480 480 * .dynamic section (with value DT_NULL). This provides the resources needed
481 481 * to add and/or alter string items in the .dynamic section, such as runpath.
482 482 */
483 483 #define DYNSTR_EXTRA_PAD 512
484 484 #define DYNAMIC_EXTRA_ELTS 10
485 485
486 486 /*
487 487 * Default relocation cache allocation unit. This number should be small
488 488 * enough to not hurt memory use significantly, but large enough to avoid
489 489 * the need for too many subsequent allocations.
490 490 */
491 491 #define REL_CACHEBUF_ALLOC 3000
492 492 #define RELAUX_CACHEBUF_ALLOC 1500
493 493
494 494 /*
495 495 * Given a symbol of a type that is allowed within a .SUNW_dynsymsort or
496 496 * .SUNW_dyntlssort section, examine the symbol attributes to determine
497 497 * if this particular symbol should be included or not.
498 498 *
499 499 * entry:
500 500 * The symbol must have an allowed type: Either a type verified by
501 501 * dynsymsort_symtype[] or STT_TLS.
502 502 *
503 503 * _sdp - Pointer to symbol descriptor
504 504 * _sym - Pointer to symbol referenced by _sdp.
505 505 *
506 506 * _sym is derivable from _sdp: _sdp->sd_sym
507 507 * However, most callers assign it to a local variable for efficiency,
508 508 * and this macro allows such a variable to be used within. If you
509 509 * don't have such a variable, supply _sdp->sd_sym.
510 510 *
511 511 * The tests used require some explanation:
512 512 *
513 513 * (_sdp->sd_flags & FLG_SY_DYNSORT)
514 514 * Some special symbols are kept even if they don't meet the
515 515 * usual requirements. These symbols have the FLG_SY_DYNSORT
516 516 * bit set. If this bit isn't set then we look at the other
517 517 * attributes.
518 518 *
519 519 * (((_sdp->sd_ref != REF_DYN_NEED) &&
520 520 * (_sdp->sd_sym->st_shndx != SHN_UNDEF))
521 521 * || (_sdp->sd_flags & FLG_SY_MVTOCOMM))
522 522 * We do not want to include symbols that are not defined within
523 523 * the object we are creating. REF_DYN_NEED corresponds to those
524 524 * UNDEF items. However, if the symbol is the target of a copy
525 525 * relocation, then it effectively becomes defined within the
526 526 * object after all. FLG_SY_MVTOCOMM indicates a copy relocation,
527 527 * and prevents us from culling those exceptions.
528 528 *
529 529 * (_sym->st_size != 0)
530 530 * Symbols with 0 length are labels injected by the compilers
531 531 * or the linker for purposes of code generation, and do
532 532 * not directly correspond to actual code. In fact, most of the
533 533 * symbols we mark with FLG_SY_DYNSORT need that flag set because
534 534 * they have size 0. This size test filters out the others.
535 535 *
536 536 * !(_sdp->sd_flags & FLG_SY_NODYNSORT)
537 537 * Some symbols are not kept, even though they do meet the usual
538 538 * requirements. These symbols have FLG_SY_NODYNSORT set.
539 539 * For example, if there are weak and non-weak versions of a given
540 540 * symbol, we only want to keep one of them. So, we set
541 541 * FLG_SY_NODYNSORT on the one we don't want.
542 542 */
543 543 #define DYNSORT_TEST_ATTR(_sdp, _sym) \
544 544 ((_sdp->sd_flags & FLG_SY_DYNSORT) || \
545 545 ((((_sdp->sd_ref != REF_DYN_NEED) && \
546 546 (_sdp->sd_sym->st_shndx != SHN_UNDEF)) || \
547 547 (_sdp->sd_flags & FLG_SY_MVTOCOMM)) && \
548 548 (_sym->st_size != 0) && \
549 549 !(_sdp->sd_flags & FLG_SY_NODYNSORT)))
550 550
551 551 /*
552 552 * We use output section descriptor counters to add up the number of
553 553 * symbol indexes to put in the .SUNW_dynsort and .SUNW_dyntlssort sections.
554 554 * Non-TLS symbols are counted by ofl->ofl_dynsymsortcnt, while TLS symbols are
555 555 * counted by ofl->ofl_dyntlssortcnt. This computation is done inline in
556 556 * several places. The DYNSORT_COUNT macro allows us to generate this from
557 557 * a single description.
558 558 *
559 559 * entry:
560 560 * _sdp, _sym - As per DYNSORT_TEST_ATTR
561 561 * _type - Type of symbol (STT_*)
562 562 * _inc_or_dec_op - Either ++, or --. This specifies the operation
563 563 * to be applied to the counter, and determines whether we
564 564 * are adding, or removing, a symbol from .SUNW_dynsymsort.
565 565 *
566 566 * Note that _type is derivable from _sym: ELF_ST_TYPE(_sdp->sd_sym->st_info).
567 567 * Most callers already have it in a variable, so this allows us to use that
568 568 * variable. If you don't have such a variable, use ELF_ST_TYPE() as shown.
569 569 */
570 570 #define DYNSORT_COUNT(_sdp, _sym, _type, _inc_or_dec_op) \
571 571 { \
572 572 Word *_cnt_var; \
573 573 \
574 574 if (dynsymsort_symtype[_type]) { /* Non-TLS counter */ \
575 575 _cnt_var = &ofl->ofl_dynsymsortcnt; \
576 576 } else if ((_type) == STT_TLS) { /* TLS counter */ \
577 577 _cnt_var = &ofl->ofl_dyntlssortcnt; \
578 578 } else { /* Don't count this symbol */ \
579 579 _cnt_var = NULL; \
580 580 } \
581 581 if ((_cnt_var != NULL) && DYNSORT_TEST_ATTR(_sdp, _sym)) \
582 582 (*_cnt_var)_inc_or_dec_op; /* Increment/Decrement */ \
583 583 }
584 584
585 585 /*
586 586 * The OFL_SWAP_RELOC macros are used to determine whether
587 587 * relocation processing needs to swap the data being relocated.
588 588 * It is an optimization to ld_swap_reloc_data(), as it avoids
589 589 * the function call in the case where the linker host and the
590 590 * target have the same byte order.
591 591 */
592 592 #define OFL_SWAP_RELOC_DATA(_ofl, _rel) \
593 593 (((_ofl)->ofl_flags1 & FLG_OF1_ENCDIFF) && \
594 594 ld_swap_reloc_data(_ofl, _rel))
595 595
596 596 /*
597 597 * Define an AVL node for maintaining input section descriptors. AVL trees of
598 598 * these descriptors are used to process group and COMDAT section.
599 599 *
600 600 * Pure COMDAT uses the input section name as the search key, while
601 601 * SHT_GROUP sections use the name of a special signature symbol. We
602 602 * support both by using the isd_name field to carry the name. An alternative
603 603 * design would be to use a separate type for each use, saving the cost
604 604 * of the unneeded pointer for pure COMDAT. We favor a single implementation
605 605 * because we believe that SHT_GROUP comdat will be more common going forward,
606 606 * particularly in the largest objects produced by C++ where SHT_GROUP is
607 607 * needed to manage the complex section relationships. In contrast, we think
608 608 * that pure COMDAT is both more rare, and used in smaller objects where the
609 609 * cost of an extra pointer per node is relatively unimportant.
610 610 */
611 611 typedef struct {
612 612 avl_node_t isd_avl; /* avl book-keeping (see SGSOFFSETOF) */
613 613 Is_desc *isd_isp; /* input section descriptor */
614 614 const char *isd_name; /* name used as search key */
615 615 uint_t isd_hash; /* input section name hash value */
616 616 } Isd_node;
617 617
618 618 /*
619 619 * Type used to break down an input file path into its component parts,
620 620 * as used by ld_place_section() to compare an input file path to
621 621 * entrance criteria ec_files file strings.
622 622 *
623 623 * We define a path in the usual Unix '/' separated manner, augmented
624 624 * with an optional archive member suffix enclosed in parenthesis:
625 625 *
626 626 * /dir/.../dir/basename(armember)
627 627 *
628 628 * The basename is the final path component, and includes the archive
629 629 * member, if present. The meaning of "object name" depends on whether or
630 630 * not the file comes from an archive or not. If not an archive, it is the
631 631 * same as the basename. If an archive, it is the name of the archive member
632 632 * from within the file.
633 633 *
634 634 * Variables of this type are initialized with ld_place_path_info_init().
635 635 */
636 636 typedef struct {
637 637 const char *ppi_path; /* Full path */
638 638 const char *ppi_bname; /* basename(ppi_path) */
639 639 const char *ppi_oname; /* object name: Not NULL terminated */
640 640 Boolean ppi_isar; /* TRUE if path has archive member */
641 641 size_t ppi_path_len; /* strlen(ppi_path) */
642 642 size_t ppi_bname_len; /* strlen(ppi_bname) */
643 643 size_t ppi_oname_len; /* strlen(ppi_oname) */
644 644 } Place_path_info;
645 645
646 646 /*
647 647 * Local data items.
648 648 */
649 649 extern char *Plibpath;
650 650 extern char *Llibdir;
651 651 extern char *Ulibdir;
652 652 extern Ld_heap *ld_heap;
653 653 extern APlist *lib_support;
654 654 extern int demangle_flag;
655 655 extern const Msg reject[];
656 656 extern int Verbose;
657 657 extern const int ldynsym_symtype[];
658 658 extern const int dynsymsort_symtype[];
659 659
660 660 /*
661 661 * Local functions.
662 662 */
663 663 extern char *add_string(char *, char *);
664 664 extern const char *demangle(const char *);
665 665 extern int cap_names_match(Alist *, Alist *);
666 666
667 667 extern void lds_atexit(Ofl_desc *, int);
668 668
669 669 extern void libld_free(void *);
670 670 extern void *libld_malloc(size_t);
671 671 extern void *libld_realloc(void *, size_t);
672 672
673 673 extern int isdavl_compare(const void *, const void *);
674 674
675 675 extern Sdf_desc *sdf_add(const char *, APlist **);
676 676 extern Sdf_desc *sdf_find(const char *, APlist *);
677 677
678 678 #if defined(_ELF64)
679 679
680 680 #define ld_add_actrel ld64_add_actrel
↓ open down ↓ |
680 lines elided |
↑ open up ↑ |
681 681 #define ld_add_libdir ld64_add_libdir
682 682 #define ld_adj_movereloc ld64_adj_movereloc
683 683 #define ld_am_I_partial ld64_am_I_partial
684 684 #define ld_ar_member ld64_ar_member
685 685 #define ld_ar_setup ld64_ar_setup
686 686 #define ld_assign_got_TLS ld64_assign_got_TLS
687 687 #define ld_bswap_Word ld64_bswap_Word
688 688 #define ld_bswap_Xword ld64_bswap_Xword
689 689 #define ld_cap_add_family ld64_cap_add_family
690 690 #define ld_cap_move_symtoobj ld64_cap_move_symtoobj
691 +#define ld_comdat_validate ld64_comdat_validate
691 692 #define ld_disp_errmsg ld64_disp_errmsg
692 693 #define ld_ent_check ld64_ent_check
693 694 #define ld_ent_lookup ld64_ent_lookup
694 695 #define ld_eprintf ld64_eprintf
695 696 #define ld_exit ld64_exit
696 697 #define ld_find_library ld64_find_library
697 698 #define ld_finish_libs ld64_finish_libs
698 699 #define ld_get_group ld64_get_group
699 700 #define ld_group_process ld64_group_process
700 701 #define ld_lib_setup ld64_lib_setup
701 702 #define ld_init_sighandler ld64_init_sighandler
702 703 #define ld_lcm ld64_lcm
703 704 #define ld_make_bss ld64_make_bss
704 705 #define ld_make_data ld64_make_data
705 706 #define ld_make_got ld64_make_got
706 707 #define ld_make_parexpn_data ld64_make_parexpn_data
707 708 #define ld_make_sunwmove ld64_make_sunmove
708 709 #define ld_make_text ld64_make_text
709 710 #define ld_map_out ld64_map_out
710 711 #define ld_map_parse ld64_map_parse
711 712 #define ld_map_post_process ld64_map_post_process
712 713 #define ld_open_outfile ld64_open_outfile
713 714 #define ld_os_first_isdesc ld64_os_first_isdesc
714 715 #define ld_place_path_info_init ld64_place_path_info_init
715 716 #define ld_place_section ld64_place_section
716 717 #define ld_process_archive ld64_process_archive
717 718 #define ld_process_files ld64_process_files
718 719 #define ld_process_flags ld64_process_flags
719 720 #define ld_process_ifl ld64_process_ifl
720 721 #define ld_process_move ld64_process_move
721 722 #define ld_process_open ld64_process_open
722 723 #define ld_process_ordered ld64_process_ordered
723 724 #define ld_process_sym_reloc ld64_process_sym_reloc
724 725 #define ld_reloc_enter ld64_reloc_enter
725 726 #define ld_reloc_GOT_relative ld64_reloc_GOT_relative
726 727 #define ld_reloc_plt ld64_reloc_plt
727 728 #define ld_reloc_remain_entry ld64_reloc_remain_entry
728 729 #define ld_reloc_set_aux_osdesc ld64_reloc_set_aux_osdesc
729 730 #define ld_reloc_set_aux_usym ld64_reloc_set_aux_usym
730 731 #define ld_reloc_sym_name ld64_reloc_sym_name
731 732 #define ld_reloc_targval_get ld64_reloc_targval_get
732 733 #define ld_reloc_targval_set ld64_reloc_targval_set
733 734 #define ld_sec_validate ld64_sec_validate
734 735 #define ld_seg_lookup ld64_seg_lookup
735 736 #define ld_sort_ordered ld64_sort_ordered
736 737 #define ld_stt_section_sym_name ld64_stt_section_sym_name
737 738 #define ld_sunw_ldmach ld64_sunw_ldmach
738 739 #define ld_sup_atexit ld64_sup_atexit
739 740 #define ld_sup_open ld64_sup_open
740 741 #define ld_sup_file ld64_sup_file
741 742 #define ld_sup_loadso ld64_sup_loadso
742 743 #define ld_sup_input_done ld64_sup_input_done
743 744 #define ld_sup_input_section ld64_sup_input_section
744 745 #define ld_sup_section ld64_sup_section
745 746 #define ld_sup_start ld64_sup_start
746 747 #define ld_swap_reloc_data ld64_swap_reloc_data
747 748 #define ld_sym_add_u ld64_sym_add_u
748 749 #define ld_sym_adjust_vis ld64_sym_adjust_vis
749 750 #define ld_sym_avl_comp ld64_sym_avl_comp
750 751 #define ld_sym_copy ld64_sym_copy
751 752 #define ld_sym_enter ld64_sym_enter
752 753 #define ld_sym_find ld64_sym_find
753 754 #define ld_sym_nodirect ld64_sym_nodirect
754 755 #define ld_sym_process ld64_sym_process
755 756 #define ld_sym_resolve ld64_sym_resolve
756 757 #define ld_sym_spec ld64_sym_spec
757 758 #define ld_targ ld64_targ
758 759 #define ld_targ_init_sparc ld64_targ_init_sparc
759 760 #define ld_targ_init_x86 ld64_targ_init_x86
760 761 #define ld_unwind_make_hdr ld64_unwind_make_hdr
761 762 #define ld_unwind_populate_hdr ld64_unwind_populate_hdr
762 763 #define ld_unwind_register ld64_unwind_register
763 764 #define ld_vers_base ld64_vers_base
764 765 #define ld_vers_check_defs ld64_vers_check_defs
765 766 #define ld_vers_check_need ld64_vers_check_need
766 767 #define ld_vers_def_process ld64_vers_def_process
767 768 #define ld_vers_desc ld64_vers_desc
768 769 #define ld_vers_find ld64_vers_find
769 770 #define ld_vers_need_process ld64_vers_need_process
770 771 #define ld_vers_promote ld64_vers_promote
771 772 #define ld_vers_sym_process ld64_vers_sym_process
772 773 #define ld_vers_verify ld64_vers_verify
773 774 #define ld_wrap_enter ld64_wrap_enter
774 775
775 776 #else
776 777
777 778 #define ld_add_actrel ld32_add_actrel
↓ open down ↓ |
77 lines elided |
↑ open up ↑ |
778 779 #define ld_add_libdir ld32_add_libdir
779 780 #define ld_adj_movereloc ld32_adj_movereloc
780 781 #define ld_am_I_partial ld32_am_I_partial
781 782 #define ld_ar_member ld32_ar_member
782 783 #define ld_ar_setup ld32_ar_setup
783 784 #define ld_assign_got_TLS ld32_assign_got_TLS
784 785 #define ld_bswap_Word ld32_bswap_Word
785 786 #define ld_bswap_Xword ld32_bswap_Xword
786 787 #define ld_cap_add_family ld32_cap_add_family
787 788 #define ld_cap_move_symtoobj ld32_cap_move_symtoobj
789 +#define ld_comdat_validate ld32_comdat_validate
788 790 #define ld_disp_errmsg ld32_disp_errmsg
789 791 #define ld_ent_check ld32_ent_check
790 792 #define ld_ent_lookup ld32_ent_lookup
791 793 #define ld_eprintf ld32_eprintf
792 794 #define ld_exit ld32_exit
793 795 #define ld_find_library ld32_find_library
794 796 #define ld_finish_libs ld32_finish_libs
795 797 #define ld_get_group ld32_get_group
796 798 #define ld_group_process ld32_group_process
797 799 #define ld_lib_setup ld32_lib_setup
798 800 #define ld_init_sighandler ld32_init_sighandler
799 801 #define ld_lcm ld32_lcm
800 802 #define ld_make_bss ld32_make_bss
801 803 #define ld_make_data ld32_make_data
802 804 #define ld_make_got ld32_make_got
803 805 #define ld_make_parexpn_data ld32_make_parexpn_data
804 806 #define ld_make_sunwmove ld32_make_sunmove
805 807 #define ld_make_text ld32_make_text
806 808 #define ld_map_out ld32_map_out
807 809 #define ld_map_parse ld32_map_parse
808 810 #define ld_map_post_process ld32_map_post_process
809 811 #define ld_open_outfile ld32_open_outfile
810 812 #define ld_os_first_isdesc ld32_os_first_isdesc
811 813 #define ld_place_path_info_init ld32_place_path_info_init
812 814 #define ld_place_section ld32_place_section
813 815 #define ld_process_archive ld32_process_archive
814 816 #define ld_process_files ld32_process_files
815 817 #define ld_process_flags ld32_process_flags
816 818 #define ld_process_ifl ld32_process_ifl
817 819 #define ld_process_move ld32_process_move
818 820 #define ld_process_open ld32_process_open
819 821 #define ld_process_ordered ld32_process_ordered
820 822 #define ld_process_sym_reloc ld32_process_sym_reloc
821 823 #define ld_reloc_enter ld32_reloc_enter
822 824 #define ld_reloc_GOT_relative ld32_reloc_GOT_relative
823 825 #define ld_reloc_plt ld32_reloc_plt
824 826 #define ld_reloc_remain_entry ld32_reloc_remain_entry
825 827 #define ld_reloc_set_aux_osdesc ld32_reloc_set_aux_osdesc
826 828 #define ld_reloc_set_aux_usym ld32_reloc_set_aux_usym
827 829 #define ld_reloc_sym_name ld32_reloc_sym_name
828 830 #define ld_reloc_targval_get ld32_reloc_targval_get
829 831 #define ld_reloc_targval_set ld32_reloc_targval_set
830 832 #define ld_sec_validate ld32_sec_validate
831 833 #define ld_seg_lookup ld32_seg_lookup
832 834 #define ld_sort_ordered ld32_sort_ordered
833 835 #define ld_stt_section_sym_name ld32_stt_section_sym_name
834 836 #define ld_sunw_ldmach ld32_sunw_ldmach
835 837 #define ld_sup_atexit ld32_sup_atexit
836 838 #define ld_sup_open ld32_sup_open
837 839 #define ld_sup_file ld32_sup_file
838 840 #define ld_sup_loadso ld32_sup_loadso
839 841 #define ld_sup_input_done ld32_sup_input_done
840 842 #define ld_sup_input_section ld32_sup_input_section
841 843 #define ld_sup_section ld32_sup_section
842 844 #define ld_sup_start ld32_sup_start
843 845 #define ld_swap_reloc_data ld32_swap_reloc_data
844 846 #define ld_sym_add_u ld32_sym_add_u
845 847 #define ld_sym_adjust_vis ld32_sym_adjust_vis
846 848 #define ld_sym_avl_comp ld32_sym_avl_comp
847 849 #define ld_sym_copy ld32_sym_copy
848 850 #define ld_sym_enter ld32_sym_enter
849 851 #define ld_sym_find ld32_sym_find
850 852 #define ld_sym_nodirect ld32_sym_nodirect
851 853 #define ld_sym_process ld32_sym_process
852 854 #define ld_sym_resolve ld32_sym_resolve
853 855 #define ld_sym_spec ld32_sym_spec
854 856 #define ld_targ ld32_targ
855 857 #define ld_targ_init_sparc ld32_targ_init_sparc
856 858 #define ld_targ_init_x86 ld32_targ_init_x86
857 859 #define ld_unwind_make_hdr ld32_unwind_make_hdr
858 860 #define ld_unwind_populate_hdr ld32_unwind_populate_hdr
859 861 #define ld_unwind_register ld32_unwind_register
860 862 #define ld_vers_base ld32_vers_base
861 863 #define ld_vers_check_defs ld32_vers_check_defs
862 864 #define ld_vers_check_need ld32_vers_check_need
863 865 #define ld_vers_def_process ld32_vers_def_process
864 866 #define ld_vers_desc ld32_vers_desc
865 867 #define ld_vers_find ld32_vers_find
866 868 #define ld_vers_need_process ld32_vers_need_process
867 869 #define ld_vers_promote ld32_vers_promote
868 870 #define ld_vers_sym_process ld32_vers_sym_process
869 871 #define ld_vers_verify ld32_vers_verify
870 872 #define ld_wrap_enter ld32_wrap_enter
871 873
872 874 #endif
873 875
874 876 extern void dbg_cleanup(void);
875 877 extern int dbg_setup(Ofl_desc *, const char *, int);
876 878
877 879 extern uintptr_t ld_add_actrel(Word, Rel_desc *, Ofl_desc *);
878 880 extern uintptr_t ld_add_libdir(Ofl_desc *, const char *);
879 881 extern void ld_adj_movereloc(Ofl_desc *, Rel_desc *);
880 882 extern Sym_desc * ld_am_I_partial(Rel_desc *, Xword);
881 883 extern void ld_ar_member(Ar_desc *, Elf_Arsym *, Ar_aux *,
882 884 Ar_mem *);
883 885 extern Ar_desc *ld_ar_setup(const char *, Elf *, Ofl_desc *);
884 886 extern uintptr_t ld_assign_got_TLS(Boolean, Rel_desc *, Ofl_desc *,
↓ open down ↓ |
87 lines elided |
↑ open up ↑ |
885 887 Sym_desc *, Gotndx *, Gotref, Word, Word,
886 888 Word, Word);
887 889
888 890 extern Word ld_bswap_Word(Word);
889 891 extern Xword ld_bswap_Xword(Xword);
890 892
891 893 extern uintptr_t ld_cap_add_family(Ofl_desc *, Sym_desc *, Sym_desc *,
892 894 Cap_group *, APlist **);
893 895 extern void ld_cap_move_symtoobj(Ofl_desc *);
894 896
897 +extern void ld_comdat_validate(Ofl_desc *, Ifl_desc *);
898 +
895 899 extern void ld_disp_errmsg(const char *, Rel_desc *, Ofl_desc *);
896 900
897 901 extern void ld_ent_check(Ofl_desc *);
898 902 extern Ent_desc *ld_ent_lookup(Ofl_desc *, const char *name,
899 903 avl_index_t *where);
900 904 extern void ld_eprintf(Ofl_desc *, Error, const char *, ...);
901 905 extern int ld_exit(Ofl_desc *);
902 906
903 907 extern uintptr_t ld_find_library(const char *, Ofl_desc *);
904 908 extern uintptr_t ld_finish_libs(Ofl_desc *);
905 909
906 910 extern const char *ld_stt_section_sym_name(Is_desc *);
907 911
908 912 extern Group_desc *ld_get_group(Ofl_desc *, Is_desc *);
909 913 extern uintptr_t ld_group_process(Is_desc *, Ofl_desc *);
910 914
911 915 extern uintptr_t ld_lib_setup(Ofl_desc *);
912 916
913 917 extern void ld_init_sighandler(Ofl_desc *);
914 918
915 919 extern Xword ld_lcm(Xword, Xword);
916 920
917 921 extern uintptr_t ld_make_bss(Ofl_desc *, Xword, Xword, uint_t);
918 922 extern Is_desc *ld_make_data(Ofl_desc *, size_t);
919 923 extern uintptr_t ld_make_got(Ofl_desc *);
920 924 extern uintptr_t ld_make_parexpn_data(Ofl_desc *, size_t, Xword);
921 925 extern uintptr_t ld_make_sunwmove(Ofl_desc *, int);
922 926 extern Is_desc *ld_make_text(Ofl_desc *, size_t);
923 927 extern void ld_map_out(Ofl_desc *);
924 928 extern Boolean ld_map_parse(const char *, Ofl_desc *);
925 929 extern Boolean ld_map_post_process(Ofl_desc *);
926 930
927 931 extern uintptr_t ld_open_outfile(Ofl_desc *);
928 932
929 933 extern Is_desc *ld_os_first_isdesc(Os_desc *);
930 934 extern Place_path_info *ld_place_path_info_init(Ofl_desc *, Ifl_desc *,
931 935 Place_path_info *);
932 936 extern Os_desc *ld_place_section(Ofl_desc *, Is_desc *,
933 937 Place_path_info *path_info, int, const char *);
934 938 extern Boolean ld_process_archive(const char *, int, Ar_desc *,
935 939 Ofl_desc *);
936 940 extern uintptr_t ld_process_files(Ofl_desc *, int, char **);
937 941 extern uintptr_t ld_process_flags(Ofl_desc *, int, char **);
938 942 extern uintptr_t ld_process_ifl(const char *, const char *, int, Elf *,
939 943 Word, Ofl_desc *, Rej_desc *, Ifl_desc **);
940 944 extern uintptr_t ld_process_move(Ofl_desc *);
941 945 extern uintptr_t ld_process_open(const char *, const char *, int *,
942 946 Ofl_desc *, Word, Rej_desc *, Ifl_desc **);
943 947 extern uintptr_t ld_process_ordered(Ofl_desc *, Ifl_desc *,
944 948 Place_path_info *path_info, Word);
945 949 extern uintptr_t ld_process_sym_reloc(Ofl_desc *, Rel_desc *, Rel *,
946 950 Is_desc *, const char *, Word);
947 951
948 952 extern Rel_desc *ld_reloc_enter(Ofl_desc *, Rel_cache *, Rel_desc *,
949 953 Word);
950 954 extern uintptr_t ld_reloc_GOT_relative(Boolean, Rel_desc *, Ofl_desc *);
951 955 extern uintptr_t ld_reloc_plt(Rel_desc *, Ofl_desc *);
952 956 extern void ld_reloc_remain_entry(Rel_desc *, Os_desc *,
953 957 Ofl_desc *, Boolean *);
954 958 extern Boolean ld_reloc_set_aux_osdesc(Ofl_desc *, Rel_desc *,
955 959 Os_desc *);
956 960 extern Boolean ld_reloc_set_aux_usym(Ofl_desc *, Rel_desc *,
957 961 Sym_desc *);
958 962
959 963 extern const char *ld_reloc_sym_name(Rel_desc *);
960 964 extern int ld_reloc_targval_get(Ofl_desc *, Rel_desc *,
961 965 uchar_t *, Xword *);
962 966 extern int ld_reloc_targval_set(Ofl_desc *, Rel_desc *,
963 967 uchar_t *, Xword);
964 968
965 969 extern Sg_desc *ld_seg_lookup(Ofl_desc *, const char *,
966 970 avl_index_t *where);
967 971 extern void ld_sec_validate(Ofl_desc *);
968 972 extern uintptr_t ld_sort_ordered(Ofl_desc *);
969 973 extern Half ld_sunw_ldmach();
970 974 extern void ld_sup_atexit(Ofl_desc *, int);
971 975 extern void ld_sup_open(Ofl_desc *, const char **, const char **,
972 976 int *, int, Elf **, Elf *ref, size_t,
973 977 const Elf_Kind);
974 978 extern void ld_sup_file(Ofl_desc *, const char *, const Elf_Kind,
975 979 int flags, Elf *);
976 980 extern uintptr_t ld_sup_loadso(Ofl_desc *, const char *);
977 981 extern void ld_sup_input_done(Ofl_desc *);
978 982 extern void ld_sup_section(Ofl_desc *, const char *, Shdr *, Word,
979 983 Elf_Data *, Elf *);
980 984 extern uintptr_t ld_sup_input_section(Ofl_desc*, Ifl_desc *,
981 985 const char *, Shdr **, Word, Elf_Scn *, Elf *);
982 986 extern void ld_sup_start(Ofl_desc *, const Half, const char *);
983 987 extern int ld_swap_reloc_data(Ofl_desc *, Rel_desc *);
984 988 extern Sym_desc *ld_sym_add_u(const char *, Ofl_desc *, Msg);
985 989 extern void ld_sym_adjust_vis(Sym_desc *, Ofl_desc *);
986 990 extern int ld_sym_avl_comp(const void *, const void *);
987 991 extern uintptr_t ld_sym_copy(Sym_desc *);
988 992 extern Sym_desc *ld_sym_enter(const char *, Sym *, Word, Ifl_desc *,
989 993 Ofl_desc *, Word, Word, sd_flag_t, avl_index_t *);
990 994 extern Sym_desc *ld_sym_find(const char *, Word, avl_index_t *,
991 995 Ofl_desc *);
992 996 extern uintptr_t ld_sym_nodirect(Is_desc *, Ifl_desc *, Ofl_desc *);
993 997 extern uintptr_t ld_sym_process(Is_desc *, Ifl_desc *, Ofl_desc *);
994 998 extern uintptr_t ld_sym_resolve(Sym_desc *, Sym *, Ifl_desc *,
995 999 Ofl_desc *, int, Word, sd_flag_t);
996 1000 extern uintptr_t ld_sym_spec(Ofl_desc *);
997 1001
998 1002 extern Target ld_targ;
999 1003 extern const Target *ld_targ_init_sparc(void);
1000 1004 extern const Target *ld_targ_init_x86(void);
1001 1005
1002 1006 extern uintptr_t ld_unwind_make_hdr(Ofl_desc *);
1003 1007 extern uintptr_t ld_unwind_populate_hdr(Ofl_desc *);
1004 1008 extern uintptr_t ld_unwind_register(Os_desc *, Ofl_desc *);
1005 1009
1006 1010 extern Ver_desc *ld_vers_base(Ofl_desc *);
1007 1011 extern uintptr_t ld_vers_check_defs(Ofl_desc *);
1008 1012 extern uintptr_t ld_vers_check_need(Ofl_desc *);
1009 1013 extern uintptr_t ld_vers_def_process(Is_desc *, Ifl_desc *, Ofl_desc *);
1010 1014 extern Ver_desc *ld_vers_desc(const char *, Word, APlist **);
1011 1015 extern Ver_desc *ld_vers_find(const char *, Word, APlist *);
1012 1016 extern uintptr_t ld_vers_need_process(Is_desc *, Ifl_desc *, Ofl_desc *);
1013 1017 extern void ld_vers_promote(Sym_desc *, Word, Ifl_desc *,
1014 1018 Ofl_desc *);
1015 1019 extern int ld_vers_sym_process(Ofl_desc *, Is_desc *, Ifl_desc *);
1016 1020 extern int ld_vers_verify(Ofl_desc *);
1017 1021 extern WrapSymNode *ld_wrap_enter(Ofl_desc *, const char *);
1018 1022
1019 1023 extern uintptr_t add_regsym(Sym_desc *, Ofl_desc *);
1020 1024 extern Word hashbkts(Word);
1021 1025 extern Xword lcm(Xword, Xword);
1022 1026
1023 1027 /*
1024 1028 * Most platforms have both a 32 and 64-bit variant (e.g. EM_SPARC and
1025 1029 * EM_SPARCV9). To support this, there many files in libld that are built
1026 1030 * twice, once for ELFCLASS64 (_ELF64), and once for ELFCLASS32. In these
1027 1031 * files, we sometimes want to supply one value for the ELFCLASS32 case
1028 1032 * and another for ELFCLASS64. The LD_TARG_BYCLASS macro is used to do
1029 1033 * this. It is called with both both alternatives, and yields the one
1030 1034 * that applies to the current compilation environment.
1031 1035 */
1032 1036 #ifdef _ELF64
1033 1037 #define LD_TARG_BYCLASS(_ec32, _ec64) (_ec64)
1034 1038 #else
1035 1039 #define LD_TARG_BYCLASS(_ec32, _ec64) (_ec32)
1036 1040 #endif
1037 1041
1038 1042
1039 1043 #ifdef __cplusplus
1040 1044 }
1041 1045 #endif
1042 1046
1043 1047 #endif /* _LIBLD_DOT_H */
↓ open down ↓ |
139 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX