17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55aefb655Srie * Common Development and Distribution License (the "License"). 65aefb655Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21c174926fSrie 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright (c) 1988 AT&T 247c478bd9Sstevel@tonic-gate * All Rights Reserved 257c478bd9Sstevel@tonic-gate * 26bb3b4f6cSRod Evans * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 277c478bd9Sstevel@tonic-gate * Use is subject to license terms. 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _LIBLD_H 317c478bd9Sstevel@tonic-gate #define _LIBLD_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <stdlib.h> 347c478bd9Sstevel@tonic-gate #include <libelf.h> 357c478bd9Sstevel@tonic-gate #include <sgs.h> 36ba2be530Sab196087 #include <_machelf.h> 377c478bd9Sstevel@tonic-gate #include <string_table.h> 387c478bd9Sstevel@tonic-gate #include <sys/avl.h> 397c478bd9Sstevel@tonic-gate #include <alist.h> 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #ifdef __cplusplus 427c478bd9Sstevel@tonic-gate extern "C" { 437c478bd9Sstevel@tonic-gate #endif 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* 467c478bd9Sstevel@tonic-gate * Default directory search path manipulation for the link-editor. YLDIR 477c478bd9Sstevel@tonic-gate * indicates which directory in LIBPATH is replaced by the -YL option to cc 487c478bd9Sstevel@tonic-gate * and ld. YUDIR indicates which directory is replaced by -YU. 497c478bd9Sstevel@tonic-gate */ 507c478bd9Sstevel@tonic-gate #define YLDIR 1 517c478bd9Sstevel@tonic-gate #define YUDIR 2 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate /* 547c478bd9Sstevel@tonic-gate * Define a hash value that can never be returned from elf_hash(). 557c478bd9Sstevel@tonic-gate */ 567c478bd9Sstevel@tonic-gate #define SYM_NOHASH (~(Word)0) 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate /* 59240e56feSab196087 * Macro that can be used to represent both ORDER flags 60240e56feSab196087 * in a section header. 617c478bd9Sstevel@tonic-gate */ 627c478bd9Sstevel@tonic-gate #define ALL_SHF_ORDER (SHF_ORDERED | SHF_LINK_ORDER) 63240e56feSab196087 64240e56feSab196087 /* 65240e56feSab196087 * The linker merges (concatenates) sections with the same name and 66240e56feSab196087 * compatible section header flags. When comparing these flags, 67240e56feSab196087 * there are some that should not be included in the decision. 68240e56feSab196087 * The ALL_SHF_IGNORE constant defines these flags. 69240e56feSab196087 * 70240e56feSab196087 * NOTE: SHF_MERGE|SHF_STRINGS: 71240e56feSab196087 * The compiler is allowed to set the SHF_MERGE|SHF_STRINGS flags in 72240e56feSab196087 * order to tell the linker that: 73240e56feSab196087 * 74240e56feSab196087 * 1) There is nothing in the section except null terminated strings. 75cce0e03bSab196087 * 2) Those strings do not contain NULL bytes, except as termination. 76cce0e03bSab196087 * 3) All references to these strings occur via standard relocation 77cce0e03bSab196087 * records. 78cce0e03bSab196087 * 79cce0e03bSab196087 * As a result, if two compatible sections both have these flags set, it is 80cce0e03bSab196087 * OK to combine the strings they contain into a single merged string table 81cce0e03bSab196087 * with duplicates removed and tail strings merged. 82240e56feSab196087 * 83240e56feSab196087 * This is a different meaning than the simple concatenating of sections 84240e56feSab196087 * that the linker always does. It is a hint that an additional optimization 85240e56feSab196087 * is possible, but not required. This means that sections that do not 86cce0e03bSab196087 * share the same SHF_MERGE|SHF_STRINGS values can be concatenated, 87cce0e03bSab196087 * but cannot have their duplicate strings combined. Hence, the 88cce0e03bSab196087 * SHF_MERGE|SHF_STRINGS flags should be ignored when deciding whether 89cce0e03bSab196087 * two sections can be concatenated. 90240e56feSab196087 */ 91240e56feSab196087 #define ALL_SHF_IGNORE (ALL_SHF_ORDER | SHF_GROUP | SHF_MERGE | SHF_STRINGS) 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * Define symbol reference types for use in symbol resolution. 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate typedef enum { 977c478bd9Sstevel@tonic-gate REF_DYN_SEEN, /* a .so symbol has been seen */ 987c478bd9Sstevel@tonic-gate REF_DYN_NEED, /* a .so symbol satisfies a .o symbol */ 997c478bd9Sstevel@tonic-gate REF_REL_NEED, /* a .o symbol */ 1007c478bd9Sstevel@tonic-gate REF_NUM /* the number of symbol references */ 1017c478bd9Sstevel@tonic-gate } Symref; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * GOT reference models 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate typedef enum { 1077c478bd9Sstevel@tonic-gate GOT_REF_GENERIC, /* generic symbol reference */ 1087c478bd9Sstevel@tonic-gate GOT_REF_TLSIE, /* TLS initial exec (gnu) reference */ 1097c478bd9Sstevel@tonic-gate GOT_REF_TLSLD, /* TLS local dynamic reference */ 1107c478bd9Sstevel@tonic-gate GOT_REF_TLSGD /* TLS general dynamic reference */ 1117c478bd9Sstevel@tonic-gate } Gotref; 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate typedef struct { 1147c478bd9Sstevel@tonic-gate Xword gn_addend; /* addend associated with GOT entry */ 1157c478bd9Sstevel@tonic-gate Sword gn_gotndx; /* GOT table index */ 1167c478bd9Sstevel@tonic-gate Gotref gn_gotref; 1177c478bd9Sstevel@tonic-gate } Gotndx; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate /* 1207c478bd9Sstevel@tonic-gate * Got debugging structure. The got index is defined as a signed value as we 1217c478bd9Sstevel@tonic-gate * do so much mucking around with negative and positive gots on SPARC, and sign 1227c478bd9Sstevel@tonic-gate * extension is necessary when building 64-bit objects. On intel we explicitly 1237c478bd9Sstevel@tonic-gate * cast this variable to an unsigned value. 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate typedef struct { 1267c478bd9Sstevel@tonic-gate Sym_desc *gt_sym; 1277c478bd9Sstevel@tonic-gate Gotndx gt_gndx; 1287c478bd9Sstevel@tonic-gate } Gottable; 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate /* 1316b3ba5bdSAli Bahrami * The link-editor caches the results of sloppy relocation processing 13240e53e87SAli Bahrami * in a variable of type Rlxrel_cache. Symbols come for processing in sorted 13340e53e87SAli Bahrami * order, so a single item cache suffices to eliminate duplicate lookups. 13440e53e87SAli Bahrami * 13540e53e87SAli Bahrami * When sloppy relocation processing fails, the Rlxrel_rej enum reports 13640e53e87SAli Bahrami * the underlying reason. 1376b3ba5bdSAli Bahrami */ 13840e53e87SAli Bahrami typedef enum { 13940e53e87SAli Bahrami RLXREL_REJ_NONE = 0, /* Replacement symbol was found */ 14040e53e87SAli Bahrami RLXREL_REJ_TARGET, /* Target sec disallows relaxed relocations */ 14140e53e87SAli Bahrami RLXREL_REJ_SECTION, /* Either there is no replacement section, */ 14240e53e87SAli Bahrami /* or its attributes are incompatible */ 14340e53e87SAli Bahrami RLXREL_REJ_SYMBOL, /* Replacement symbol not found */ 14440e53e87SAli Bahrami } Rlxrel_rej; 14540e53e87SAli Bahrami 1466b3ba5bdSAli Bahrami typedef struct sreloc_cache { 1476b3ba5bdSAli Bahrami Sym_desc *sr_osdp; /* Original symbol */ 1486b3ba5bdSAli Bahrami Sym_desc *sr_rsdp; /* Replacement symbol */ 14940e53e87SAli Bahrami Rlxrel_rej sr_rej; /* Reason for failure if NULL sr_rsdp */ 15040e53e87SAli Bahrami } Rlxrel_cache; 1516b3ba5bdSAli Bahrami 1526b3ba5bdSAli Bahrami /* 153*cdcc71c0SAli Bahrami * Nodes in an ofl_wrap AVL tree 154*cdcc71c0SAli Bahrami * 155*cdcc71c0SAli Bahrami * wsn_name is the name of the symbol to be wrapped. wsn_wrapname is used 156*cdcc71c0SAli Bahrami * when we need to refer to the wrap symbol, and consists of the symbol 157*cdcc71c0SAli Bahrami * name with a __wrap_ prefix. 158*cdcc71c0SAli Bahrami */ 159*cdcc71c0SAli Bahrami typedef struct wrap_sym_node { 160*cdcc71c0SAli Bahrami avl_node_t wsn_avlnode; /* AVL book-keeping */ 161*cdcc71c0SAli Bahrami const char *wsn_name; /* Symbol name: XXX */ 162*cdcc71c0SAli Bahrami const char *wsn_wrapname; /* Wrap symbol name: __wrap_XXX */ 163*cdcc71c0SAli Bahrami } WrapSymNode; 164*cdcc71c0SAli Bahrami 165*cdcc71c0SAli Bahrami 166*cdcc71c0SAli Bahrami /* 1677c478bd9Sstevel@tonic-gate * Output file processing structure 1687c478bd9Sstevel@tonic-gate */ 1691d9df23bSab196087 typedef Lword ofl_flag_t; 1707c478bd9Sstevel@tonic-gate struct ofl_desc { 1717c478bd9Sstevel@tonic-gate char *ofl_sgsid; /* link-editor identification */ 1727c478bd9Sstevel@tonic-gate const char *ofl_name; /* full file name */ 1737c478bd9Sstevel@tonic-gate Elf *ofl_elf; /* elf_memory() elf descriptor */ 1747c478bd9Sstevel@tonic-gate Elf *ofl_welf; /* ELF_C_WRITE elf descriptor */ 1755aefb655Srie Ehdr *ofl_dehdr; /* default elf header, and new elf */ 1765aefb655Srie Ehdr *ofl_nehdr; /* header describing this file */ 1777c478bd9Sstevel@tonic-gate Phdr *ofl_phdr; /* program header descriptor */ 1787c478bd9Sstevel@tonic-gate Phdr *ofl_tlsphdr; /* TLS phdr */ 1797c478bd9Sstevel@tonic-gate int ofl_fd; /* file descriptor */ 1807c478bd9Sstevel@tonic-gate size_t ofl_size; /* image size */ 18157ef7aa9SRod Evans APlist *ofl_maps; /* list of input mapfiles */ 18257ef7aa9SRod Evans APlist *ofl_segs; /* list of segments */ 18357ef7aa9SRod Evans Alist *ofl_ents; /* list of entrance descriptors */ 18457ef7aa9SRod Evans APlist *ofl_objs; /* relocatable object file list */ 1857c478bd9Sstevel@tonic-gate Word ofl_objscnt; /* and count */ 18657ef7aa9SRod Evans APlist *ofl_ars; /* archive library list */ 1877c478bd9Sstevel@tonic-gate Word ofl_arscnt; /* and count */ 188551cffe3SAli Bahrami int ofl_ars_gsandx; /* archive group argv index. 0 means */ 189551cffe3SAli Bahrami /* no current group, < 0 means */ 190551cffe3SAli Bahrami /* error reported. >0 is cur ndx */ 191551cffe3SAli Bahrami Word ofl_ars_gsndx; /* current -zrescan-start ofl_ars ndx */ 19257ef7aa9SRod Evans APlist *ofl_sos; /* shared object list */ 1937c478bd9Sstevel@tonic-gate Word ofl_soscnt; /* and count */ 19457ef7aa9SRod Evans APlist *ofl_soneed; /* list of implicitly required .so's */ 19557ef7aa9SRod Evans APlist *ofl_socntl; /* list of .so control definitions */ 19657ef7aa9SRod Evans APlist *ofl_outrels; /* list of output relocations */ 1977c478bd9Sstevel@tonic-gate Word ofl_outrelscnt; /* and count */ 19857ef7aa9SRod Evans APlist *ofl_actrels; /* list of relocations to perform */ 1997c478bd9Sstevel@tonic-gate Word ofl_actrelscnt; /* and count */ 200c174926fSrie Word ofl_entrelscnt; /* no of relocations entered */ 20157ef7aa9SRod Evans Alist *ofl_copyrels; /* list of copy relocations */ 20257ef7aa9SRod Evans APlist *ofl_ordered; /* list of shf_ordered sections */ 20357ef7aa9SRod Evans APlist *ofl_syminfsyms; /* list of interesting syms */ 2047c478bd9Sstevel@tonic-gate /* for syminfo processing */ 20557ef7aa9SRod Evans APlist *ofl_ismove; /* list of .SUNW_move sections */ 20657ef7aa9SRod Evans APlist *ofl_ismoverel; /* list of relocation input section */ 2077c478bd9Sstevel@tonic-gate /* targeting to expanded area */ 20857ef7aa9SRod Evans APlist *ofl_parsyms; /* list of partially initialized */ 20957ef7aa9SRod Evans /* symbols (ie. move symbols) */ 21057ef7aa9SRod Evans APlist *ofl_extrarels; /* relocation sections which have */ 2117c478bd9Sstevel@tonic-gate /* a NULL sh_info */ 212cc7efc4fSrie avl_tree_t *ofl_groups; /* pointer to head of Groups AVL tree */ 21357ef7aa9SRod Evans APlist *ofl_initarray; /* list of init array func names */ 21457ef7aa9SRod Evans APlist *ofl_finiarray; /* list of fini array func names */ 21557ef7aa9SRod Evans APlist *ofl_preiarray; /* list of preinit array func names */ 21657ef7aa9SRod Evans APlist *ofl_rtldinfo; /* list of rtldinfo syms */ 21757ef7aa9SRod Evans APlist *ofl_osgroups; /* list of output GROUP sections */ 21857ef7aa9SRod Evans APlist *ofl_ostlsseg; /* pointer to sections in TLS segment */ 2197e16fca0SAli Bahrami APlist *ofl_unwind; /* list of unwind output sections */ 2207c478bd9Sstevel@tonic-gate Os_desc *ofl_unwindhdr; /* Unwind hdr */ 2217c478bd9Sstevel@tonic-gate avl_tree_t ofl_symavl; /* pointer to head of Syms AVL tree */ 2227c478bd9Sstevel@tonic-gate Sym_desc **ofl_regsyms; /* array of potential register */ 2237c478bd9Sstevel@tonic-gate Word ofl_regsymsno; /* symbols and array count */ 2247c478bd9Sstevel@tonic-gate Word ofl_regsymcnt; /* no. of output register symbols */ 2257c478bd9Sstevel@tonic-gate Word ofl_lregsymcnt; /* no. of local register symbols */ 2267c478bd9Sstevel@tonic-gate Sym_desc *ofl_dtracesym; /* ld -zdtrace= */ 2271d9df23bSab196087 ofl_flag_t ofl_flags; /* various state bits, args etc. */ 2281d9df23bSab196087 ofl_flag_t ofl_flags1; /* more flags */ 2297c478bd9Sstevel@tonic-gate void *ofl_entry; /* entry point (-e and Sym_desc *) */ 2307c478bd9Sstevel@tonic-gate char *ofl_filtees; /* shared objects we are a filter for */ 2317c478bd9Sstevel@tonic-gate const char *ofl_soname; /* (-h option) output file name for */ 2327c478bd9Sstevel@tonic-gate /* dynamic structure */ 2337c478bd9Sstevel@tonic-gate const char *ofl_interp; /* interpreter name used by exec() */ 2347c478bd9Sstevel@tonic-gate char *ofl_rpath; /* run path to store in .dynamic */ 2357c478bd9Sstevel@tonic-gate char *ofl_config; /* config path to store in .dynamic */ 23657ef7aa9SRod Evans APlist *ofl_ulibdirs; /* user supplied library search list */ 23757ef7aa9SRod Evans APlist *ofl_dlibdirs; /* default library search list */ 2387c478bd9Sstevel@tonic-gate Word ofl_vercnt; /* number of versions to generate */ 23957ef7aa9SRod Evans APlist *ofl_verdesc; /* list of version descriptors */ 2407c478bd9Sstevel@tonic-gate size_t ofl_verdefsz; /* size of version definition section */ 2417c478bd9Sstevel@tonic-gate size_t ofl_verneedsz; /* size of version needed section */ 2427c478bd9Sstevel@tonic-gate Word ofl_entercnt; /* no. of global symbols entered */ 2437c478bd9Sstevel@tonic-gate Word ofl_globcnt; /* no. of global symbols to output */ 2447c478bd9Sstevel@tonic-gate Word ofl_scopecnt; /* no. of scoped symbols to output */ 2459039eeafSab196087 Word ofl_dynscopecnt; /* no. scoped syms in .SUNW_ldynsym */ 2467c478bd9Sstevel@tonic-gate Word ofl_elimcnt; /* no. of eliminated symbols */ 2479039eeafSab196087 Word ofl_locscnt; /* no. of local symbols in .symtab */ 2489039eeafSab196087 Word ofl_dynlocscnt; /* no. local symbols in .SUNW_ldynsym */ 249d579eb63Sab196087 Word ofl_dynsymsortcnt; /* no. ndx in .SUNW_dynsymsort */ 250d579eb63Sab196087 Word ofl_dyntlssortcnt; /* no. ndx in .SUNW_dyntlssort */ 2517c478bd9Sstevel@tonic-gate Word ofl_dynshdrcnt; /* no. of output section in .dynsym */ 2527c478bd9Sstevel@tonic-gate Word ofl_shdrcnt; /* no. of output sections */ 2537c478bd9Sstevel@tonic-gate Str_tbl *ofl_shdrsttab; /* Str_tbl for shdr strtab */ 2547c478bd9Sstevel@tonic-gate Str_tbl *ofl_strtab; /* Str_tbl for symtab strtab */ 2557c478bd9Sstevel@tonic-gate Str_tbl *ofl_dynstrtab; /* Str_tbl for dymsym strtab */ 2567c478bd9Sstevel@tonic-gate Gotndx *ofl_tlsldgotndx; /* index to LD TLS_index structure */ 2577c478bd9Sstevel@tonic-gate Xword ofl_relocsz; /* size of output relocations */ 2587c478bd9Sstevel@tonic-gate Xword ofl_relocgotsz; /* size of .got relocations */ 2597c478bd9Sstevel@tonic-gate Xword ofl_relocpltsz; /* size of .plt relocations */ 2607c478bd9Sstevel@tonic-gate Xword ofl_relocbsssz; /* size of .bss (copy) relocations */ 2617c478bd9Sstevel@tonic-gate Xword ofl_relocrelsz; /* size of .rel[a] relocations */ 2627c478bd9Sstevel@tonic-gate Word ofl_relocincnt; /* no. of input relocations */ 2637c478bd9Sstevel@tonic-gate Word ofl_reloccnt; /* tot number of output relocations */ 2647c478bd9Sstevel@tonic-gate Word ofl_reloccntsub; /* tot numb of output relocations to */ 2657c478bd9Sstevel@tonic-gate /* skip (-zignore) */ 2667c478bd9Sstevel@tonic-gate Word ofl_relocrelcnt; /* tot number of relative */ 2677c478bd9Sstevel@tonic-gate /* relocations */ 2687c478bd9Sstevel@tonic-gate Word ofl_gotcnt; /* no. of .got entries */ 2697c478bd9Sstevel@tonic-gate Word ofl_pltcnt; /* no. of .plt entries */ 2707c478bd9Sstevel@tonic-gate Word ofl_pltpad; /* no. of .plt padd entries */ 2717c478bd9Sstevel@tonic-gate Word ofl_hashbkts; /* no. of hash buckets required */ 2727c478bd9Sstevel@tonic-gate Is_desc *ofl_isbss; /* .bss input section (globals) */ 27354d82594Sseizo Is_desc *ofl_islbss; /* .lbss input section (globals) */ 2747c478bd9Sstevel@tonic-gate Is_desc *ofl_istlsbss; /* .tlsbss input section (globals) */ 27535450702SAli Bahrami Is_desc *ofl_isparexpn; /* -z nopartial .data input section */ 2767c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynamic; /* .dynamic output section */ 2777c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynsym; /* .dynsym output section */ 2789039eeafSab196087 Os_desc *ofl_osldynsym; /* .SUNW_ldynsym output section */ 2797c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynstr; /* .dynstr output section */ 280d579eb63Sab196087 Os_desc *ofl_osdynsymsort; /* .SUNW_dynsymsort output section */ 281d579eb63Sab196087 Os_desc *ofl_osdyntlssort; /* .SUNW_dyntlssort output section */ 2827c478bd9Sstevel@tonic-gate Os_desc *ofl_osgot; /* .got output section */ 2837c478bd9Sstevel@tonic-gate Os_desc *ofl_oshash; /* .hash output section */ 2847c478bd9Sstevel@tonic-gate Os_desc *ofl_osinitarray; /* .initarray output section */ 2857c478bd9Sstevel@tonic-gate Os_desc *ofl_osfiniarray; /* .finiarray output section */ 2867c478bd9Sstevel@tonic-gate Os_desc *ofl_ospreinitarray; /* .preinitarray output section */ 2877c478bd9Sstevel@tonic-gate Os_desc *ofl_osinterp; /* .interp output section */ 2887c478bd9Sstevel@tonic-gate Os_desc *ofl_oscap; /* .SUNW_cap output section */ 2897c478bd9Sstevel@tonic-gate Os_desc *ofl_osplt; /* .plt output section */ 2907c478bd9Sstevel@tonic-gate Os_desc *ofl_osmove; /* .SUNW_move output section */ 2917c478bd9Sstevel@tonic-gate Os_desc *ofl_osrelhead; /* first relocation section */ 2927c478bd9Sstevel@tonic-gate Os_desc *ofl_osrel; /* .rel[a] relocation section */ 2937c478bd9Sstevel@tonic-gate Os_desc *ofl_osshstrtab; /* .shstrtab output section */ 2947c478bd9Sstevel@tonic-gate Os_desc *ofl_osstrtab; /* .strtab output section */ 2957c478bd9Sstevel@tonic-gate Os_desc *ofl_ossymtab; /* .symtab output section */ 2967c478bd9Sstevel@tonic-gate Os_desc *ofl_ossymshndx; /* .symtab_shndx output section */ 2977c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynshndx; /* .dynsym_shndx output section */ 2989039eeafSab196087 Os_desc *ofl_osldynshndx; /* .SUNW_ldynsym_shndx output sec */ 2997c478bd9Sstevel@tonic-gate Os_desc *ofl_osverdef; /* .version definition output section */ 3007c478bd9Sstevel@tonic-gate Os_desc *ofl_osverneed; /* .version needed output section */ 3017c478bd9Sstevel@tonic-gate Os_desc *ofl_osversym; /* .version symbol ndx output section */ 3027c478bd9Sstevel@tonic-gate Word ofl_dtflags_1; /* DT_FLAGS_1 entries */ 3037c478bd9Sstevel@tonic-gate Word ofl_dtflags; /* DT_FLAGS entries */ 3047c478bd9Sstevel@tonic-gate Os_desc *ofl_ossyminfo; /* .SUNW_syminfo output section */ 30535450702SAli Bahrami Half ofl_parexpnndx; /* -z nopartial section index */ 3067c478bd9Sstevel@tonic-gate /* Ref. at perform_outreloc() in */ 3077c478bd9Sstevel@tonic-gate /* libld/{mach}/machrel.c */ 3087c478bd9Sstevel@tonic-gate Xword *ofl_checksum; /* DT_CHECKSUM value address */ 3097c478bd9Sstevel@tonic-gate char *ofl_depaudit; /* dependency auditing required (-P) */ 3107c478bd9Sstevel@tonic-gate char *ofl_audit; /* object auditing required (-p) */ 3117c478bd9Sstevel@tonic-gate Alist *ofl_symfltrs; /* per-symbol filtees and their */ 3127c478bd9Sstevel@tonic-gate Alist *ofl_dtsfltrs; /* associated .dynamic/.dynstrs */ 3137c478bd9Sstevel@tonic-gate Xword ofl_hwcap_1; /* hardware capabilities */ 3147c478bd9Sstevel@tonic-gate Xword ofl_sfcap_1; /* software capabilities */ 3155aefb655Srie Lm_list *ofl_lml; /* runtime link-map list */ 316d326b23bSrie Gottable *ofl_gottable; /* debugging got information */ 31740e53e87SAli Bahrami Rlxrel_cache ofl_sr_cache; /* Cache last result from */ 3186b3ba5bdSAli Bahrami /* sloppy_comdat_reloc() */ 31957ef7aa9SRod Evans APlist *ofl_maptext; /* mapfile added text sections */ 32057ef7aa9SRod Evans APlist *ofl_mapdata; /* mapfile added data sections */ 321*cdcc71c0SAli Bahrami avl_tree_t *ofl_wrap; /* -z wrap symbols */ 3227c478bd9Sstevel@tonic-gate }; 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate #define FLG_OF_DYNAMIC 0x00000001 /* generate dynamic output module */ 3257c478bd9Sstevel@tonic-gate #define FLG_OF_STATIC 0x00000002 /* generate static output module */ 3267c478bd9Sstevel@tonic-gate #define FLG_OF_EXEC 0x00000004 /* generate an executable */ 3277c478bd9Sstevel@tonic-gate #define FLG_OF_RELOBJ 0x00000008 /* generate a relocatable object */ 3287c478bd9Sstevel@tonic-gate #define FLG_OF_SHAROBJ 0x00000010 /* generate a shared object */ 3297c478bd9Sstevel@tonic-gate #define FLG_OF_BFLAG 0x00000020 /* do no special plt building: -b */ 3307c478bd9Sstevel@tonic-gate #define FLG_OF_IGNENV 0x00000040 /* ignore LD_LIBRARY_PATH: -i */ 3317c478bd9Sstevel@tonic-gate #define FLG_OF_STRIP 0x00000080 /* strip output: -s */ 3327c478bd9Sstevel@tonic-gate #define FLG_OF_NOWARN 0x00000100 /* disable symbol warnings: -t */ 3337c478bd9Sstevel@tonic-gate #define FLG_OF_NOUNDEF 0x00000200 /* allow no undefined symbols: -zdefs */ 3347c478bd9Sstevel@tonic-gate #define FLG_OF_PURETXT 0x00000400 /* allow no text relocations: -ztext */ 3357c478bd9Sstevel@tonic-gate #define FLG_OF_GENMAP 0x00000800 /* generate a memory map: -m */ 3367c478bd9Sstevel@tonic-gate #define FLG_OF_DYNLIBS 0x00001000 /* dynamic input allowed: -Bdynamic */ 3377c478bd9Sstevel@tonic-gate #define FLG_OF_SYMBOLIC 0x00002000 /* bind global symbols: -Bsymbolic */ 3387c478bd9Sstevel@tonic-gate #define FLG_OF_ADDVERS 0x00004000 /* add version stamp: -Qy */ 3399039eeafSab196087 #define FLG_OF_NOLDYNSYM 0x00008000 /* -znoldynsym set */ 3407c478bd9Sstevel@tonic-gate #define FLG_OF_SEGORDER 0x00010000 /* segment ordering is required */ 3417c478bd9Sstevel@tonic-gate #define FLG_OF_SEGSORT 0x00020000 /* segment sorting is required */ 3427c478bd9Sstevel@tonic-gate #define FLG_OF_TEXTREL 0x00040000 /* text relocations have been found */ 3437c478bd9Sstevel@tonic-gate #define FLG_OF_MULDEFS 0x00080000 /* multiple symbols are allowed */ 344dd94ecefSrie #define FLG_OF_TLSPHDR 0x00100000 /* a TLS program header is required */ 3457c478bd9Sstevel@tonic-gate #define FLG_OF_BLDGOT 0x00200000 /* build GOT table */ 3467c478bd9Sstevel@tonic-gate #define FLG_OF_VERDEF 0x00400000 /* record version definitions */ 3477c478bd9Sstevel@tonic-gate #define FLG_OF_VERNEED 0x00800000 /* record version dependencies */ 3487c478bd9Sstevel@tonic-gate #define FLG_OF_NOVERSEC 0x01000000 /* don't record version sections */ 3490e233487SRod Evans #define FLG_OF_KEY 0x02000000 /* file requires sort keys */ 3507c478bd9Sstevel@tonic-gate #define FLG_OF_PROCRED 0x04000000 /* process any symbol reductions by */ 3517c478bd9Sstevel@tonic-gate /* effecting the symbol table */ 3527c478bd9Sstevel@tonic-gate /* output and relocations */ 3537c478bd9Sstevel@tonic-gate #define FLG_OF_SYMINFO 0x08000000 /* create a syminfo section */ 3547c478bd9Sstevel@tonic-gate #define FLG_OF_AUX 0x10000000 /* ofl_filter is an auxiliary filter */ 3557c478bd9Sstevel@tonic-gate #define FLG_OF_FATAL 0x20000000 /* fatal error during input */ 3567c478bd9Sstevel@tonic-gate #define FLG_OF_WARN 0x40000000 /* warning during input processing. */ 3577c478bd9Sstevel@tonic-gate #define FLG_OF_VERBOSE 0x80000000 /* -z verbose flag set */ 3587c478bd9Sstevel@tonic-gate 3599a411307Srie #define FLG_OF_MAPSYMB 0x000100000000 /* symbolic scope definition seen */ 3609a411307Srie #define FLG_OF_MAPGLOB 0x000200000000 /* global scope definition seen */ 361e38a713aSrie #define FLG_OF_COMREL 0x000400000000 /* -z combreloc set, which enables */ 362e38a713aSrie /* DT_RELACNT tracking, */ 363e38a713aSrie #define FLG_OF_NOCOMREL 0x000800000000 /* -z nocombreloc set */ 36444bac77bSrie #define FLG_OF_AUTOLCL 0x001000000000 /* automatically reduce unspecified */ 36544bac77bSrie /* global symbols to locals */ 36644bac77bSrie #define FLG_OF_AUTOELM 0x002000000000 /* automatically eliminate */ 36744bac77bSrie /* unspecified global symbols */ 36844bac77bSrie #define FLG_OF_REDLSYM 0x004000000000 /* reduce local symbols */ 3690e233487SRod Evans #define FLG_OF_SECORDER 0x008000000000 /* section ordering is required */ 3704f680cc6SAli Bahrami #define FLG_OF_OSABI 0x010000000000 /* Tag object as ELFOSABI_SOLARIS */ 3719a411307Srie 3727c478bd9Sstevel@tonic-gate /* 3737c478bd9Sstevel@tonic-gate * In the flags1 arena, establish any options that are applicable to archive 3747c478bd9Sstevel@tonic-gate * extraction first, and associate a mask. These values are recorded with any 3757c478bd9Sstevel@tonic-gate * archive descriptor so that they may be reset should the archive require a 3767c478bd9Sstevel@tonic-gate * rescan to try and resolve undefined symbols. 3777c478bd9Sstevel@tonic-gate */ 3787c478bd9Sstevel@tonic-gate #define FLG_OF1_ALLEXRT 0x00000001 /* extract all members from an */ 3797c478bd9Sstevel@tonic-gate /* archive file */ 3807c478bd9Sstevel@tonic-gate #define FLG_OF1_WEAKEXT 0x00000002 /* allow archive extraction to */ 3817c478bd9Sstevel@tonic-gate /* resolve weak references */ 38270d3e49eSrie #define MSK_OF1_ARCHIVE 0x00000003 /* archive flags mask */ 3837c478bd9Sstevel@tonic-gate 38470d3e49eSrie #define FLG_OF1_NOINTRP 0x00000008 /* -z nointerp flag set */ 3857c478bd9Sstevel@tonic-gate #define FLG_OF1_ZDIRECT 0x00000010 /* -z direct flag set */ 3867c478bd9Sstevel@tonic-gate #define FLG_OF1_NDIRECT 0x00000020 /* no-direct bindings specified */ 3877c478bd9Sstevel@tonic-gate #define FLG_OF1_OVHWCAP 0x00000040 /* override any input hardware or */ 3887c478bd9Sstevel@tonic-gate #define FLG_OF1_OVSFCAP 0x00000080 /* software capabilities */ 3897c478bd9Sstevel@tonic-gate #define FLG_OF1_RELDYN 0x00000100 /* process .dynamic in rel obj */ 3900e233487SRod Evans #define FLG_OF1_NRLXREL 0x00000200 /* -z norelaxreloc flag set */ 3910e233487SRod Evans #define FLG_OF1_RLXREL 0x00000400 /* -z relaxreloc flag set */ 3927c478bd9Sstevel@tonic-gate #define FLG_OF1_IGNORE 0x00000800 /* ignore unused dependencies */ 393e38a713aSrie 39456e2cc86SAli Bahrami #define FLG_OF1_NOSGHND 0x00001000 /* -z nosighandler flag set */ 3957c478bd9Sstevel@tonic-gate #define FLG_OF1_TEXTOFF 0x00002000 /* text relocations are ok */ 3967c478bd9Sstevel@tonic-gate #define FLG_OF1_ABSEXEC 0x00004000 /* -zabsexec set */ 3977c478bd9Sstevel@tonic-gate #define FLG_OF1_LAZYLD 0x00008000 /* lazy loading of objects enabled */ 3987c478bd9Sstevel@tonic-gate #define FLG_OF1_GRPPRM 0x00010000 /* dependencies are to have */ 3997c478bd9Sstevel@tonic-gate /* GROUPPERM enabled */ 4007c478bd9Sstevel@tonic-gate #define FLG_OF1_OVRFLW 0x00020000 /* size exceeds 32-bit limitation */ 4017c478bd9Sstevel@tonic-gate /* of 32-bit libld */ 4027c478bd9Sstevel@tonic-gate #define FLG_OF1_NOPARTI 0x00040000 /* -znopartial set */ 4037c478bd9Sstevel@tonic-gate #define FLG_OF1_BSSOREL 0x00080000 /* output relocation against bss */ 4047c478bd9Sstevel@tonic-gate /* section */ 4057c478bd9Sstevel@tonic-gate #define FLG_OF1_TLSOREL 0x00100000 /* output relocation against .tlsbss */ 4067c478bd9Sstevel@tonic-gate /* section */ 4079039eeafSab196087 #define FLG_OF1_MEMORY 0x00200000 /* produce a memory model */ 40828bda19cSRod Evans #define FLG_OF1_NGLBDIR 0x00400000 /* no DT_1_DIRECT flag allowed */ 409f3324781Sab196087 #define FLG_OF1_ENCDIFF 0x00800000 /* Host running linker has different */ 410f3324781Sab196087 /* byte order than output object */ 41157ef7aa9SRod Evans #define FLG_OF1_VADDR 0x01000000 /* user segment defines a vaddr */ 4127c478bd9Sstevel@tonic-gate #define FLG_OF1_EXTRACT 0x02000000 /* archive member has been extracted */ 4137c478bd9Sstevel@tonic-gate #define FLG_OF1_RESCAN 0x04000000 /* any archives should be rescanned */ 4147c478bd9Sstevel@tonic-gate #define FLG_OF1_IGNPRC 0x08000000 /* ignore processing required */ 4157c478bd9Sstevel@tonic-gate #define FLG_OF1_NCSTTAB 0x10000000 /* -znocompstrtab set */ 4167c478bd9Sstevel@tonic-gate #define FLG_OF1_DONE 0x20000000 /* link-editor processing complete */ 4177c478bd9Sstevel@tonic-gate #define FLG_OF1_NONREG 0x40000000 /* non-regular file specified as */ 4187c478bd9Sstevel@tonic-gate /* the output file */ 4197c478bd9Sstevel@tonic-gate #define FLG_OF1_ALNODIR 0x80000000 /* establish NODIRECT for all */ 4207c478bd9Sstevel@tonic-gate /* exported interfaces. */ 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate /* 4239039eeafSab196087 * Test to see if the output file would allow the presence of 4249039eeafSab196087 * a .dynsym section. 4259039eeafSab196087 */ 426f3324781Sab196087 #define OFL_ALLOW_DYNSYM(_ofl) (((_ofl)->ofl_flags & \ 4279039eeafSab196087 (FLG_OF_DYNAMIC | FLG_OF_RELOBJ)) == FLG_OF_DYNAMIC) 4289039eeafSab196087 4299039eeafSab196087 /* 4309039eeafSab196087 * Test to see if the output file would allow the presence of 4319039eeafSab196087 * a .SUNW_ldynsym section. The requirements are that a .dynsym 4329039eeafSab196087 * is allowed, and -znoldynsym has not been specified. Note that 4339039eeafSab196087 * even if the answer is True (1), we will only generate one if there 4349039eeafSab196087 * are local symbols that require it. 4359039eeafSab196087 */ 436f3324781Sab196087 #define OFL_ALLOW_LDYNSYM(_ofl) (((_ofl)->ofl_flags & \ 4379039eeafSab196087 (FLG_OF_DYNAMIC | FLG_OF_RELOBJ | FLG_OF_NOLDYNSYM)) == FLG_OF_DYNAMIC) 4389039eeafSab196087 4399039eeafSab196087 /* 440f3324781Sab196087 * Test to see if relocation processing should be done. This is normally 441f3324781Sab196087 * true, but can be disabled via the '-z noreloc' option. Note that 442f3324781Sab196087 * relocatable objects are still relocated even if '-z noreloc' is present. 443f3324781Sab196087 */ 444f3324781Sab196087 #define OFL_DO_RELOC(_ofl) (((_ofl)->ofl_flags & FLG_OF_RELOBJ) || \ 445f3324781Sab196087 !((_ofl)->ofl_dtflags_1 & DF_1_NORELOC)) 446f3324781Sab196087 447f3324781Sab196087 /* 44857ef7aa9SRod Evans * Define a move descriptor used within relocation structures. 44957ef7aa9SRod Evans */ 45057ef7aa9SRod Evans typedef struct { 45157ef7aa9SRod Evans Move *mr_move; 45257ef7aa9SRod Evans Sym_desc *mr_sym; 45357ef7aa9SRod Evans } Mv_reloc; 45457ef7aa9SRod Evans 45557ef7aa9SRod Evans /* 4567c478bd9Sstevel@tonic-gate * Relocation (active & output) processing structure - transparent to common 4577c478bd9Sstevel@tonic-gate * code. 458cce0e03bSab196087 * 459cce0e03bSab196087 * Note that rel_raddend is primarily only of interest to RELA relocations, 460cce0e03bSab196087 * and is set to 0 for REL. However, there is an exception: If FLG_REL_NADDEND 461cce0e03bSab196087 * is set, then rel_raddend contains a replacement value for the implicit 462cce0e03bSab196087 * addend found in the relocation target. 4637c478bd9Sstevel@tonic-gate */ 4647c478bd9Sstevel@tonic-gate struct rel_desc { 4657c478bd9Sstevel@tonic-gate Os_desc *rel_osdesc; /* output section reloc is against */ 4667c478bd9Sstevel@tonic-gate Is_desc *rel_isdesc; /* input section reloc is against */ 4677c478bd9Sstevel@tonic-gate const char *rel_sname; /* symbol name (may be "unknown") */ 4687c478bd9Sstevel@tonic-gate Sym_desc *rel_sym; /* sym relocation is against */ 4697c478bd9Sstevel@tonic-gate Sym_desc *rel_usym; /* strong sym if this is a weak pair */ 47057ef7aa9SRod Evans Mv_reloc *rel_move; /* move table information */ 4717c478bd9Sstevel@tonic-gate Word rel_flags; /* misc. flags for relocations */ 4727c478bd9Sstevel@tonic-gate Word rel_rtype; /* relocation type */ 4737c478bd9Sstevel@tonic-gate Xword rel_roffset; /* relocation offset */ 4747c478bd9Sstevel@tonic-gate Sxword rel_raddend; /* addend from input relocation */ 4757c478bd9Sstevel@tonic-gate Word rel_typedata; /* ELF_R_TYPE_DATA(info) */ 4767c478bd9Sstevel@tonic-gate }; 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* 4797c478bd9Sstevel@tonic-gate * common flags used on the Rel_desc structure (defined in machrel.h). 4807c478bd9Sstevel@tonic-gate */ 4817c478bd9Sstevel@tonic-gate #define FLG_REL_GOT 0x00000001 /* relocation against GOT */ 4827c478bd9Sstevel@tonic-gate #define FLG_REL_PLT 0x00000002 /* relocation against PLT */ 4837c478bd9Sstevel@tonic-gate #define FLG_REL_BSS 0x00000004 /* relocation against BSS */ 4847c478bd9Sstevel@tonic-gate #define FLG_REL_LOAD 0x00000008 /* section loadable */ 4857c478bd9Sstevel@tonic-gate #define FLG_REL_SCNNDX 0x00000010 /* use section index for symbol ndx */ 4867c478bd9Sstevel@tonic-gate #define FLG_REL_CLVAL 0x00000020 /* clear VALUE for active relocation */ 4877c478bd9Sstevel@tonic-gate #define FLG_REL_ADVAL 0x00000040 /* add VALUE for output relocation, */ 48863360950Smp204432 /* only relevant to SPARC and */ 4897c478bd9Sstevel@tonic-gate /* R_SPARC_RELATIVE */ 4907c478bd9Sstevel@tonic-gate #define FLG_REL_GOTCL 0x00000080 /* clear the GOT entry. This is */ 4917c478bd9Sstevel@tonic-gate /* relevant to RELA relocations, */ 4927c478bd9Sstevel@tonic-gate /* not REL (i386) relocations */ 4937c478bd9Sstevel@tonic-gate #define FLG_REL_MOVETAB 0x00000100 /* Relocation against .SUNW_move */ 4947c478bd9Sstevel@tonic-gate /* adjustments required before */ 4957c478bd9Sstevel@tonic-gate /* actual relocation */ 4967c478bd9Sstevel@tonic-gate #define FLG_REL_NOINFO 0x00000200 /* Relocation comes from a section */ 4977c478bd9Sstevel@tonic-gate /* with a null sh_info field */ 4987c478bd9Sstevel@tonic-gate #define FLG_REL_REG 0x00000400 /* Relocation target is reg sym */ 4997c478bd9Sstevel@tonic-gate #define FLG_REL_FPTR 0x00000800 /* relocation against func. desc. */ 5007c478bd9Sstevel@tonic-gate #define FLG_REL_RFPTR1 0x00001000 /* Relative relocation against */ 5017c478bd9Sstevel@tonic-gate /* 1st part of FD */ 5027c478bd9Sstevel@tonic-gate #define FLG_REL_RFPTR2 0x00002000 /* Relative relocation against */ 5037c478bd9Sstevel@tonic-gate /* 2nd part of FD */ 5047c478bd9Sstevel@tonic-gate #define FLG_REL_DISP 0x00004000 /* *disp* relocation */ 5057c478bd9Sstevel@tonic-gate #define FLG_REL_STLS 0x00008000 /* IE TLS reference to */ 5067c478bd9Sstevel@tonic-gate /* static TLS GOT index */ 5077c478bd9Sstevel@tonic-gate #define FLG_REL_DTLS 0x00010000 /* GD TLS reference relative to */ 5087c478bd9Sstevel@tonic-gate /* dynamic TLS GOT index */ 5097c478bd9Sstevel@tonic-gate #define FLG_REL_MTLS 0x00020000 /* LD TLS reference against GOT */ 5107c478bd9Sstevel@tonic-gate #define FLG_REL_STTLS 0x00040000 /* LE TLS reference directly */ 5117c478bd9Sstevel@tonic-gate /* to static tls index */ 5127c478bd9Sstevel@tonic-gate #define FLG_REL_TLSFIX 0x00080000 /* relocation points to TLS instr. */ 5137c478bd9Sstevel@tonic-gate /* which needs updating */ 51457ef7aa9SRod Evans #define FLG_REL_RELA 0x00100000 /* descriptor captures a Rela */ 5157c478bd9Sstevel@tonic-gate #define FLG_REL_GOTFIX 0x00200000 /* relocation points to GOTOP instr. */ 5167c478bd9Sstevel@tonic-gate /* which needs updating */ 517cce0e03bSab196087 #define FLG_REL_NADDEND 0x00400000 /* Replace implicit addend in dest */ 518cce0e03bSab196087 /* with value in rel_raddend */ 519cce0e03bSab196087 /* Relevant to REL (i386) */ 520cce0e03bSab196087 /* relocations, not to RELA. */ 5217c478bd9Sstevel@tonic-gate 5227c478bd9Sstevel@tonic-gate /* 5237c478bd9Sstevel@tonic-gate * Structure to hold a cache of Relocations. 5247c478bd9Sstevel@tonic-gate */ 5257c478bd9Sstevel@tonic-gate struct rel_cache { 5267c478bd9Sstevel@tonic-gate Rel_desc *rc_end; 5277c478bd9Sstevel@tonic-gate Rel_desc *rc_free; 5287c478bd9Sstevel@tonic-gate }; 5297c478bd9Sstevel@tonic-gate 5307c478bd9Sstevel@tonic-gate /* 5317c478bd9Sstevel@tonic-gate * Symbol value descriptor. For relocatable objects, each symbols value is 5327c478bd9Sstevel@tonic-gate * its offset within its associated section. Therefore, to uniquely define 5337c478bd9Sstevel@tonic-gate * each symbol within a reloctable object, record and sort the sh_offset and 5347c478bd9Sstevel@tonic-gate * symbol value. This information is used to seach for displacement 5357c478bd9Sstevel@tonic-gate * relocations as part of copy relocation validation. 5367c478bd9Sstevel@tonic-gate */ 5377c478bd9Sstevel@tonic-gate typedef struct { 5387c478bd9Sstevel@tonic-gate Addr ssv_value; 5397c478bd9Sstevel@tonic-gate Sym_desc *ssv_sdp; 5407c478bd9Sstevel@tonic-gate } Ssv_desc; 5417c478bd9Sstevel@tonic-gate 5427c478bd9Sstevel@tonic-gate /* 5437c478bd9Sstevel@tonic-gate * Input file processing structures. 5447c478bd9Sstevel@tonic-gate */ 5457c478bd9Sstevel@tonic-gate struct ifl_desc { /* input file descriptor */ 5467c478bd9Sstevel@tonic-gate const char *ifl_name; /* full file name */ 5477c478bd9Sstevel@tonic-gate const char *ifl_soname; /* shared object name */ 5487c478bd9Sstevel@tonic-gate dev_t ifl_stdev; /* device id and inode number for .so */ 5497c478bd9Sstevel@tonic-gate ino_t ifl_stino; /* multiple inclusion checks */ 5507c478bd9Sstevel@tonic-gate Ehdr *ifl_ehdr; /* elf header describing this file */ 5517c478bd9Sstevel@tonic-gate Elf *ifl_elf; /* elf descriptor for this file */ 5527c478bd9Sstevel@tonic-gate Sym_desc **ifl_oldndx; /* original symbol table indices */ 5537c478bd9Sstevel@tonic-gate Sym_desc *ifl_locs; /* symbol desc version of locals */ 5547c478bd9Sstevel@tonic-gate Ssv_desc *ifl_sortsyms; /* sorted list of symbols by value */ 5557c478bd9Sstevel@tonic-gate Word ifl_locscnt; /* no. of local symbols to process */ 5567c478bd9Sstevel@tonic-gate Word ifl_symscnt; /* total no. of symbols to process */ 5577c478bd9Sstevel@tonic-gate Word ifl_sortcnt; /* no. of sorted symbols to process */ 5587c478bd9Sstevel@tonic-gate Word ifl_shnum; /* number of sections in file */ 5597c478bd9Sstevel@tonic-gate Word ifl_shstrndx; /* index to .shstrtab */ 5607c478bd9Sstevel@tonic-gate Word ifl_vercnt; /* number of versions in file */ 56157ef7aa9SRod Evans Half ifl_neededndx; /* index to NEEDED in .dyn section */ 56228bda19cSRod Evans Word ifl_flags; /* explicit/implicit reference */ 5637c478bd9Sstevel@tonic-gate Is_desc **ifl_isdesc; /* isdesc[scn ndx] = Is_desc ptr */ 5647c478bd9Sstevel@tonic-gate Sdf_desc *ifl_sdfdesc; /* control definition */ 5657c478bd9Sstevel@tonic-gate Versym *ifl_versym; /* version symbol table array */ 5667c478bd9Sstevel@tonic-gate Ver_index *ifl_verndx; /* verndx[ver ndx] = Ver_index */ 56757ef7aa9SRod Evans APlist *ifl_verdesc; /* version descriptor list */ 56857ef7aa9SRod Evans APlist *ifl_relsect; /* relocation section list */ 569cc7efc4fSrie Alist *ifl_groups; /* SHT_GROUP section list */ 5707c478bd9Sstevel@tonic-gate }; 5717c478bd9Sstevel@tonic-gate 572d840867fSab196087 #define FLG_IF_CMDLINE 0x00000001 /* full filename specified from the */ 5737c478bd9Sstevel@tonic-gate /* command line (no -l) */ 574d840867fSab196087 #define FLG_IF_NEEDED 0x00000002 /* shared object should be recorded */ 575d840867fSab196087 #define FLG_IF_DIRECT 0x00000004 /* establish direct bindings to this */ 5767c478bd9Sstevel@tonic-gate /* object */ 577d840867fSab196087 #define FLG_IF_EXTRACT 0x00000008 /* file extracted from an archive */ 578d840867fSab196087 #define FLG_IF_VERNEED 0x00000010 /* version dependency information is */ 5797c478bd9Sstevel@tonic-gate /* required */ 580d840867fSab196087 #define FLG_IF_DEPREQD 0x00000020 /* dependency is required to satisfy */ 5817c478bd9Sstevel@tonic-gate /* symbol references */ 582d840867fSab196087 #define FLG_IF_NEEDSTR 0x00000040 /* dependency specified by -Nn */ 5837c478bd9Sstevel@tonic-gate /* flag */ 584d840867fSab196087 #define FLG_IF_IGNORE 0x00000080 /* ignore unused dependencies */ 585d840867fSab196087 #define FLG_IF_NODIRECT 0x00000100 /* object contains symbols that */ 5867c478bd9Sstevel@tonic-gate /* cannot be directly bound to. */ 587d840867fSab196087 #define FLG_IF_LAZYLD 0x00000200 /* bindings to this object should be */ 5887c478bd9Sstevel@tonic-gate /* lazy loaded */ 589d840867fSab196087 #define FLG_IF_GRPPRM 0x00000400 /* this dependency should have the */ 5907c478bd9Sstevel@tonic-gate /* DF_P1_GROUPPERM flag set */ 591d840867fSab196087 #define FLG_IF_DISPPEND 0x00000800 /* displacement relocation done */ 5927c478bd9Sstevel@tonic-gate /* in the ld time. */ 593d840867fSab196087 #define FLG_IF_DISPDONE 0x00001000 /* displacement relocation done */ 5947c478bd9Sstevel@tonic-gate /* at the run time */ 595d840867fSab196087 #define FLG_IF_MAPFILE 0x00002000 /* file is a mapfile */ 596d840867fSab196087 #define FLG_IF_HSTRTAB 0x00004000 /* file has a string section */ 597d840867fSab196087 #define FLG_IF_FILEREF 0x00008000 /* file contains a section which */ 5987c478bd9Sstevel@tonic-gate /* is included in the output */ 5997c478bd9Sstevel@tonic-gate /* allocatable image */ 600d840867fSab196087 #define FLG_IF_GNUVER 0x00010000 /* file used GNU-style versioning */ 6010e233487SRod Evans #define FLG_IF_ORDERED 0x00020000 /* ordered section processing */ 6020e233487SRod Evans /* required */ 6037c478bd9Sstevel@tonic-gate 6047c478bd9Sstevel@tonic-gate struct is_desc { /* input section descriptor */ 6050e233487SRod Evans const char *is_name; /* original section name */ 6067c478bd9Sstevel@tonic-gate Shdr *is_shdr; /* the elf section header */ 6077c478bd9Sstevel@tonic-gate Ifl_desc *is_file; /* infile desc for this section */ 6087c478bd9Sstevel@tonic-gate Os_desc *is_osdesc; /* new output section for this */ 6097c478bd9Sstevel@tonic-gate /* input section */ 6107c478bd9Sstevel@tonic-gate Elf_Data *is_indata; /* input sections raw data */ 6117c478bd9Sstevel@tonic-gate Is_desc *is_symshndx; /* related SHT_SYM_SHNDX section */ 6126b3ba5bdSAli Bahrami Is_desc *is_comdatkeep; /* If COMDAT section is discarded, */ 6136b3ba5bdSAli Bahrami /* this is section that was kept */ 6147c478bd9Sstevel@tonic-gate Word is_scnndx; /* original section index in file */ 61557ef7aa9SRod Evans Word is_ordndx; /* Index for section. Used to decide */ 6167c478bd9Sstevel@tonic-gate /* where to insert section when */ 6177c478bd9Sstevel@tonic-gate /* reordering sections */ 6181dd9d86fSAli Bahrami Word is_keyident; /* key for SHF_{ORDERED|LINK_ORDER} */ 6191dd9d86fSAli Bahrami /* processing and ident used for */ 6200e233487SRod Evans /* placing/ordering sections */ 6210e233487SRod Evans Word is_flags; /* Various flags */ 6227c478bd9Sstevel@tonic-gate }; 6237c478bd9Sstevel@tonic-gate 6240e233487SRod Evans #define FLG_IS_ORDERED 0x0001 /* this is a SHF_ORDERED section */ 6250e233487SRod Evans #define FLG_IS_KEY 0x0002 /* section requires sort keys */ 6267c478bd9Sstevel@tonic-gate #define FLG_IS_DISCARD 0x0004 /* section is to be discarded */ 6277c478bd9Sstevel@tonic-gate #define FLG_IS_RELUPD 0x0008 /* symbol defined here may have moved */ 6287c478bd9Sstevel@tonic-gate #define FLG_IS_SECTREF 0x0010 /* section has been referenced */ 6297c478bd9Sstevel@tonic-gate #define FLG_IS_GDATADEF 0x0020 /* section contains global data sym */ 63054d82594Sseizo #define FLG_IS_EXTERNAL 0x0040 /* isp from an user file */ 631cce0e03bSab196087 #define FLG_IS_INSTRMRG 0x0080 /* Usable SHF_MERGE|SHF_STRINGS sec */ 632cce0e03bSab196087 #define FLG_IS_GNSTRMRG 0x0100 /* Generated mergeable string section */ 6330e233487SRod Evans #define FLG_IS_GROUPS 0x0200 /* section has groups to process */ 6340e233487SRod Evans #define FLG_IS_PLACE 0x0400 /* section requires to be placed */ 6350e233487SRod Evans #define FLG_IS_COMDAT 0x0800 /* section is COMDAT */ 6367e16fca0SAli Bahrami #define FLG_IS_EHFRAME 0x1000 /* section is .eh_frame */ 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate /* 6391dd9d86fSAli Bahrami * Output sections contain lists of input sections that are assigned to them. 6401dd9d86fSAli Bahrami * These items fall into 4 categories: 6411dd9d86fSAli Bahrami * BEFORE - Ordered sections that specify SHN_BEFORE, in input order. 6421dd9d86fSAli Bahrami * ORDERED - Ordered sections that are sorted using unsorted sections 6431dd9d86fSAli Bahrami * as the sort key. 6441dd9d86fSAli Bahrami * DEFAULT - Sections that are placed into the output section 6451dd9d86fSAli Bahrami * in input order. 6461dd9d86fSAli Bahrami * AFTER - Ordered sections that specify SHN_AFTER, in input order. 6471dd9d86fSAli Bahrami */ 6481dd9d86fSAli Bahrami #define OS_ISD_BEFORE 0 6491dd9d86fSAli Bahrami #define OS_ISD_ORDERED 1 6501dd9d86fSAli Bahrami #define OS_ISD_DEFAULT 2 6511dd9d86fSAli Bahrami #define OS_ISD_AFTER 3 6521dd9d86fSAli Bahrami #define OS_ISD_NUM 4 6531dd9d86fSAli Bahrami typedef APlist *os_isdecs_arr[OS_ISD_NUM]; 6541dd9d86fSAli Bahrami 6551dd9d86fSAli Bahrami /* 6561dd9d86fSAli Bahrami * Convenience macro for traversing every input section associated 6571dd9d86fSAli Bahrami * with a given output section. The primary benefit of this macro 6581dd9d86fSAli Bahrami * is that it preserves a precious level of code indentation in the 6591dd9d86fSAli Bahrami * code that uses it. 6601dd9d86fSAli Bahrami */ 6611dd9d86fSAli Bahrami #define OS_ISDESCS_TRAVERSE(_list_idx, _osp, _idx, _isp) \ 6621dd9d86fSAli Bahrami for (_list_idx = 0; _list_idx < OS_ISD_NUM; _list_idx++) \ 6631dd9d86fSAli Bahrami for (APLIST_TRAVERSE(_osp->os_isdescs[_list_idx], _idx, _isp)) 6641dd9d86fSAli Bahrami 6651dd9d86fSAli Bahrami 6661dd9d86fSAli Bahrami /* 6677c478bd9Sstevel@tonic-gate * Map file and output file processing structures 6687c478bd9Sstevel@tonic-gate */ 6697c478bd9Sstevel@tonic-gate struct os_desc { /* Output section descriptor */ 6707c478bd9Sstevel@tonic-gate const char *os_name; /* the section name */ 6717c478bd9Sstevel@tonic-gate Elf_Scn *os_scn; /* the elf section descriptor */ 6727c478bd9Sstevel@tonic-gate Shdr *os_shdr; /* the elf section header */ 6737c478bd9Sstevel@tonic-gate Os_desc *os_relosdesc; /* the output relocation section */ 6746b3ba5bdSAli Bahrami APlist *os_relisdescs; /* reloc input section descriptors */ 6757c478bd9Sstevel@tonic-gate /* for this output section */ 6761dd9d86fSAli Bahrami os_isdecs_arr os_isdescs; /* lists of input sections in output */ 677cce0e03bSab196087 APlist *os_mstrisdescs; /* FLG_IS_INSTRMRG input sections */ 6787c478bd9Sstevel@tonic-gate Sg_desc *os_sgdesc; /* segment os_desc is placed on */ 6797c478bd9Sstevel@tonic-gate Elf_Data *os_outdata; /* output sections raw data */ 6806b3ba5bdSAli Bahrami avl_tree_t *os_comdats; /* AVL tree of COMDAT input sections */ 6816b3ba5bdSAli Bahrami /* associated to output section */ 68257ef7aa9SRod Evans Word os_identndx; /* section identifier for input */ 68357ef7aa9SRod Evans /* section processing, followed */ 68457ef7aa9SRod Evans /* by section symbol index */ 68557ef7aa9SRod Evans Word os_ordndx; /* index for section. Used to decide */ 6867c478bd9Sstevel@tonic-gate /* where to insert section when */ 6877c478bd9Sstevel@tonic-gate /* reordering sections */ 6887c478bd9Sstevel@tonic-gate Xword os_szoutrels; /* size of output relocation section */ 6897c478bd9Sstevel@tonic-gate uint_t os_namehash; /* hash on section name */ 6907c478bd9Sstevel@tonic-gate uchar_t os_flags; /* various flags */ 6917c478bd9Sstevel@tonic-gate }; 6927c478bd9Sstevel@tonic-gate 6930e233487SRod Evans #define FLG_OS_KEY 0x01 /* section requires sort keys */ 6947c478bd9Sstevel@tonic-gate #define FLG_OS_OUTREL 0x02 /* output rel against this section */ 695dd94ecefSrie #define FLG_OS_SECTREF 0x04 /* isps are not affected by -zignore */ 6967c478bd9Sstevel@tonic-gate 6977c478bd9Sstevel@tonic-gate /* 69857ef7aa9SRod Evans * Types of segment index. 69957ef7aa9SRod Evans */ 70057ef7aa9SRod Evans typedef enum { 70157ef7aa9SRod Evans LD_PHDR, 70257ef7aa9SRod Evans LD_INTERP, 70357ef7aa9SRod Evans LD_SUNWCAP, 70457ef7aa9SRod Evans LD_TEXT, 70557ef7aa9SRod Evans LD_DATA, 70657ef7aa9SRod Evans LD_BSS, 70757ef7aa9SRod Evans #if defined(_ELF64) 70857ef7aa9SRod Evans LD_LRODATA, /* (amd64-only) */ 70957ef7aa9SRod Evans LD_LDATA, /* (amd64-only) */ 71057ef7aa9SRod Evans #endif 71157ef7aa9SRod Evans LD_DYN, 71257ef7aa9SRod Evans LD_DTRACE, 71357ef7aa9SRod Evans LD_TLS, 71457ef7aa9SRod Evans LD_UNWIND, 71557ef7aa9SRod Evans LD_NOTE, 71657ef7aa9SRod Evans LD_EXTRA, 71757ef7aa9SRod Evans LD_NUM 71857ef7aa9SRod Evans } Segment_id; 71957ef7aa9SRod Evans 7207c478bd9Sstevel@tonic-gate struct sg_desc { /* output segment descriptor */ 72157ef7aa9SRod Evans Segment_id sg_id; /* segment identifier (for sorting) */ 7227c478bd9Sstevel@tonic-gate Phdr sg_phdr; /* segment header for output file */ 7237c478bd9Sstevel@tonic-gate const char *sg_name; /* segment name */ 7247c478bd9Sstevel@tonic-gate Xword sg_round; /* data rounding required (mapfile) */ 7257c478bd9Sstevel@tonic-gate Xword sg_length; /* maximum segment length; if 0 */ 7267c478bd9Sstevel@tonic-gate /* segment is not specified */ 727cce0e03bSab196087 APlist *sg_osdescs; /* list of output section descriptors */ 728cce0e03bSab196087 APlist *sg_secorder; /* list specifying section ordering */ 7290bc07c75Srie /* for the segment */ 7307c478bd9Sstevel@tonic-gate Half sg_flags; 7317c478bd9Sstevel@tonic-gate Sym_desc *sg_sizesym; /* size symbol for this segment */ 7327c478bd9Sstevel@tonic-gate Xword sg_addralign; /* LCM of sh_addralign */ 7337c478bd9Sstevel@tonic-gate Elf_Scn *sg_fscn; /* the SCN of the first section. */ 7347c478bd9Sstevel@tonic-gate }; 7357c478bd9Sstevel@tonic-gate 7367c478bd9Sstevel@tonic-gate #define FLG_SG_VADDR 0x0001 /* vaddr segment attribute set */ 7377c478bd9Sstevel@tonic-gate #define FLG_SG_PADDR 0x0002 /* paddr segment attribute set */ 7387c478bd9Sstevel@tonic-gate #define FLG_SG_LENGTH 0x0004 /* length segment attribute set */ 7397c478bd9Sstevel@tonic-gate #define FLG_SG_ALIGN 0x0008 /* align segment attribute set */ 7407c478bd9Sstevel@tonic-gate #define FLG_SG_ROUND 0x0010 /* round segment attribute set */ 7417c478bd9Sstevel@tonic-gate #define FLG_SG_FLAGS 0x0020 /* flags segment attribute set */ 7427c478bd9Sstevel@tonic-gate #define FLG_SG_TYPE 0x0040 /* type segment attribute set */ 7437c478bd9Sstevel@tonic-gate #define FLG_SG_ORDER 0x0080 /* has ordering been turned on for */ 7447c478bd9Sstevel@tonic-gate /* this segment. */ 7457c478bd9Sstevel@tonic-gate /* i.e. ?[O] option in mapfile */ 7467c478bd9Sstevel@tonic-gate #define FLG_SG_NOHDR 0x0100 /* don't map ELF or phdrs into */ 7477c478bd9Sstevel@tonic-gate /* this segment */ 7487c478bd9Sstevel@tonic-gate #define FLG_SG_EMPTY 0x0200 /* an empty segment specification */ 7497c478bd9Sstevel@tonic-gate /* no input sections will be */ 7507c478bd9Sstevel@tonic-gate /* associated to this section */ 7510e233487SRod Evans #define FLG_SG_KEY 0x0400 /* segment requires sort keys */ 7527c478bd9Sstevel@tonic-gate #define FLG_SG_DISABLED 0x0800 /* this segment is disabled */ 75354d82594Sseizo #define FLG_SG_PHREQ 0x1000 /* this segment requires a program */ 75454d82594Sseizo /* header */ 7557c478bd9Sstevel@tonic-gate 7567c478bd9Sstevel@tonic-gate struct sec_order { 7577c478bd9Sstevel@tonic-gate const char *sco_secname; /* section name to be ordered */ 7587c478bd9Sstevel@tonic-gate Word sco_index; /* ordering index for section */ 7597c478bd9Sstevel@tonic-gate Half sco_flags; 7607c478bd9Sstevel@tonic-gate }; 7617c478bd9Sstevel@tonic-gate 7627c478bd9Sstevel@tonic-gate #define FLG_SGO_USED 0x0001 /* was ordering used? */ 7637c478bd9Sstevel@tonic-gate 7647c478bd9Sstevel@tonic-gate struct ent_desc { /* input section entrance criteria */ 76557ef7aa9SRod Evans APlist *ec_files; /* files from which to accept */ 7667c478bd9Sstevel@tonic-gate /* sections */ 7677c478bd9Sstevel@tonic-gate const char *ec_name; /* name to match (NULL if none) */ 7687c478bd9Sstevel@tonic-gate Word ec_type; /* section type */ 76954d82594Sseizo Word ec_attrmask; /* section attribute mask (AWX) */ 77054d82594Sseizo Word ec_attrbits; /* sections attribute bits */ 7717c478bd9Sstevel@tonic-gate Sg_desc *ec_segment; /* output segment to enter if matched */ 77257ef7aa9SRod Evans Word ec_ordndx; /* index to determine where section */ 7737c478bd9Sstevel@tonic-gate /* meeting this criteria should */ 7747c478bd9Sstevel@tonic-gate /* inserted. Used for reordering */ 7757c478bd9Sstevel@tonic-gate /* of sections. */ 7767c478bd9Sstevel@tonic-gate Half ec_flags; 7777c478bd9Sstevel@tonic-gate }; 7787c478bd9Sstevel@tonic-gate 779e23c41c9SAli Bahrami #define FLG_EC_BUILTIN 0x0001 /* built in descriptor */ 780e23c41c9SAli Bahrami #define FLG_EC_USED 0x0002 /* entrance criteria met? */ 7817c478bd9Sstevel@tonic-gate 7827c478bd9Sstevel@tonic-gate /* 78357ef7aa9SRod Evans * One structure is allocated for a move entry, and associated to the symbol 78457ef7aa9SRod Evans * against which a move is targeted. 7857c478bd9Sstevel@tonic-gate */ 78657ef7aa9SRod Evans typedef struct { 78757ef7aa9SRod Evans Move *md_move; /* original Move entry */ 78857ef7aa9SRod Evans Xword md_start; /* start position */ 78957ef7aa9SRod Evans Xword md_len; /* length of initialization */ 79057ef7aa9SRod Evans Word md_oidx; /* output Move entry index */ 79157ef7aa9SRod Evans } Mv_desc; 7927c478bd9Sstevel@tonic-gate 7937c478bd9Sstevel@tonic-gate /* 79457ef7aa9SRod Evans * Symbol descriptor. 7957c478bd9Sstevel@tonic-gate */ 7967c478bd9Sstevel@tonic-gate struct sym_desc { 79757ef7aa9SRod Evans Alist *sd_GOTndxs; /* list of associated GOT entries */ 7987c478bd9Sstevel@tonic-gate Sym *sd_sym; /* pointer to symbol table entry */ 7997c478bd9Sstevel@tonic-gate Sym *sd_osym; /* copy of the original symbol entry */ 800d326b23bSrie /* used only for local partial */ 80157ef7aa9SRod Evans Alist *sd_move; /* move information associated with a */ 80257ef7aa9SRod Evans /* partially initialized symbol */ 8037c478bd9Sstevel@tonic-gate const char *sd_name; /* symbols name */ 8047c478bd9Sstevel@tonic-gate Ifl_desc *sd_file; /* file where symbol is taken */ 8057c478bd9Sstevel@tonic-gate Is_desc *sd_isc; /* input section of symbol definition */ 8067c478bd9Sstevel@tonic-gate Sym_aux *sd_aux; /* auxiliary global symbol info. */ 8077c478bd9Sstevel@tonic-gate Word sd_symndx; /* index in output symbol table */ 8087c478bd9Sstevel@tonic-gate Word sd_shndx; /* sect. index sym is associated w/ */ 8097c478bd9Sstevel@tonic-gate Word sd_flags; /* state flags */ 8107c478bd9Sstevel@tonic-gate Half sd_flags1; /* more symbol flags */ 8117c478bd9Sstevel@tonic-gate Half sd_ref; /* reference definition of symbol */ 8127c478bd9Sstevel@tonic-gate }; 8137c478bd9Sstevel@tonic-gate 8147c478bd9Sstevel@tonic-gate /* 8157c478bd9Sstevel@tonic-gate * The auxiliary symbol descriptor contains the additional information (beyond 8167c478bd9Sstevel@tonic-gate * the symbol descriptor) required to process global symbols. These symbols are 8177c478bd9Sstevel@tonic-gate * accessed via an internal symbol hash table where locality of reference is 8187c478bd9Sstevel@tonic-gate * important for performance. 8197c478bd9Sstevel@tonic-gate */ 8207c478bd9Sstevel@tonic-gate struct sym_aux { 82157ef7aa9SRod Evans APlist *sa_dfiles; /* files where symbol is defined */ 8227c478bd9Sstevel@tonic-gate Sym sa_sym; /* copy of symtab entry */ 8237c478bd9Sstevel@tonic-gate const char *sa_vfile; /* first unavailable definition */ 8247c478bd9Sstevel@tonic-gate Ifl_desc *sa_bindto; /* symbol to bind to - for translator */ 8257c478bd9Sstevel@tonic-gate const char *sa_rfile; /* file with first symbol referenced */ 8267c478bd9Sstevel@tonic-gate Word sa_hash; /* the pure hash value of symbol */ 8277c478bd9Sstevel@tonic-gate Word sa_PLTndx; /* index into PLT for symbol */ 8287c478bd9Sstevel@tonic-gate Word sa_PLTGOTndx; /* GOT entry indx for PLT indirection */ 829d579eb63Sab196087 Word sa_linkndx; /* index of associated symbol from */ 830d579eb63Sab196087 /* ET_DYN file */ 8317c478bd9Sstevel@tonic-gate Half sa_symspec; /* special symbol ids */ 8327c478bd9Sstevel@tonic-gate Half sa_overndx; /* output file versioning index */ 8337c478bd9Sstevel@tonic-gate Half sa_dverndx; /* dependency versioning index */ 8347c478bd9Sstevel@tonic-gate }; 8357c478bd9Sstevel@tonic-gate 8367c478bd9Sstevel@tonic-gate /* 8377c478bd9Sstevel@tonic-gate * Nodes used to track symbols in the global AVL symbol dictionary. 8387c478bd9Sstevel@tonic-gate */ 8397c478bd9Sstevel@tonic-gate struct sym_avlnode { 8407c478bd9Sstevel@tonic-gate avl_node_t sav_node; /* AVL node */ 8417c478bd9Sstevel@tonic-gate Word sav_hash; /* symbol hash value */ 8427c478bd9Sstevel@tonic-gate const char *sav_name; /* symbol name */ 8437c478bd9Sstevel@tonic-gate Sym_desc *sav_symdesc; /* SymDesc entry */ 8447c478bd9Sstevel@tonic-gate }; 8457c478bd9Sstevel@tonic-gate 8467c478bd9Sstevel@tonic-gate /* 8477c478bd9Sstevel@tonic-gate * These are the ids for processing of `Special symbols'. They are used 8487c478bd9Sstevel@tonic-gate * to set the sym->sd_aux->sa_symspec field. 8497c478bd9Sstevel@tonic-gate */ 8507c478bd9Sstevel@tonic-gate #define SDAUX_ID_ETEXT 1 /* etext && _etext symbol */ 8517c478bd9Sstevel@tonic-gate #define SDAUX_ID_EDATA 2 /* edata && _edata symbol */ 8527c478bd9Sstevel@tonic-gate #define SDAUX_ID_END 3 /* end, _end, && _END_ symbol */ 8537c478bd9Sstevel@tonic-gate #define SDAUX_ID_DYN 4 /* DYNAMIC && _DYNAMIC symbol */ 8547c478bd9Sstevel@tonic-gate #define SDAUX_ID_PLT 5 /* _PROCEDURE_LINKAGE_TABLE_ symbol */ 8557c478bd9Sstevel@tonic-gate #define SDAUX_ID_GOT 6 /* _GLOBAL_OFFSET_TABLE_ symbol */ 8567c478bd9Sstevel@tonic-gate #define SDAUX_ID_START 7 /* START_ && _START_ symbol */ 8577c478bd9Sstevel@tonic-gate 8587c478bd9Sstevel@tonic-gate /* 8597c478bd9Sstevel@tonic-gate * Flags for sym_desc.sd_flags 8607c478bd9Sstevel@tonic-gate */ 8617c478bd9Sstevel@tonic-gate #define FLG_SY_MVTOCOMM 0x00000001 /* assign symbol to common (.bss) */ 8627c478bd9Sstevel@tonic-gate /* this is a result of a */ 8637c478bd9Sstevel@tonic-gate /* copy reloc against sym */ 8647c478bd9Sstevel@tonic-gate #define FLG_SY_GLOBREF 0x00000002 /* a global reference has been seen */ 8657c478bd9Sstevel@tonic-gate #define FLG_SY_WEAKDEF 0x00000004 /* a weak definition has been used */ 8667c478bd9Sstevel@tonic-gate #define FLG_SY_CLEAN 0x00000008 /* `Sym' entry points to original */ 8677c478bd9Sstevel@tonic-gate /* input file (read-only). */ 8687c478bd9Sstevel@tonic-gate #define FLG_SY_UPREQD 0x00000010 /* symbol value update is required, */ 8697c478bd9Sstevel@tonic-gate /* either it's used as an entry */ 8707c478bd9Sstevel@tonic-gate /* point or for relocation, but */ 8717c478bd9Sstevel@tonic-gate /* it must be updated even if */ 8727c478bd9Sstevel@tonic-gate /* the -s flag is in effect */ 8737c478bd9Sstevel@tonic-gate #define FLG_SY_NOTAVAIL 0x00000020 /* symbol is not available to the */ 8747c478bd9Sstevel@tonic-gate /* application either because it */ 8757c478bd9Sstevel@tonic-gate /* originates from an implicitly */ 8767c478bd9Sstevel@tonic-gate /* referenced shared object, or */ 8777c478bd9Sstevel@tonic-gate /* because it is not part of a */ 8787c478bd9Sstevel@tonic-gate /* specified version. */ 8797c478bd9Sstevel@tonic-gate #define FLG_SY_REDUCED 0x00000040 /* a global is reduced to local */ 8807c478bd9Sstevel@tonic-gate #define FLG_SY_VERSPROM 0x00000080 /* version definition has been */ 8817c478bd9Sstevel@tonic-gate /* promoted to output file */ 8827c478bd9Sstevel@tonic-gate #define FLG_SY_PROT 0x00000100 /* stv_protected visibility seen */ 8837c478bd9Sstevel@tonic-gate 8847c478bd9Sstevel@tonic-gate #define FLG_SY_MAPREF 0x00000200 /* symbol reference generated by user */ 8857c478bd9Sstevel@tonic-gate /* from mapfile */ 8867c478bd9Sstevel@tonic-gate #define FLG_SY_REFRSD 0x00000400 /* symbols sd_ref has been raised */ 8877c478bd9Sstevel@tonic-gate /* due to a copy-relocs */ 8887c478bd9Sstevel@tonic-gate /* weak-strong pairing */ 8899a411307Srie #define FLG_SY_INTPOSE 0x00000800 /* symbol defines an interposer */ 8907c478bd9Sstevel@tonic-gate #define FLG_SY_INVALID 0x00001000 /* unwanted/erroneous symbol */ 8917c478bd9Sstevel@tonic-gate #define FLG_SY_SMGOT 0x00002000 /* small got index assigned to symbol */ 8927c478bd9Sstevel@tonic-gate /* sparc only */ 8937c478bd9Sstevel@tonic-gate #define FLG_SY_PARENT 0x00004000 /* symbol to be found in parent */ 8947c478bd9Sstevel@tonic-gate /* only used with direct bindings */ 8957c478bd9Sstevel@tonic-gate #define FLG_SY_LAZYLD 0x00008000 /* symbol to cause lazyloading of */ 8967c478bd9Sstevel@tonic-gate /* parent object */ 8977c478bd9Sstevel@tonic-gate #define FLG_SY_ISDISC 0x00010000 /* symbol is a member of a DISCARDED */ 8987c478bd9Sstevel@tonic-gate /* section (COMDAT) */ 8997c478bd9Sstevel@tonic-gate #define FLG_SY_PAREXPN 0x00020000 /* partially init. symbol to be */ 9007c478bd9Sstevel@tonic-gate /* expanded */ 9017c478bd9Sstevel@tonic-gate #define FLG_SY_PLTPAD 0x00040000 /* pltpadding has been allocated for */ 9027c478bd9Sstevel@tonic-gate /* this symbol */ 9037c478bd9Sstevel@tonic-gate #define FLG_SY_REGSYM 0x00080000 /* REGISTER symbol (sparc only) */ 9047c478bd9Sstevel@tonic-gate #define FLG_SY_SOFOUND 0x00100000 /* compared against an SO definition */ 9057c478bd9Sstevel@tonic-gate #define FLG_SY_EXTERN 0x00200000 /* symbol is external, allows -zdefs */ 9067c478bd9Sstevel@tonic-gate /* error suppression */ 9077c478bd9Sstevel@tonic-gate #define FLG_SY_MAPUSED 0x00400000 /* mapfile symbol used (occurred */ 9087c478bd9Sstevel@tonic-gate /* within a relocatable object) */ 9097c478bd9Sstevel@tonic-gate #define FLG_SY_COMMEXP 0x00800000 /* COMMON symbol which has been */ 9107c478bd9Sstevel@tonic-gate /* allocated */ 9117c478bd9Sstevel@tonic-gate #define FLG_SY_CMDREF 0x01000000 /* symbol was referenced from the */ 9127c478bd9Sstevel@tonic-gate /* command line. (ld -u <>, */ 9137c478bd9Sstevel@tonic-gate /* ld -zrtldinfo=<>, ...) */ 9147c478bd9Sstevel@tonic-gate #define FLG_SY_SPECSEC 0x02000000 /* section index is reserved value */ 9157c478bd9Sstevel@tonic-gate /* ABS, COMMON, ... */ 9167c478bd9Sstevel@tonic-gate #define FLG_SY_TENTSYM 0x04000000 /* tentative symbol */ 9177c478bd9Sstevel@tonic-gate #define FLG_SY_VISIBLE 0x08000000 /* symbols visibility determined */ 9187c478bd9Sstevel@tonic-gate #define FLG_SY_STDFLTR 0x10000000 /* symbol is a standard filter */ 9197c478bd9Sstevel@tonic-gate #define FLG_SY_AUXFLTR 0x20000000 /* symbol is an auxiliary filter */ 920d579eb63Sab196087 #define FLG_SY_DYNSORT 0x40000000 /* req. in dyn[sym|tls]sort section */ 921d579eb63Sab196087 #define FLG_SY_NODYNSORT 0x80000000 /* excluded from dyn[sym_tls]sort sec */ 9227c478bd9Sstevel@tonic-gate 9237c478bd9Sstevel@tonic-gate /* 9247c478bd9Sstevel@tonic-gate * Sym_desc.sd_flags1 9257c478bd9Sstevel@tonic-gate */ 92660758829Srie #define FLG_SY1_DEFAULT 0x00000001 /* global symbol, default */ 92760758829Srie #define FLG_SY1_SINGLE 0x00000002 /* global symbol, singleton defined */ 92860758829Srie #define FLG_SY1_PROTECT 0x00000004 /* global symbol, protected defined */ 92960758829Srie #define FLG_SY1_EXPORT 0x00000008 /* global symbol, exported defined */ 9307c478bd9Sstevel@tonic-gate 93160758829Srie #define MSK_SY1_GLOBAL \ 93260758829Srie (FLG_SY1_DEFAULT | FLG_SY1_SINGLE | FLG_SY1_PROTECT | FLG_SY1_EXPORT) 93360758829Srie /* this mask indicates that the */ 93460758829Srie /* symbol has been explicitly */ 93560758829Srie /* defined within a mapfile */ 93660758829Srie /* definition, and is a candidate */ 93760758829Srie /* for versioning */ 93860758829Srie 93960758829Srie #define FLG_SY1_HIDDEN 0x00000010 /* global symbol, reduce to local */ 94060758829Srie #define FLG_SY1_ELIM 0x00000020 /* global symbol, eliminate */ 94160758829Srie #define FLG_SY1_IGNORE 0x00000040 /* global symbol, ignored */ 94260758829Srie 94360758829Srie #define MSK_SY1_LOCAL (FLG_SY1_HIDDEN | FLG_SY1_ELIM | FLG_SY1_IGNORE) 94460758829Srie /* this mask allows all local state */ 94560758829Srie /* flags to be removed when the */ 94660758829Srie /* symbol is copy relocated */ 94760758829Srie 94860758829Srie #define FLG_SY1_EXPDEF 0x00000100 /* symbol visibility defined */ 94960758829Srie /* explicitly */ 95060758829Srie 95160758829Srie #define MSK_SY1_NOAUTO (FLG_SY1_SINGLE | FLG_SY1_EXPORT | FLG_SY1_EXPDEF) 95260758829Srie /* this mask indicates that the */ 95360758829Srie /* symbol is not a candidate for */ 95460758829Srie /* auto-reduction/elimination */ 95560758829Srie 95660758829Srie #define FLG_SY1_MAPFILE 0x00000200 /* symbol attribute defined in a */ 95760758829Srie /* mapfile */ 95860758829Srie #define FLG_SY1_DIR 0x00000400 /* global symbol, direct bindings */ 95960758829Srie #define FLG_SY1_NDIR 0x00000800 /* global symbol, nondirect bindings */ 96057ef7aa9SRod Evans #define FLG_SY1_OVERLAP 0x00001000 /* Move entry overlap detected */ 9617c478bd9Sstevel@tonic-gate 9627c478bd9Sstevel@tonic-gate /* 96360758829Srie * Create a mask for (sym.st_other & visibility) since the gABI does not yet 96460758829Srie * define a ELF*_ST_OTHER macro. 9657c478bd9Sstevel@tonic-gate */ 96660758829Srie #define MSK_SYM_VISIBILITY 0x7 9677c478bd9Sstevel@tonic-gate 9687c478bd9Sstevel@tonic-gate /* 9697c478bd9Sstevel@tonic-gate * Structure to manage the shared object definition lists. There are two lists 9707c478bd9Sstevel@tonic-gate * that use this structure: 9717c478bd9Sstevel@tonic-gate * 97228bda19cSRod Evans * - ofl_soneed; maintain the list of implicitly required dependencies 9737c478bd9Sstevel@tonic-gate * (ie. shared objects needed by other shared objects). These definitions 9747c478bd9Sstevel@tonic-gate * may include RPATH's required to locate the dependencies, and any 9757c478bd9Sstevel@tonic-gate * version requirements. 9767c478bd9Sstevel@tonic-gate * 97728bda19cSRod Evans * - ofl_socntl; maintains the shared object control definitions. These are 9787c478bd9Sstevel@tonic-gate * provided by the user (via a mapfile) and are used to indicate any 97928bda19cSRod Evans * version control requirements. 9807c478bd9Sstevel@tonic-gate */ 9817c478bd9Sstevel@tonic-gate struct sdf_desc { 9827c478bd9Sstevel@tonic-gate const char *sdf_name; /* the shared objects file name */ 9837c478bd9Sstevel@tonic-gate char *sdf_rpath; /* library search path DT_RPATH */ 9847c478bd9Sstevel@tonic-gate const char *sdf_rfile; /* referencing file for diagnostics */ 9857c478bd9Sstevel@tonic-gate Ifl_desc *sdf_file; /* the final input file descriptor */ 98657ef7aa9SRod Evans Alist *sdf_vers; /* list of versions that are required */ 9877c478bd9Sstevel@tonic-gate /* from this object */ 98857ef7aa9SRod Evans Alist *sdf_verneed; /* list of VERNEEDS to create for */ 9894a8d0ea7SAli Bahrami /* object via mapfile ADDVERS */ 9907c478bd9Sstevel@tonic-gate Word sdf_flags; 9917c478bd9Sstevel@tonic-gate }; 9927c478bd9Sstevel@tonic-gate 9934a8d0ea7SAli Bahrami #define FLG_SDF_SELECT 0x01 /* version control selection required */ 9944a8d0ea7SAli Bahrami #define FLG_SDF_VERIFY 0x02 /* version definition verification */ 9957c478bd9Sstevel@tonic-gate /* required */ 9964a8d0ea7SAli Bahrami #define FLG_SDF_ADDVER 0x04 /* add VERNEED references */ 9977c478bd9Sstevel@tonic-gate 9987c478bd9Sstevel@tonic-gate /* 9997c478bd9Sstevel@tonic-gate * Structure to manage shared object version usage requirements. 10007c478bd9Sstevel@tonic-gate */ 10017c478bd9Sstevel@tonic-gate struct sdv_desc { 10027c478bd9Sstevel@tonic-gate const char *sdv_name; /* version name */ 10037c478bd9Sstevel@tonic-gate const char *sdv_ref; /* versions reference */ 10047c478bd9Sstevel@tonic-gate Word sdv_flags; /* flags */ 10057c478bd9Sstevel@tonic-gate }; 10067c478bd9Sstevel@tonic-gate 10077c478bd9Sstevel@tonic-gate #define FLG_SDV_MATCHED 0x01 /* VERDEF found and matched */ 10087c478bd9Sstevel@tonic-gate 10097c478bd9Sstevel@tonic-gate /* 10107c478bd9Sstevel@tonic-gate * Structures to manage versioning information. Two versioning structures are 10117c478bd9Sstevel@tonic-gate * defined: 10127c478bd9Sstevel@tonic-gate * 101328bda19cSRod Evans * - a version descriptor maintains a linked list of versions and their 10147c478bd9Sstevel@tonic-gate * associated dependencies. This is used to build the version definitions 10157c478bd9Sstevel@tonic-gate * for an image being created (see map_symbol), and to determine the 10167c478bd9Sstevel@tonic-gate * version dependency graph for any input files that are versioned. 10177c478bd9Sstevel@tonic-gate * 101828bda19cSRod Evans * - a version index array contains each version of an input file that is 10197c478bd9Sstevel@tonic-gate * being processed. It informs us which versions are available for 10207c478bd9Sstevel@tonic-gate * binding, and is used to generate any version dependency information. 10217c478bd9Sstevel@tonic-gate */ 10227c478bd9Sstevel@tonic-gate struct ver_desc { 10237c478bd9Sstevel@tonic-gate const char *vd_name; /* version name */ 10247c478bd9Sstevel@tonic-gate Ifl_desc *vd_file; /* file that defined version */ 102557ef7aa9SRod Evans Word vd_hash; /* hash value of name */ 10267c478bd9Sstevel@tonic-gate Half vd_ndx; /* coordinates with symbol index */ 10277c478bd9Sstevel@tonic-gate Half vd_flags; /* version information */ 102857ef7aa9SRod Evans APlist *vd_deps; /* version dependencies */ 10297c478bd9Sstevel@tonic-gate Ver_desc *vd_ref; /* dependency's first reference */ 10307c478bd9Sstevel@tonic-gate }; 10317c478bd9Sstevel@tonic-gate 10327c478bd9Sstevel@tonic-gate struct ver_index { 10337c478bd9Sstevel@tonic-gate const char *vi_name; /* dependency version name */ 10347c478bd9Sstevel@tonic-gate Half vi_flags; /* communicates availability */ 1035090a8d9eSAli Bahrami Half vi_overndx; /* Index asssigned to this version in */ 1036090a8d9eSAli Bahrami /* output object Verneed section */ 10377c478bd9Sstevel@tonic-gate Ver_desc *vi_desc; /* cross reference to descriptor */ 10387c478bd9Sstevel@tonic-gate }; 10397c478bd9Sstevel@tonic-gate 10407c478bd9Sstevel@tonic-gate /* 10417c478bd9Sstevel@tonic-gate * Define any internal version descriptor flags ([vd|vi]_flags). Note that the 10427c478bd9Sstevel@tonic-gate * first byte is reserved for user visible flags (refer VER_FLG's in link.h). 10437c478bd9Sstevel@tonic-gate */ 10447c478bd9Sstevel@tonic-gate #define MSK_VER_USER 0x0f /* mask for user visible flags */ 10457c478bd9Sstevel@tonic-gate 10467c478bd9Sstevel@tonic-gate #define FLG_VER_AVAIL 0x10 /* version is available for binding */ 10477c478bd9Sstevel@tonic-gate #define FLG_VER_REFER 0x20 /* version has been referenced */ 10484a8d0ea7SAli Bahrami #define FLG_VER_CYCLIC 0x40 /* a member of cyclic dependency */ 10497c478bd9Sstevel@tonic-gate 10507c478bd9Sstevel@tonic-gate /* 10517c478bd9Sstevel@tonic-gate * isalist(1) descriptor - used to break an isalist string into its component 10527c478bd9Sstevel@tonic-gate * options. 10537c478bd9Sstevel@tonic-gate */ 10547c478bd9Sstevel@tonic-gate struct isa_opt { 10557c478bd9Sstevel@tonic-gate char *isa_name; /* individual isa option name */ 10567c478bd9Sstevel@tonic-gate size_t isa_namesz; /* and associated size */ 10577c478bd9Sstevel@tonic-gate }; 10587c478bd9Sstevel@tonic-gate 10597c478bd9Sstevel@tonic-gate struct isa_desc { 10607c478bd9Sstevel@tonic-gate char *isa_list; /* sysinfo(SI_ISALIST) list */ 10617c478bd9Sstevel@tonic-gate size_t isa_listsz; /* and associated size */ 10627c478bd9Sstevel@tonic-gate Isa_opt *isa_opt; /* table of individual isa options */ 10637c478bd9Sstevel@tonic-gate size_t isa_optno; /* and associated number */ 10647c478bd9Sstevel@tonic-gate }; 10657c478bd9Sstevel@tonic-gate 10667c478bd9Sstevel@tonic-gate /* 10677c478bd9Sstevel@tonic-gate * uname(2) descriptor - used to break a utsname structure into its component 10687c478bd9Sstevel@tonic-gate * options (at least those that we're interested in). 10697c478bd9Sstevel@tonic-gate */ 10707c478bd9Sstevel@tonic-gate struct uts_desc { 10717c478bd9Sstevel@tonic-gate char *uts_osname; /* operating system name */ 10727c478bd9Sstevel@tonic-gate size_t uts_osnamesz; /* and associated size */ 10737c478bd9Sstevel@tonic-gate char *uts_osrel; /* operating system release */ 10747c478bd9Sstevel@tonic-gate size_t uts_osrelsz; /* and associated size */ 10757c478bd9Sstevel@tonic-gate }; 10767c478bd9Sstevel@tonic-gate 10777c478bd9Sstevel@tonic-gate /* 10787c478bd9Sstevel@tonic-gate * SHT_GROUP descriptor - used to track group sections at the global 10790e233487SRod Evans * level to resolve conflicts and determine which to keep. 10807c478bd9Sstevel@tonic-gate */ 10817c478bd9Sstevel@tonic-gate struct group_desc { 10820e233487SRod Evans Is_desc *gd_isc; /* input section descriptor */ 10830e233487SRod Evans Is_desc *gd_oisc; /* overriding input section */ 10840e233487SRod Evans /* descriptor when discarded */ 10850e233487SRod Evans const char *gd_name; /* group name (signature symbol) */ 1086cc7efc4fSrie Word *gd_data; /* data for group section */ 1087cc7efc4fSrie size_t gd_cnt; /* number of entries in group data */ 10887c478bd9Sstevel@tonic-gate }; 10897c478bd9Sstevel@tonic-gate 10907c478bd9Sstevel@tonic-gate /* 10917c478bd9Sstevel@tonic-gate * Indexes into the ld_support_funcs[] table. 10927c478bd9Sstevel@tonic-gate */ 10937c478bd9Sstevel@tonic-gate typedef enum { 1094d2d5cf7cSAli Bahrami LDS_VERSION = 0, /* Must be first and have value 0 */ 10957c478bd9Sstevel@tonic-gate LDS_INPUT_DONE, 10967c478bd9Sstevel@tonic-gate LDS_START, 10977c478bd9Sstevel@tonic-gate LDS_ATEXIT, 10983906e0c2Srie LDS_OPEN, 10997c478bd9Sstevel@tonic-gate LDS_FILE, 11002926dd2eSrie LDS_INSEC, 11012926dd2eSrie LDS_SEC, 11027c478bd9Sstevel@tonic-gate LDS_NUM 11037c478bd9Sstevel@tonic-gate } Support_ndx; 11047c478bd9Sstevel@tonic-gate 11057c478bd9Sstevel@tonic-gate /* 11067c478bd9Sstevel@tonic-gate * Structure to manage archive member caching. Each archive has an archive 11077c478bd9Sstevel@tonic-gate * descriptor (Ar_desc) associated with it. This contains pointers to the 11087c478bd9Sstevel@tonic-gate * archive symbol table (obtained by elf_getarsyms(3e)) and an auxiliary 11097c478bd9Sstevel@tonic-gate * structure (Ar_uax[]) that parallels this symbol table. The member element 11107c478bd9Sstevel@tonic-gate * of this auxiliary table indicates whether the archive member associated with 11117c478bd9Sstevel@tonic-gate * the symbol offset has already been extracted (AREXTRACTED) or partially 11127c478bd9Sstevel@tonic-gate * processed (refer process_member()). 11137c478bd9Sstevel@tonic-gate */ 11147c478bd9Sstevel@tonic-gate typedef struct ar_mem { 11157c478bd9Sstevel@tonic-gate Elf *am_elf; /* elf descriptor for this member */ 11167c478bd9Sstevel@tonic-gate char *am_name; /* members name */ 11177c478bd9Sstevel@tonic-gate char *am_path; /* path (ie. lib(foo.o)) */ 11187c478bd9Sstevel@tonic-gate Sym *am_syms; /* start of global symbols */ 11197c478bd9Sstevel@tonic-gate char *am_strs; /* associated string table start */ 11207c478bd9Sstevel@tonic-gate Xword am_symn; /* no. of global symbols */ 11217c478bd9Sstevel@tonic-gate } Ar_mem; 11227c478bd9Sstevel@tonic-gate 11237c478bd9Sstevel@tonic-gate typedef struct ar_aux { 11247c478bd9Sstevel@tonic-gate Sym_desc *au_syms; /* internal symbol descriptor */ 11257c478bd9Sstevel@tonic-gate Ar_mem *au_mem; /* associated member */ 11267c478bd9Sstevel@tonic-gate } Ar_aux; 11277c478bd9Sstevel@tonic-gate 11287c478bd9Sstevel@tonic-gate #define FLG_ARMEM_PROC (Ar_mem *)-1 11297c478bd9Sstevel@tonic-gate 11307c478bd9Sstevel@tonic-gate typedef struct ar_desc { 11317c478bd9Sstevel@tonic-gate const char *ad_name; /* archive file name */ 11327c478bd9Sstevel@tonic-gate Elf *ad_elf; /* elf descriptor for the archive */ 11337c478bd9Sstevel@tonic-gate Elf_Arsym *ad_start; /* archive symbol table start */ 11347c478bd9Sstevel@tonic-gate Ar_aux *ad_aux; /* auxiliary symbol information */ 11357c478bd9Sstevel@tonic-gate dev_t ad_stdev; /* device id and inode number for */ 11367c478bd9Sstevel@tonic-gate ino_t ad_stino; /* multiple inclusion checks */ 11371d9df23bSab196087 ofl_flag_t ad_flags; /* archive specific cmd line flags */ 11387c478bd9Sstevel@tonic-gate } Ar_desc; 11397c478bd9Sstevel@tonic-gate 11407c478bd9Sstevel@tonic-gate /* 11417c478bd9Sstevel@tonic-gate * Define any archive descriptor flags. NOTE, make sure they do not clash with 11427c478bd9Sstevel@tonic-gate * any output file descriptor archive extraction flags, as these are saved in 11437c478bd9Sstevel@tonic-gate * the same entry (see MSK_OF1_ARCHIVE). 11447c478bd9Sstevel@tonic-gate */ 11457c478bd9Sstevel@tonic-gate #define FLG_ARD_EXTRACT 0x00010000 /* archive member has been extracted */ 11467c478bd9Sstevel@tonic-gate 11477c478bd9Sstevel@tonic-gate /* 11485aefb655Srie * Function Declarations. 11497c478bd9Sstevel@tonic-gate */ 11505aefb655Srie #if defined(_ELF64) 11515aefb655Srie 11525aefb655Srie #define ld_create_outfile ld64_create_outfile 11535aefb655Srie #define ld_ent_setup ld64_ent_setup 1154c1c6f601Srie #define ld_init_strings ld64_init_strings 1155ba2be530Sab196087 #define ld_init_target ld64_init_target 11565aefb655Srie #define ld_make_sections ld64_make_sections 11575aefb655Srie #define ld_main ld64_main 11582926dd2eSrie #define ld_ofl_cleanup ld64_ofl_cleanup 115956deab07SRod Evans #define ld_process_mem ld64_process_mem 11605aefb655Srie #define ld_reloc_init ld64_reloc_init 11615aefb655Srie #define ld_reloc_process ld64_reloc_process 11625aefb655Srie #define ld_sym_validate ld64_sym_validate 11635aefb655Srie #define ld_update_outfile ld64_update_outfile 11645aefb655Srie 11655aefb655Srie #else 11665aefb655Srie 11675aefb655Srie #define ld_create_outfile ld32_create_outfile 11685aefb655Srie #define ld_ent_setup ld32_ent_setup 1169c1c6f601Srie #define ld_init_strings ld32_init_strings 1170ba2be530Sab196087 #define ld_init_target ld32_init_target 11715aefb655Srie #define ld_make_sections ld32_make_sections 11725aefb655Srie #define ld_main ld32_main 11732926dd2eSrie #define ld_ofl_cleanup ld32_ofl_cleanup 117456deab07SRod Evans #define ld_process_mem ld32_process_mem 11755aefb655Srie #define ld_reloc_init ld32_reloc_init 11765aefb655Srie #define ld_reloc_process ld32_reloc_process 11775aefb655Srie #define ld_sym_validate ld32_sym_validate 11785aefb655Srie #define ld_update_outfile ld32_update_outfile 11795aefb655Srie 11805aefb655Srie #endif 11815aefb655Srie 118292a02081SRod Evans extern int ld_getopt(Lm_list *, int, int, char **); 118392a02081SRod Evans 1184ba2be530Sab196087 extern int ld32_main(int, char **, Half); 1185ba2be530Sab196087 extern int ld64_main(int, char **, Half); 11865aefb655Srie 11875aefb655Srie extern uintptr_t ld_create_outfile(Ofl_desc *); 11885aefb655Srie extern uintptr_t ld_ent_setup(Ofl_desc *, Xword); 1189c1c6f601Srie extern uintptr_t ld_init_strings(Ofl_desc *); 1190ba2be530Sab196087 extern int ld_init_target(Lm_list *, Half mach); 11915aefb655Srie extern uintptr_t ld_make_sections(Ofl_desc *); 11922926dd2eSrie extern void ld_ofl_cleanup(Ofl_desc *); 119356deab07SRod Evans extern Ifl_desc *ld_process_mem(const char *, const char *, char *, 119456deab07SRod Evans size_t, Ofl_desc *, Rej_desc *); 11955aefb655Srie extern uintptr_t ld_reloc_init(Ofl_desc *); 11965aefb655Srie extern uintptr_t ld_reloc_process(Ofl_desc *); 11975aefb655Srie extern uintptr_t ld_sym_validate(Ofl_desc *); 11985aefb655Srie extern uintptr_t ld_update_outfile(Ofl_desc *); 11995aefb655Srie 12007c478bd9Sstevel@tonic-gate #ifdef __cplusplus 12017c478bd9Sstevel@tonic-gate } 12027c478bd9Sstevel@tonic-gate #endif 12037c478bd9Sstevel@tonic-gate 12047c478bd9Sstevel@tonic-gate #endif /* _LIBLD_H */ 1205