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