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 * 265aefb655Srie * Copyright 2006 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 #pragma ident "%Z%%M% %I% %E% SMI" 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <stdlib.h> 367c478bd9Sstevel@tonic-gate #include <libelf.h> 377c478bd9Sstevel@tonic-gate #include <sgs.h> 387c478bd9Sstevel@tonic-gate #include <machdep.h> 397c478bd9Sstevel@tonic-gate #include <string_table.h> 407c478bd9Sstevel@tonic-gate #include <sys/avl.h> 417c478bd9Sstevel@tonic-gate #include <alist.h> 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #ifdef __cplusplus 447c478bd9Sstevel@tonic-gate extern "C" { 457c478bd9Sstevel@tonic-gate #endif 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate /* 487c478bd9Sstevel@tonic-gate * Default directory search path manipulation for the link-editor. YLDIR 497c478bd9Sstevel@tonic-gate * indicates which directory in LIBPATH is replaced by the -YL option to cc 507c478bd9Sstevel@tonic-gate * and ld. YUDIR indicates which directory is replaced by -YU. 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate #define YLDIR 1 537c478bd9Sstevel@tonic-gate #define YUDIR 2 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate /* 567c478bd9Sstevel@tonic-gate * Define a hash value that can never be returned from elf_hash(). 577c478bd9Sstevel@tonic-gate */ 587c478bd9Sstevel@tonic-gate #define SYM_NOHASH (~(Word)0) 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * Define MACROs to be used for input sections to flagout 627c478bd9Sstevel@tonic-gate * when matching sections. 637c478bd9Sstevel@tonic-gate */ 647c478bd9Sstevel@tonic-gate #define ALL_SHF_ORDER (SHF_ORDERED | SHF_LINK_ORDER) 657c478bd9Sstevel@tonic-gate #define ALL_SHF_IGNORE (ALL_SHF_ORDER | SHF_GROUP) 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * Define symbol reference types for use in symbol resolution. 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate typedef enum { 717c478bd9Sstevel@tonic-gate REF_DYN_SEEN, /* a .so symbol has been seen */ 727c478bd9Sstevel@tonic-gate REF_DYN_NEED, /* a .so symbol satisfies a .o symbol */ 737c478bd9Sstevel@tonic-gate REF_REL_NEED, /* a .o symbol */ 747c478bd9Sstevel@tonic-gate REF_NUM /* the number of symbol references */ 757c478bd9Sstevel@tonic-gate } Symref; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* 797c478bd9Sstevel@tonic-gate * GOT reference models 807c478bd9Sstevel@tonic-gate */ 817c478bd9Sstevel@tonic-gate typedef enum { 827c478bd9Sstevel@tonic-gate GOT_REF_GENERIC, /* generic symbol reference */ 837c478bd9Sstevel@tonic-gate GOT_REF_TLSIE, /* TLS initial exec (gnu) reference */ 847c478bd9Sstevel@tonic-gate GOT_REF_TLSLD, /* TLS local dynamic reference */ 857c478bd9Sstevel@tonic-gate GOT_REF_TLSGD /* TLS general dynamic reference */ 867c478bd9Sstevel@tonic-gate } Gotref; 877c478bd9Sstevel@tonic-gate 887c478bd9Sstevel@tonic-gate typedef struct { 897c478bd9Sstevel@tonic-gate Xword gn_addend; /* addend associated with GOT entry */ 907c478bd9Sstevel@tonic-gate Sword gn_gotndx; /* GOT table index */ 917c478bd9Sstevel@tonic-gate Gotref gn_gotref; 927c478bd9Sstevel@tonic-gate } Gotndx; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* 957c478bd9Sstevel@tonic-gate * Got debugging structure. The got index is defined as a signed value as we 967c478bd9Sstevel@tonic-gate * do so much mucking around with negative and positive gots on SPARC, and sign 977c478bd9Sstevel@tonic-gate * extension is necessary when building 64-bit objects. On intel we explicitly 987c478bd9Sstevel@tonic-gate * cast this variable to an unsigned value. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate typedef struct { 1017c478bd9Sstevel@tonic-gate Sym_desc * gt_sym; 1027c478bd9Sstevel@tonic-gate Gotndx gt_gndx; 1037c478bd9Sstevel@tonic-gate } Gottable; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Output file processing structure 1087c478bd9Sstevel@tonic-gate */ 1097c478bd9Sstevel@tonic-gate struct ofl_desc { 1107c478bd9Sstevel@tonic-gate char *ofl_sgsid; /* link-editor identification */ 1117c478bd9Sstevel@tonic-gate const char *ofl_name; /* full file name */ 1127c478bd9Sstevel@tonic-gate Elf *ofl_elf; /* elf_memory() elf descriptor */ 1137c478bd9Sstevel@tonic-gate Elf *ofl_welf; /* ELF_C_WRITE elf descriptor */ 1145aefb655Srie Ehdr *ofl_dehdr; /* default elf header, and new elf */ 1155aefb655Srie Ehdr *ofl_nehdr; /* header describing this file */ 1167c478bd9Sstevel@tonic-gate Phdr *ofl_phdr; /* program header descriptor */ 1177c478bd9Sstevel@tonic-gate Phdr *ofl_tlsphdr; /* TLS phdr */ 1187c478bd9Sstevel@tonic-gate int ofl_fd; /* file descriptor */ 1197c478bd9Sstevel@tonic-gate size_t ofl_size; /* image size */ 1207c478bd9Sstevel@tonic-gate List ofl_maps; /* list of input mapfiles */ 1217c478bd9Sstevel@tonic-gate List ofl_segs; /* list of segments */ 1227c478bd9Sstevel@tonic-gate List ofl_ents; /* list of entrance descriptors */ 1237c478bd9Sstevel@tonic-gate List ofl_objs; /* relocatable object file list */ 1247c478bd9Sstevel@tonic-gate Word ofl_objscnt; /* and count */ 1257c478bd9Sstevel@tonic-gate List ofl_ars; /* archive library list */ 1267c478bd9Sstevel@tonic-gate Word ofl_arscnt; /* and count */ 1277c478bd9Sstevel@tonic-gate List ofl_sos; /* shared object list */ 1287c478bd9Sstevel@tonic-gate Word ofl_soscnt; /* and count */ 1297c478bd9Sstevel@tonic-gate List ofl_soneed; /* list of implicitly required .so's */ 1307c478bd9Sstevel@tonic-gate List ofl_socntl; /* list of .so control definitions */ 1317c478bd9Sstevel@tonic-gate List ofl_outrels; /* list of output relocations */ 1327c478bd9Sstevel@tonic-gate Word ofl_outrelscnt; /* and count */ 1337c478bd9Sstevel@tonic-gate List ofl_actrels; /* list of relocations to perform */ 1347c478bd9Sstevel@tonic-gate Word ofl_actrelscnt; /* and count */ 135c174926fSrie Word ofl_entrelscnt; /* no of relocations entered */ 1367c478bd9Sstevel@tonic-gate List ofl_copyrels; /* list of copy relocations */ 1377c478bd9Sstevel@tonic-gate List ofl_ordered; /* list of shf_ordered sections */ 1387c478bd9Sstevel@tonic-gate List ofl_syminfsyms; /* list of interesting syms */ 1397c478bd9Sstevel@tonic-gate /* for syminfo processing */ 1407c478bd9Sstevel@tonic-gate List ofl_ismove; /* list of .SUNW_move sections */ 1417c478bd9Sstevel@tonic-gate List ofl_mvrelisdescs; /* list of relocation input section */ 1427c478bd9Sstevel@tonic-gate /* targeting to expanded area */ 1437c478bd9Sstevel@tonic-gate List ofl_parsym; /* list of Parsym_info */ 1447c478bd9Sstevel@tonic-gate List ofl_extrarels; /* relocation sections which have */ 1457c478bd9Sstevel@tonic-gate /* a NULL sh_info */ 146cc7efc4fSrie avl_tree_t *ofl_groups; /* pointer to head of Groups AVL tree */ 1477c478bd9Sstevel@tonic-gate List ofl_initarray; /* list of init array func names */ 1487c478bd9Sstevel@tonic-gate List ofl_finiarray; /* list of fini array func names */ 1497c478bd9Sstevel@tonic-gate List ofl_preiarray; /* list of preinit array func names */ 1507c478bd9Sstevel@tonic-gate List ofl_rtldinfo; /* list of rtldinfo syms */ 1517c478bd9Sstevel@tonic-gate List ofl_osgroups; /* list of output GROUP sections */ 1527c478bd9Sstevel@tonic-gate List ofl_ostlsseg; /* pointer to sections in TLS segment */ 1537c478bd9Sstevel@tonic-gate #if (defined(__i386) || defined(__amd64)) && defined(_ELF64) 1547c478bd9Sstevel@tonic-gate List ofl_unwind; /* list of unwind output sections */ 1557c478bd9Sstevel@tonic-gate Os_desc *ofl_unwindhdr; /* Unwind hdr */ 1567c478bd9Sstevel@tonic-gate #endif 1577c478bd9Sstevel@tonic-gate avl_tree_t ofl_symavl; /* pointer to head of Syms AVL tree */ 1587c478bd9Sstevel@tonic-gate Sym_desc **ofl_regsyms; /* array of potential register */ 1597c478bd9Sstevel@tonic-gate Word ofl_regsymsno; /* symbols and array count */ 1607c478bd9Sstevel@tonic-gate Word ofl_regsymcnt; /* no. of output register symbols */ 1617c478bd9Sstevel@tonic-gate Word ofl_lregsymcnt; /* no. of local register symbols */ 1627c478bd9Sstevel@tonic-gate Sym_desc *ofl_dtracesym; /* ld -zdtrace= */ 1637c478bd9Sstevel@tonic-gate Word ofl_flags; /* various state bits, args etc. */ 1647c478bd9Sstevel@tonic-gate Word ofl_flags1; /* more flags */ 1657c478bd9Sstevel@tonic-gate Xword ofl_segorigin; /* segment origin (start) */ 1667c478bd9Sstevel@tonic-gate void *ofl_entry; /* entry point (-e and Sym_desc *) */ 1677c478bd9Sstevel@tonic-gate char *ofl_filtees; /* shared objects we are a filter for */ 1687c478bd9Sstevel@tonic-gate const char *ofl_soname; /* (-h option) output file name for */ 1697c478bd9Sstevel@tonic-gate /* dynamic structure */ 1707c478bd9Sstevel@tonic-gate const char *ofl_interp; /* interpreter name used by exec() */ 1717c478bd9Sstevel@tonic-gate char *ofl_rpath; /* run path to store in .dynamic */ 1727c478bd9Sstevel@tonic-gate char *ofl_config; /* config path to store in .dynamic */ 1737c478bd9Sstevel@tonic-gate List ofl_ulibdirs; /* user supplied library search list */ 1747c478bd9Sstevel@tonic-gate List ofl_dlibdirs; /* default library search list */ 1757c478bd9Sstevel@tonic-gate Word ofl_vercnt; /* number of versions to generate */ 1767c478bd9Sstevel@tonic-gate List ofl_verdesc; /* list of version descriptors */ 1777c478bd9Sstevel@tonic-gate size_t ofl_verdefsz; /* size of version definition section */ 1787c478bd9Sstevel@tonic-gate size_t ofl_verneedsz; /* size of version needed section */ 1797c478bd9Sstevel@tonic-gate Word ofl_entercnt; /* no. of global symbols entered */ 1807c478bd9Sstevel@tonic-gate Word ofl_globcnt; /* no. of global symbols to output */ 1817c478bd9Sstevel@tonic-gate Word ofl_scopecnt; /* no. of scoped symbols to output */ 1827c478bd9Sstevel@tonic-gate Word ofl_elimcnt; /* no. of eliminated symbols */ 1837c478bd9Sstevel@tonic-gate Word ofl_locscnt; /* no. of local symbols to output */ 1847c478bd9Sstevel@tonic-gate Word ofl_dynshdrcnt; /* no. of output section in .dynsym */ 1857c478bd9Sstevel@tonic-gate Word ofl_shdrcnt; /* no. of output sections */ 1867c478bd9Sstevel@tonic-gate Str_tbl *ofl_shdrsttab; /* Str_tbl for shdr strtab */ 1877c478bd9Sstevel@tonic-gate Str_tbl *ofl_strtab; /* Str_tbl for symtab strtab */ 1887c478bd9Sstevel@tonic-gate Str_tbl *ofl_dynstrtab; /* Str_tbl for dymsym strtab */ 1897c478bd9Sstevel@tonic-gate Gotndx *ofl_tlsldgotndx; /* index to LD TLS_index structure */ 1907c478bd9Sstevel@tonic-gate Xword ofl_relocsz; /* size of output relocations */ 1917c478bd9Sstevel@tonic-gate Xword ofl_relocgotsz; /* size of .got relocations */ 1927c478bd9Sstevel@tonic-gate Xword ofl_relocpltsz; /* size of .plt relocations */ 1937c478bd9Sstevel@tonic-gate Xword ofl_relocbsssz; /* size of .bss (copy) relocations */ 1947c478bd9Sstevel@tonic-gate Xword ofl_relocrelsz; /* size of .rel[a] relocations */ 1957c478bd9Sstevel@tonic-gate Word ofl_relocincnt; /* no. of input relocations */ 1967c478bd9Sstevel@tonic-gate Word ofl_reloccnt; /* tot number of output relocations */ 1977c478bd9Sstevel@tonic-gate Word ofl_reloccntsub; /* tot numb of output relocations to */ 1987c478bd9Sstevel@tonic-gate /* skip (-zignore) */ 1997c478bd9Sstevel@tonic-gate Word ofl_relocrelcnt; /* tot number of relative */ 2007c478bd9Sstevel@tonic-gate /* relocations */ 2017c478bd9Sstevel@tonic-gate Word ofl_gotcnt; /* no. of .got entries */ 2027c478bd9Sstevel@tonic-gate Word ofl_pltcnt; /* no. of .plt entries */ 2037c478bd9Sstevel@tonic-gate Word ofl_pltpad; /* no. of .plt padd entries */ 2047c478bd9Sstevel@tonic-gate Word ofl_hashbkts; /* no. of hash buckets required */ 2057c478bd9Sstevel@tonic-gate Is_desc *ofl_isbss; /* .bss input section (globals) */ 20654d82594Sseizo Is_desc *ofl_islbss; /* .lbss input section (globals) */ 2077c478bd9Sstevel@tonic-gate Is_desc *ofl_istlsbss; /* .tlsbss input section (globals) */ 2087c478bd9Sstevel@tonic-gate Is_desc *ofl_issunwdata1; /* .data input section */ 2097c478bd9Sstevel@tonic-gate /* partially expanded. */ 2107c478bd9Sstevel@tonic-gate Is_desc *ofl_issunwbss; /* .SUNW_bss input section (globals) */ 2117c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynamic; /* .dynamic output section */ 2127c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynsym; /* .dynsym output section */ 2137c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynstr; /* .dynstr output section */ 2147c478bd9Sstevel@tonic-gate Os_desc *ofl_osgot; /* .got output section */ 2157c478bd9Sstevel@tonic-gate Os_desc *ofl_oshash; /* .hash output section */ 2167c478bd9Sstevel@tonic-gate Os_desc *ofl_osinitarray; /* .initarray output section */ 2177c478bd9Sstevel@tonic-gate Os_desc *ofl_osfiniarray; /* .finiarray output section */ 2187c478bd9Sstevel@tonic-gate Os_desc *ofl_ospreinitarray; /* .preinitarray output section */ 2197c478bd9Sstevel@tonic-gate Os_desc *ofl_osinterp; /* .interp output section */ 2207c478bd9Sstevel@tonic-gate Os_desc *ofl_oscap; /* .SUNW_cap output section */ 2217c478bd9Sstevel@tonic-gate Os_desc *ofl_osplt; /* .plt output section */ 2227c478bd9Sstevel@tonic-gate Os_desc *ofl_osmove; /* .SUNW_move output section */ 2237c478bd9Sstevel@tonic-gate Os_desc *ofl_osrelhead; /* first relocation section */ 2247c478bd9Sstevel@tonic-gate Os_desc *ofl_osrel; /* .rel[a] relocation section */ 2257c478bd9Sstevel@tonic-gate Os_desc *ofl_osshstrtab; /* .shstrtab output section */ 2267c478bd9Sstevel@tonic-gate Os_desc *ofl_osstrtab; /* .strtab output section */ 2277c478bd9Sstevel@tonic-gate Os_desc *ofl_ossymtab; /* .symtab output section */ 2287c478bd9Sstevel@tonic-gate Os_desc *ofl_ossymshndx; /* .symtab_shndx output section */ 2297c478bd9Sstevel@tonic-gate Os_desc *ofl_osdynshndx; /* .dynsym_shndx output section */ 2307c478bd9Sstevel@tonic-gate Os_desc *ofl_osverdef; /* .version definition output section */ 2317c478bd9Sstevel@tonic-gate Os_desc *ofl_osverneed; /* .version needed output section */ 2327c478bd9Sstevel@tonic-gate Os_desc *ofl_osversym; /* .version symbol ndx output section */ 2337c478bd9Sstevel@tonic-gate Word ofl_dtflags_1; /* DT_FLAGS_1 entries */ 2347c478bd9Sstevel@tonic-gate Word ofl_dtflags; /* DT_FLAGS entries */ 2357c478bd9Sstevel@tonic-gate Os_desc *ofl_ossyminfo; /* .SUNW_syminfo output section */ 2367c478bd9Sstevel@tonic-gate Half ofl_sunwdata1ndx; /* section index for sunwdata1 */ 2377c478bd9Sstevel@tonic-gate /* Ref. at perform_outreloc() in */ 2387c478bd9Sstevel@tonic-gate /* libld/{mach}/machrel.c */ 2397c478bd9Sstevel@tonic-gate Xword *ofl_checksum; /* DT_CHECKSUM value address */ 2407c478bd9Sstevel@tonic-gate char *ofl_depaudit; /* dependency auditing required (-P) */ 2417c478bd9Sstevel@tonic-gate char *ofl_audit; /* object auditing required (-p) */ 2427c478bd9Sstevel@tonic-gate Alist *ofl_symfltrs; /* per-symbol filtees and their */ 2437c478bd9Sstevel@tonic-gate Alist *ofl_dtsfltrs; /* associated .dynamic/.dynstrs */ 2447c478bd9Sstevel@tonic-gate Xword ofl_hwcap_1; /* hardware capabilities */ 2457c478bd9Sstevel@tonic-gate Xword ofl_sfcap_1; /* software capabilities */ 2465aefb655Srie Lm_list *ofl_lml; /* runtime link-map list */ 2477c478bd9Sstevel@tonic-gate }; 2487c478bd9Sstevel@tonic-gate 2497c478bd9Sstevel@tonic-gate #define FLG_OF_DYNAMIC 0x00000001 /* generate dynamic output module */ 2507c478bd9Sstevel@tonic-gate #define FLG_OF_STATIC 0x00000002 /* generate static output module */ 2517c478bd9Sstevel@tonic-gate #define FLG_OF_EXEC 0x00000004 /* generate an executable */ 2527c478bd9Sstevel@tonic-gate #define FLG_OF_RELOBJ 0x00000008 /* generate a relocatable object */ 2537c478bd9Sstevel@tonic-gate #define FLG_OF_SHAROBJ 0x00000010 /* generate a shared object */ 2547c478bd9Sstevel@tonic-gate #define FLG_OF_BFLAG 0x00000020 /* do no special plt building: -b */ 2557c478bd9Sstevel@tonic-gate #define FLG_OF_IGNENV 0x00000040 /* ignore LD_LIBRARY_PATH: -i */ 2567c478bd9Sstevel@tonic-gate #define FLG_OF_STRIP 0x00000080 /* strip output: -s */ 2577c478bd9Sstevel@tonic-gate #define FLG_OF_NOWARN 0x00000100 /* disable symbol warnings: -t */ 2587c478bd9Sstevel@tonic-gate #define FLG_OF_NOUNDEF 0x00000200 /* allow no undefined symbols: -zdefs */ 2597c478bd9Sstevel@tonic-gate #define FLG_OF_PURETXT 0x00000400 /* allow no text relocations: -ztext */ 2607c478bd9Sstevel@tonic-gate #define FLG_OF_GENMAP 0x00000800 /* generate a memory map: -m */ 2617c478bd9Sstevel@tonic-gate #define FLG_OF_DYNLIBS 0x00001000 /* dynamic input allowed: -Bdynamic */ 2627c478bd9Sstevel@tonic-gate #define FLG_OF_SYMBOLIC 0x00002000 /* bind global symbols: -Bsymbolic */ 2637c478bd9Sstevel@tonic-gate #define FLG_OF_ADDVERS 0x00004000 /* add version stamp: -Qy */ 2647c478bd9Sstevel@tonic-gate #define FLG_OF_MEMORY 0x00008000 /* produce a memory model */ 2657c478bd9Sstevel@tonic-gate #define FLG_OF_SEGORDER 0x00010000 /* segment ordering is required */ 2667c478bd9Sstevel@tonic-gate #define FLG_OF_SEGSORT 0x00020000 /* segment sorting is required */ 2677c478bd9Sstevel@tonic-gate #define FLG_OF_TEXTREL 0x00040000 /* text relocations have been found */ 2687c478bd9Sstevel@tonic-gate #define FLG_OF_MULDEFS 0x00080000 /* multiple symbols are allowed */ 269dd94ecefSrie #define FLG_OF_TLSPHDR 0x00100000 /* a TLS program header is required */ 2707c478bd9Sstevel@tonic-gate #define FLG_OF_BLDGOT 0x00200000 /* build GOT table */ 2717c478bd9Sstevel@tonic-gate #define FLG_OF_VERDEF 0x00400000 /* record version definitions */ 2727c478bd9Sstevel@tonic-gate #define FLG_OF_VERNEED 0x00800000 /* record version dependencies */ 2737c478bd9Sstevel@tonic-gate #define FLG_OF_NOVERSEC 0x01000000 /* don't record version sections */ 2747c478bd9Sstevel@tonic-gate #define FLG_OF_AUTOLCL 0x02000000 /* automatically reduce unspecified */ 2757c478bd9Sstevel@tonic-gate /* global symbols to locals */ 2767c478bd9Sstevel@tonic-gate #define FLG_OF_PROCRED 0x04000000 /* process any symbol reductions by */ 2777c478bd9Sstevel@tonic-gate /* effecting the symbol table */ 2787c478bd9Sstevel@tonic-gate /* output and relocations */ 2797c478bd9Sstevel@tonic-gate #define FLG_OF_SYMINFO 0x08000000 /* create a syminfo section */ 2807c478bd9Sstevel@tonic-gate #define FLG_OF_AUX 0x10000000 /* ofl_filter is an auxiliary filter */ 2817c478bd9Sstevel@tonic-gate #define FLG_OF_FATAL 0x20000000 /* fatal error during input */ 2827c478bd9Sstevel@tonic-gate #define FLG_OF_WARN 0x40000000 /* warning during input processing. */ 2837c478bd9Sstevel@tonic-gate #define FLG_OF_VERBOSE 0x80000000 /* -z verbose flag set */ 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate /* 2867c478bd9Sstevel@tonic-gate * In the flags1 arena, establish any options that are applicable to archive 2877c478bd9Sstevel@tonic-gate * extraction first, and associate a mask. These values are recorded with any 2887c478bd9Sstevel@tonic-gate * archive descriptor so that they may be reset should the archive require a 2897c478bd9Sstevel@tonic-gate * rescan to try and resolve undefined symbols. 2907c478bd9Sstevel@tonic-gate */ 2917c478bd9Sstevel@tonic-gate #define FLG_OF1_ALLEXRT 0x00000001 /* extract all members from an */ 2927c478bd9Sstevel@tonic-gate /* archive file */ 2937c478bd9Sstevel@tonic-gate #define FLG_OF1_WEAKEXT 0x00000002 /* allow archive extraction to */ 2947c478bd9Sstevel@tonic-gate /* resolve weak references */ 2957c478bd9Sstevel@tonic-gate #define MSK_OF1_ARCHIVE 0x0000000f /* archive flags mask */ 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate #define FLG_OF1_ZDIRECT 0x00000010 /* -z direct flag set */ 2987c478bd9Sstevel@tonic-gate #define FLG_OF1_NDIRECT 0x00000020 /* no-direct bindings specified */ 2997c478bd9Sstevel@tonic-gate #define FLG_OF1_OVHWCAP 0x00000040 /* override any input hardware or */ 3007c478bd9Sstevel@tonic-gate #define FLG_OF1_OVSFCAP 0x00000080 /* software capabilities */ 3017c478bd9Sstevel@tonic-gate #define FLG_OF1_RELDYN 0x00000100 /* process .dynamic in rel obj */ 3027c478bd9Sstevel@tonic-gate #define FLG_OF1_REDLSYM 0x00000200 /* reduce local symbols */ 3037c478bd9Sstevel@tonic-gate #define FLG_OF1_AUTOELM 0x00000400 /* automatically eliminate */ 3047c478bd9Sstevel@tonic-gate /* unspecified global symbols */ 3057c478bd9Sstevel@tonic-gate #define FLG_OF1_IGNORE 0x00000800 /* ignore unused dependencies */ 3067c478bd9Sstevel@tonic-gate #define FLG_OF1_RELCNT 0x00001000 /* enable DT_RELACNT tracking */ 3077c478bd9Sstevel@tonic-gate #define FLG_OF1_TEXTOFF 0x00002000 /* text relocations are ok */ 3087c478bd9Sstevel@tonic-gate #define FLG_OF1_ABSEXEC 0x00004000 /* -zabsexec set */ 3097c478bd9Sstevel@tonic-gate #define FLG_OF1_LAZYLD 0x00008000 /* lazy loading of objects enabled */ 3107c478bd9Sstevel@tonic-gate #define FLG_OF1_GRPPRM 0x00010000 /* dependencies are to have */ 3117c478bd9Sstevel@tonic-gate /* GROUPPERM enabled */ 3127c478bd9Sstevel@tonic-gate #define FLG_OF1_OVRFLW 0x00020000 /* size exceeds 32-bit limitation */ 3137c478bd9Sstevel@tonic-gate /* of 32-bit libld */ 3147c478bd9Sstevel@tonic-gate #define FLG_OF1_NOPARTI 0x00040000 /* -znopartial set */ 3157c478bd9Sstevel@tonic-gate #define FLG_OF1_BSSOREL 0x00080000 /* output relocation against bss */ 3167c478bd9Sstevel@tonic-gate /* section */ 3177c478bd9Sstevel@tonic-gate #define FLG_OF1_TLSOREL 0x00100000 /* output relocation against .tlsbss */ 3187c478bd9Sstevel@tonic-gate /* section */ 3197c478bd9Sstevel@tonic-gate #define FLG_OF1_NOHDR 0x00800000 /* no elf header/phdr alignment */ 3207c478bd9Sstevel@tonic-gate /* needed */ 3217c478bd9Sstevel@tonic-gate #define FLG_OF1_VADDR 0x01000000 /* vaddr was explicitly set */ 3227c478bd9Sstevel@tonic-gate #define FLG_OF1_EXTRACT 0x02000000 /* archive member has been extracted */ 3237c478bd9Sstevel@tonic-gate #define FLG_OF1_RESCAN 0x04000000 /* any archives should be rescanned */ 3247c478bd9Sstevel@tonic-gate #define FLG_OF1_IGNPRC 0x08000000 /* ignore processing required */ 3257c478bd9Sstevel@tonic-gate #define FLG_OF1_NCSTTAB 0x10000000 /* -znocompstrtab set */ 3267c478bd9Sstevel@tonic-gate #define FLG_OF1_DONE 0x20000000 /* link-editor processing complete */ 3277c478bd9Sstevel@tonic-gate #define FLG_OF1_NONREG 0x40000000 /* non-regular file specified as */ 3287c478bd9Sstevel@tonic-gate /* the output file */ 3297c478bd9Sstevel@tonic-gate #define FLG_OF1_ALNODIR 0x80000000 /* establish NODIRECT for all */ 3307c478bd9Sstevel@tonic-gate /* exported interfaces. */ 3317c478bd9Sstevel@tonic-gate 3327c478bd9Sstevel@tonic-gate /* 3337c478bd9Sstevel@tonic-gate * Relocation (active & output) processing structure - transparent to common 3347c478bd9Sstevel@tonic-gate * code. 3357c478bd9Sstevel@tonic-gate */ 3367c478bd9Sstevel@tonic-gate struct rel_desc { 3377c478bd9Sstevel@tonic-gate Os_desc *rel_osdesc; /* output section reloc is against */ 3387c478bd9Sstevel@tonic-gate Is_desc *rel_isdesc; /* input section reloc is against */ 3397c478bd9Sstevel@tonic-gate const char *rel_sname; /* symbol name (may be "unknown") */ 3407c478bd9Sstevel@tonic-gate Sym_desc *rel_sym; /* sym relocation is against */ 3417c478bd9Sstevel@tonic-gate Sym_desc *rel_usym; /* strong sym if this is a weak pair */ 3427c478bd9Sstevel@tonic-gate Mv_desc *rel_move; /* move table information */ 3437c478bd9Sstevel@tonic-gate Word rel_flags; /* misc. flags for relocations */ 3447c478bd9Sstevel@tonic-gate Word rel_rtype; /* relocation type */ 3457c478bd9Sstevel@tonic-gate Xword rel_roffset; /* relocation offset */ 3467c478bd9Sstevel@tonic-gate Sxword rel_raddend; /* addend from input relocation */ 3477c478bd9Sstevel@tonic-gate Word rel_typedata; /* ELF_R_TYPE_DATA(info) */ 3487c478bd9Sstevel@tonic-gate }; 3497c478bd9Sstevel@tonic-gate 3507c478bd9Sstevel@tonic-gate /* 3517c478bd9Sstevel@tonic-gate * common flags used on the Rel_desc structure (defined in machrel.h). 3527c478bd9Sstevel@tonic-gate */ 3537c478bd9Sstevel@tonic-gate #define FLG_REL_GOT 0x00000001 /* relocation against GOT */ 3547c478bd9Sstevel@tonic-gate #define FLG_REL_PLT 0x00000002 /* relocation against PLT */ 3557c478bd9Sstevel@tonic-gate #define FLG_REL_BSS 0x00000004 /* relocation against BSS */ 3567c478bd9Sstevel@tonic-gate #define FLG_REL_LOAD 0x00000008 /* section loadable */ 3577c478bd9Sstevel@tonic-gate #define FLG_REL_SCNNDX 0x00000010 /* use section index for symbol ndx */ 3587c478bd9Sstevel@tonic-gate #define FLG_REL_CLVAL 0x00000020 /* clear VALUE for active relocation */ 3597c478bd9Sstevel@tonic-gate #define FLG_REL_ADVAL 0x00000040 /* add VALUE for output relocation, */ 3607c478bd9Sstevel@tonic-gate /* only relevent to SPARC and */ 3617c478bd9Sstevel@tonic-gate /* R_SPARC_RELATIVE */ 3627c478bd9Sstevel@tonic-gate #define FLG_REL_GOTCL 0x00000080 /* clear the GOT entry. This is */ 3637c478bd9Sstevel@tonic-gate /* relevant to RELA relocations, */ 3647c478bd9Sstevel@tonic-gate /* not REL (i386) relocations */ 3657c478bd9Sstevel@tonic-gate #define FLG_REL_MOVETAB 0x00000100 /* Relocation against .SUNW_move */ 3667c478bd9Sstevel@tonic-gate /* adjustments required before */ 3677c478bd9Sstevel@tonic-gate /* actual relocation */ 3687c478bd9Sstevel@tonic-gate #define FLG_REL_NOINFO 0x00000200 /* Relocation comes from a section */ 3697c478bd9Sstevel@tonic-gate /* with a null sh_info field */ 3707c478bd9Sstevel@tonic-gate #define FLG_REL_REG 0x00000400 /* Relocation target is reg sym */ 3717c478bd9Sstevel@tonic-gate #define FLG_REL_FPTR 0x00000800 /* relocation against func. desc. */ 3727c478bd9Sstevel@tonic-gate #define FLG_REL_RFPTR1 0x00001000 /* Relative relocation against */ 3737c478bd9Sstevel@tonic-gate /* 1st part of FD */ 3747c478bd9Sstevel@tonic-gate #define FLG_REL_RFPTR2 0x00002000 /* Relative relocation against */ 3757c478bd9Sstevel@tonic-gate /* 2nd part of FD */ 3767c478bd9Sstevel@tonic-gate #define FLG_REL_DISP 0x00004000 /* *disp* relocation */ 3777c478bd9Sstevel@tonic-gate #define FLG_REL_STLS 0x00008000 /* IE TLS reference to */ 3787c478bd9Sstevel@tonic-gate /* static TLS GOT index */ 3797c478bd9Sstevel@tonic-gate #define FLG_REL_DTLS 0x00010000 /* GD TLS reference relative to */ 3807c478bd9Sstevel@tonic-gate /* dynamic TLS GOT index */ 3817c478bd9Sstevel@tonic-gate #define FLG_REL_MTLS 0x00020000 /* LD TLS reference against GOT */ 3827c478bd9Sstevel@tonic-gate #define FLG_REL_STTLS 0x00040000 /* LE TLS reference directly */ 3837c478bd9Sstevel@tonic-gate /* to static tls index */ 3847c478bd9Sstevel@tonic-gate #define FLG_REL_TLSFIX 0x00080000 /* relocation points to TLS instr. */ 3857c478bd9Sstevel@tonic-gate /* which needs updating */ 3867c478bd9Sstevel@tonic-gate #define FLG_REL_RELA 0x00100000 /* descripter captures a Rela */ 3877c478bd9Sstevel@tonic-gate #define FLG_REL_GOTFIX 0x00200000 /* relocation points to GOTOP instr. */ 3887c478bd9Sstevel@tonic-gate /* which needs updating */ 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate /* 3917c478bd9Sstevel@tonic-gate * Structure to hold a cache of Relocations. 3927c478bd9Sstevel@tonic-gate */ 3937c478bd9Sstevel@tonic-gate struct rel_cache { 3947c478bd9Sstevel@tonic-gate Rel_desc *rc_end; 3957c478bd9Sstevel@tonic-gate Rel_desc *rc_free; 3967c478bd9Sstevel@tonic-gate }; 3977c478bd9Sstevel@tonic-gate 3987c478bd9Sstevel@tonic-gate /* 3997c478bd9Sstevel@tonic-gate * Symbol value descriptor. For relocatable objects, each symbols value is 4007c478bd9Sstevel@tonic-gate * its offset within its associated section. Therefore, to uniquely define 4017c478bd9Sstevel@tonic-gate * each symbol within a reloctable object, record and sort the sh_offset and 4027c478bd9Sstevel@tonic-gate * symbol value. This information is used to seach for displacement 4037c478bd9Sstevel@tonic-gate * relocations as part of copy relocation validation. 4047c478bd9Sstevel@tonic-gate */ 4057c478bd9Sstevel@tonic-gate typedef struct { 4067c478bd9Sstevel@tonic-gate Addr ssv_value; 4077c478bd9Sstevel@tonic-gate Sym_desc *ssv_sdp; 4087c478bd9Sstevel@tonic-gate } Ssv_desc; 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate /* 4117c478bd9Sstevel@tonic-gate * Input file processing structures. 4127c478bd9Sstevel@tonic-gate */ 4137c478bd9Sstevel@tonic-gate struct ifl_desc { /* input file descriptor */ 4147c478bd9Sstevel@tonic-gate const char *ifl_name; /* full file name */ 4157c478bd9Sstevel@tonic-gate const char *ifl_soname; /* shared object name */ 4167c478bd9Sstevel@tonic-gate dev_t ifl_stdev; /* device id and inode number for .so */ 4177c478bd9Sstevel@tonic-gate ino_t ifl_stino; /* multiple inclusion checks */ 4187c478bd9Sstevel@tonic-gate Ehdr *ifl_ehdr; /* elf header describing this file */ 4197c478bd9Sstevel@tonic-gate Elf *ifl_elf; /* elf descriptor for this file */ 4207c478bd9Sstevel@tonic-gate Sym_desc **ifl_oldndx; /* original symbol table indices */ 4217c478bd9Sstevel@tonic-gate Sym_desc *ifl_locs; /* symbol desc version of locals */ 4227c478bd9Sstevel@tonic-gate Ssv_desc *ifl_sortsyms; /* sorted list of symbols by value */ 4237c478bd9Sstevel@tonic-gate Word ifl_locscnt; /* no. of local symbols to process */ 4247c478bd9Sstevel@tonic-gate Word ifl_symscnt; /* total no. of symbols to process */ 4257c478bd9Sstevel@tonic-gate Word ifl_sortcnt; /* no. of sorted symbols to process */ 4267c478bd9Sstevel@tonic-gate Word ifl_shnum; /* number of sections in file */ 4277c478bd9Sstevel@tonic-gate Word ifl_shstrndx; /* index to .shstrtab */ 4287c478bd9Sstevel@tonic-gate Word ifl_vercnt; /* number of versions in file */ 4297c478bd9Sstevel@tonic-gate Is_desc **ifl_isdesc; /* isdesc[scn ndx] = Is_desc ptr */ 4307c478bd9Sstevel@tonic-gate Sdf_desc *ifl_sdfdesc; /* control definition */ 4317c478bd9Sstevel@tonic-gate Versym *ifl_versym; /* version symbol table array */ 4327c478bd9Sstevel@tonic-gate Ver_index *ifl_verndx; /* verndx[ver ndx] = Ver_index */ 4337c478bd9Sstevel@tonic-gate List ifl_verdesc; /* version descriptor list */ 4347c478bd9Sstevel@tonic-gate List ifl_relsect; /* relocation section list */ 435cc7efc4fSrie Alist *ifl_groups; /* SHT_GROUP section list */ 4367c478bd9Sstevel@tonic-gate Half ifl_neededndx; /* index to NEEDED in .dyn section */ 4377c478bd9Sstevel@tonic-gate Half ifl_flags; /* Explicit/implicit reference */ 4387c478bd9Sstevel@tonic-gate }; 4397c478bd9Sstevel@tonic-gate 4407c478bd9Sstevel@tonic-gate #define FLG_IF_CMDLINE 0x00001 /* full filename specified from the */ 4417c478bd9Sstevel@tonic-gate /* command line (no -l) */ 4427c478bd9Sstevel@tonic-gate #define FLG_IF_NEEDED 0x00002 /* shared object should be recorded */ 4437c478bd9Sstevel@tonic-gate #define FLG_IF_DIRECT 0x00004 /* establish direct bindings to this */ 4447c478bd9Sstevel@tonic-gate /* object */ 4457c478bd9Sstevel@tonic-gate #define FLG_IF_EXTRACT 0x00008 /* file extracted from an archive */ 4467c478bd9Sstevel@tonic-gate #define FLG_IF_VERNEED 0x00010 /* version dependency information is */ 4477c478bd9Sstevel@tonic-gate /* required */ 4487c478bd9Sstevel@tonic-gate #define FLG_IF_DEPREQD 0x00020 /* dependency is required to satisfy */ 4497c478bd9Sstevel@tonic-gate /* symbol references */ 4507c478bd9Sstevel@tonic-gate #define FLG_IF_NEEDSTR 0x00040 /* dependency specified by -Nn */ 4517c478bd9Sstevel@tonic-gate /* flag */ 4527c478bd9Sstevel@tonic-gate #define FLG_IF_IGNORE 0x00080 /* ignore unused dependencies */ 4537c478bd9Sstevel@tonic-gate #define FLG_IF_NODIRECT 0x00100 /* object contains symbols that */ 4547c478bd9Sstevel@tonic-gate /* cannot be directly bound to. */ 4557c478bd9Sstevel@tonic-gate #define FLG_IF_LAZYLD 0x00200 /* bindings to this object should be */ 4567c478bd9Sstevel@tonic-gate /* lazy loaded */ 4577c478bd9Sstevel@tonic-gate #define FLG_IF_GRPPRM 0x00400 /* this dependency should have the */ 4587c478bd9Sstevel@tonic-gate /* DF_P1_GROUPPERM flag set */ 4597c478bd9Sstevel@tonic-gate #define FLG_IF_DISPPEND 0x00800 /* displacement relocation done */ 4607c478bd9Sstevel@tonic-gate /* in the ld time. */ 4617c478bd9Sstevel@tonic-gate #define FLG_IF_DISPDONE 0x01000 /* displacement relocation done */ 4627c478bd9Sstevel@tonic-gate /* at the run time */ 4637c478bd9Sstevel@tonic-gate #define FLG_IF_MAPFILE 0x02000 /* file is a mapfile */ 4647c478bd9Sstevel@tonic-gate #define FLG_IF_HSTRTAB 0x04000 /* file has a string section */ 4657c478bd9Sstevel@tonic-gate #define FLG_IF_FILEREF 0x08000 /* file contains a section which */ 4667c478bd9Sstevel@tonic-gate /* is included in the output */ 4677c478bd9Sstevel@tonic-gate /* allocatable image */ 4687c478bd9Sstevel@tonic-gate 4697c478bd9Sstevel@tonic-gate struct is_desc { /* input section descriptor */ 4707c478bd9Sstevel@tonic-gate const char *is_name; /* the section name */ 4717c478bd9Sstevel@tonic-gate const char *is_basename; /* original section name (without */ 4727c478bd9Sstevel@tonic-gate /* .<sect>%<func> munging */ 4737c478bd9Sstevel@tonic-gate Shdr *is_shdr; /* the elf section header */ 4747c478bd9Sstevel@tonic-gate Ifl_desc *is_file; /* infile desc for this section */ 4757c478bd9Sstevel@tonic-gate Os_desc *is_osdesc; /* new output section for this */ 4767c478bd9Sstevel@tonic-gate /* input section */ 4777c478bd9Sstevel@tonic-gate Elf_Data *is_indata; /* input sections raw data */ 4787c478bd9Sstevel@tonic-gate Is_desc *is_symshndx; /* related SHT_SYM_SHNDX section */ 4797c478bd9Sstevel@tonic-gate Word is_scnndx; /* original section index in file */ 4807c478bd9Sstevel@tonic-gate Word is_txtndx; /* Index for section. Used to decide */ 4817c478bd9Sstevel@tonic-gate /* where to insert section when */ 4827c478bd9Sstevel@tonic-gate /* reordering sections */ 4837c478bd9Sstevel@tonic-gate Word is_ident; /* preserved IDENT used for ordered */ 4847c478bd9Sstevel@tonic-gate /* sections. */ 4857c478bd9Sstevel@tonic-gate uint_t is_namehash; /* hash on section name */ 4867c478bd9Sstevel@tonic-gate Half is_key; /* Used for SHF_ORDERED */ 4877c478bd9Sstevel@tonic-gate Half is_flags; /* Various flags */ 4887c478bd9Sstevel@tonic-gate }; 4897c478bd9Sstevel@tonic-gate 4907c478bd9Sstevel@tonic-gate #define FLG_IS_ORDERED 0x0001 /* This is a SHF_ORDERED section */ 4917c478bd9Sstevel@tonic-gate #define FLG_IS_KEY 0x0002 /* This is a section pointed by */ 4927c478bd9Sstevel@tonic-gate /* sh_info of a SHF_ORDERED section */ 4937c478bd9Sstevel@tonic-gate #define FLG_IS_DISCARD 0x0004 /* section is to be discarded */ 4947c478bd9Sstevel@tonic-gate #define FLG_IS_RELUPD 0x0008 /* symbol defined here may have moved */ 4957c478bd9Sstevel@tonic-gate #define FLG_IS_SECTREF 0x0010 /* section has been referenced */ 4967c478bd9Sstevel@tonic-gate #define FLG_IS_GDATADEF 0x0020 /* section contains global data sym */ 49754d82594Sseizo #define FLG_IS_EXTERNAL 0x0040 /* isp from an user file */ 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate 5007c478bd9Sstevel@tonic-gate /* 5017c478bd9Sstevel@tonic-gate * Map file and output file processing structures 5027c478bd9Sstevel@tonic-gate */ 5037c478bd9Sstevel@tonic-gate struct os_desc { /* Output section descriptor */ 5047c478bd9Sstevel@tonic-gate const char *os_name; /* the section name */ 5057c478bd9Sstevel@tonic-gate Elf_Scn *os_scn; /* the elf section descriptor */ 5067c478bd9Sstevel@tonic-gate Shdr *os_shdr; /* the elf section header */ 5077c478bd9Sstevel@tonic-gate Os_desc *os_relosdesc; /* the output relocation section */ 5087c478bd9Sstevel@tonic-gate List os_relisdescs; /* reloc input section descriptors */ 5097c478bd9Sstevel@tonic-gate /* for this output section */ 5107c478bd9Sstevel@tonic-gate List os_isdescs; /* list of input sections in output */ 5117c478bd9Sstevel@tonic-gate Sort_desc *os_sort; /* used for sorting sections */ 5127c478bd9Sstevel@tonic-gate Sg_desc *os_sgdesc; /* segment os_desc is placed on */ 5137c478bd9Sstevel@tonic-gate Elf_Data *os_outdata; /* output sections raw data */ 5147c478bd9Sstevel@tonic-gate List os_comdats; /* list of COMDAT sections present */ 5157c478bd9Sstevel@tonic-gate /* in current output section */ 5167c478bd9Sstevel@tonic-gate Word os_scnsymndx; /* index in output symtab of section */ 5177c478bd9Sstevel@tonic-gate /* symbol for this section */ 5187c478bd9Sstevel@tonic-gate Word os_txtndx; /* Index for section. Used to decide */ 5197c478bd9Sstevel@tonic-gate /* where to insert section when */ 5207c478bd9Sstevel@tonic-gate /* reordering sections */ 5217c478bd9Sstevel@tonic-gate Xword os_szoutrels; /* size of output relocation section */ 5227c478bd9Sstevel@tonic-gate uint_t os_namehash; /* hash on section name */ 5237c478bd9Sstevel@tonic-gate uchar_t os_flags; /* various flags */ 5247c478bd9Sstevel@tonic-gate }; 5257c478bd9Sstevel@tonic-gate 5267c478bd9Sstevel@tonic-gate #define FLG_OS_ORDER_KEY 0x01 /* include a sort key section */ 5277c478bd9Sstevel@tonic-gate #define FLG_OS_OUTREL 0x02 /* output rel against this section */ 528dd94ecefSrie #define FLG_OS_SECTREF 0x04 /* isps are not affected by -zignore */ 5297c478bd9Sstevel@tonic-gate 5307c478bd9Sstevel@tonic-gate /* 5317c478bd9Sstevel@tonic-gate * For sorting sections. 5327c478bd9Sstevel@tonic-gate */ 5337c478bd9Sstevel@tonic-gate struct sort_desc { 5347c478bd9Sstevel@tonic-gate Is_desc **st_order; 5357c478bd9Sstevel@tonic-gate Word st_ordercnt; 5367c478bd9Sstevel@tonic-gate Is_desc **st_before; 5377c478bd9Sstevel@tonic-gate Word st_beforecnt; 5387c478bd9Sstevel@tonic-gate Is_desc **st_after; 5397c478bd9Sstevel@tonic-gate Word st_aftercnt; 5407c478bd9Sstevel@tonic-gate }; 5417c478bd9Sstevel@tonic-gate 5427c478bd9Sstevel@tonic-gate struct sg_desc { /* output segment descriptor */ 5437c478bd9Sstevel@tonic-gate Phdr sg_phdr; /* segment header for output file */ 5447c478bd9Sstevel@tonic-gate const char *sg_name; /* segment name */ 5457c478bd9Sstevel@tonic-gate Xword sg_round; /* data rounding required (mapfile) */ 5467c478bd9Sstevel@tonic-gate Xword sg_length; /* maximum segment length; if 0 */ 5477c478bd9Sstevel@tonic-gate /* segment is not specified */ 548*0bc07c75Srie Alist *sg_osdescs; /* list of output section descriptors */ 549*0bc07c75Srie Alist *sg_secorder; /* list specifying section ordering */ 550*0bc07c75Srie /* for the segment */ 5517c478bd9Sstevel@tonic-gate Half sg_flags; 5527c478bd9Sstevel@tonic-gate Sym_desc *sg_sizesym; /* size symbol for this segment */ 5537c478bd9Sstevel@tonic-gate Xword sg_addralign; /* LCM of sh_addralign */ 5547c478bd9Sstevel@tonic-gate Elf_Scn *sg_fscn; /* the SCN of the first section. */ 5557c478bd9Sstevel@tonic-gate }; 5567c478bd9Sstevel@tonic-gate 5577c478bd9Sstevel@tonic-gate 5587c478bd9Sstevel@tonic-gate #define FLG_SG_VADDR 0x0001 /* vaddr segment attribute set */ 5597c478bd9Sstevel@tonic-gate #define FLG_SG_PADDR 0x0002 /* paddr segment attribute set */ 5607c478bd9Sstevel@tonic-gate #define FLG_SG_LENGTH 0x0004 /* length segment attribute set */ 5617c478bd9Sstevel@tonic-gate #define FLG_SG_ALIGN 0x0008 /* align segment attribute set */ 5627c478bd9Sstevel@tonic-gate #define FLG_SG_ROUND 0x0010 /* round segment attribute set */ 5637c478bd9Sstevel@tonic-gate #define FLG_SG_FLAGS 0x0020 /* flags segment attribute set */ 5647c478bd9Sstevel@tonic-gate #define FLG_SG_TYPE 0x0040 /* type segment attribute set */ 5657c478bd9Sstevel@tonic-gate #define FLG_SG_ORDER 0x0080 /* has ordering been turned on for */ 5667c478bd9Sstevel@tonic-gate /* this segment. */ 5677c478bd9Sstevel@tonic-gate /* i.e. ?[O] option in mapfile */ 5687c478bd9Sstevel@tonic-gate #define FLG_SG_NOHDR 0x0100 /* don't map ELF or phdrs into */ 5697c478bd9Sstevel@tonic-gate /* this segment */ 5707c478bd9Sstevel@tonic-gate #define FLG_SG_EMPTY 0x0200 /* an empty segment specification */ 5717c478bd9Sstevel@tonic-gate /* no input sections will be */ 5727c478bd9Sstevel@tonic-gate /* associated to this section */ 5737c478bd9Sstevel@tonic-gate #define FLG_SG_KEY 0x0400 /* include a key section */ 5747c478bd9Sstevel@tonic-gate #define FLG_SG_DISABLED 0x0800 /* this segment is disabled */ 57554d82594Sseizo #define FLG_SG_PHREQ 0x1000 /* this segment requires a program */ 57654d82594Sseizo /* header */ 5777c478bd9Sstevel@tonic-gate 5787c478bd9Sstevel@tonic-gate struct sec_order { 5797c478bd9Sstevel@tonic-gate const char *sco_secname; /* section name to be ordered */ 5807c478bd9Sstevel@tonic-gate Word sco_index; /* ordering index for section */ 5817c478bd9Sstevel@tonic-gate Half sco_flags; 5827c478bd9Sstevel@tonic-gate }; 5837c478bd9Sstevel@tonic-gate 5847c478bd9Sstevel@tonic-gate #define FLG_SGO_USED 0x0001 /* was ordering used? */ 5857c478bd9Sstevel@tonic-gate 5867c478bd9Sstevel@tonic-gate struct ent_desc { /* input section entrance criteria */ 5877c478bd9Sstevel@tonic-gate List ec_files; /* files from which to accept */ 5887c478bd9Sstevel@tonic-gate /* sections */ 5897c478bd9Sstevel@tonic-gate const char *ec_name; /* name to match (NULL if none) */ 5907c478bd9Sstevel@tonic-gate Word ec_type; /* section type */ 59154d82594Sseizo Word ec_attrmask; /* section attribute mask (AWX) */ 59254d82594Sseizo Word ec_attrbits; /* sections attribute bits */ 5937c478bd9Sstevel@tonic-gate Sg_desc *ec_segment; /* output segment to enter if matched */ 5947c478bd9Sstevel@tonic-gate Word ec_ndx; /* index to determine where section */ 5957c478bd9Sstevel@tonic-gate /* meeting this criteria should */ 5967c478bd9Sstevel@tonic-gate /* inserted. Used for reordering */ 5977c478bd9Sstevel@tonic-gate /* of sections. */ 5987c478bd9Sstevel@tonic-gate Half ec_flags; 5997c478bd9Sstevel@tonic-gate }; 6007c478bd9Sstevel@tonic-gate 6017c478bd9Sstevel@tonic-gate #define FLG_EC_USED 0x0001 /* entrance criteria met? */ 6027c478bd9Sstevel@tonic-gate 6037c478bd9Sstevel@tonic-gate /* 6047c478bd9Sstevel@tonic-gate * Move supplementary structures 6057c478bd9Sstevel@tonic-gate * Sorted by symbol local/global and then by name. 6067c478bd9Sstevel@tonic-gate */ 6077c478bd9Sstevel@tonic-gate typedef struct psym_info { 6087c478bd9Sstevel@tonic-gate Sym_desc *psym_symd; /* partially initialized symbol */ 6097c478bd9Sstevel@tonic-gate Word psym_num; /* number of move entires */ 6107c478bd9Sstevel@tonic-gate Half psym_flag; /* various flag */ 6117c478bd9Sstevel@tonic-gate List psym_mvs; /* the list of move entries */ 6127c478bd9Sstevel@tonic-gate } Psym_info; 6137c478bd9Sstevel@tonic-gate 6147c478bd9Sstevel@tonic-gate #define FLG_PSYM_OVERLAP 0x01 /* Overlapping */ 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate /* 6177c478bd9Sstevel@tonic-gate * One structure is allocated for a move entry. 6187c478bd9Sstevel@tonic-gate */ 6197c478bd9Sstevel@tonic-gate typedef struct mv_itm { 6207c478bd9Sstevel@tonic-gate Xword mv_start; /* start position */ 6217c478bd9Sstevel@tonic-gate Xword mv_length; /* The length of initialization */ 6227c478bd9Sstevel@tonic-gate Half mv_flag; /* various flags */ 6237c478bd9Sstevel@tonic-gate Is_desc *mv_isp; /* input desc. this entry is from */ 6247c478bd9Sstevel@tonic-gate Move *mv_ientry; /* Input Move_entry */ 6257c478bd9Sstevel@tonic-gate Word mv_oidx; /* Output Move_entry index */ 6267c478bd9Sstevel@tonic-gate } Mv_itm; 6277c478bd9Sstevel@tonic-gate 6287c478bd9Sstevel@tonic-gate #define FLG_MV_OUTSECT 0x01 /* Will be in move section */ 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate /* 6317c478bd9Sstevel@tonic-gate * Define a move descripter used within relocation structures. 6327c478bd9Sstevel@tonic-gate */ 6337c478bd9Sstevel@tonic-gate struct mv_desc { 6347c478bd9Sstevel@tonic-gate Move *mvd_move; 6357c478bd9Sstevel@tonic-gate Sym_desc *mvd_sym; 6367c478bd9Sstevel@tonic-gate }; 6377c478bd9Sstevel@tonic-gate 6387c478bd9Sstevel@tonic-gate struct sym_desc { 6397c478bd9Sstevel@tonic-gate List sd_GOTndxs; /* list of associated GOT entries */ 6407c478bd9Sstevel@tonic-gate Sym *sd_sym; /* pointer to symbol table entry */ 6417c478bd9Sstevel@tonic-gate Sym *sd_osym; /* copy of the original symbol entry */ 6427c478bd9Sstevel@tonic-gate /* Used only for local partial */ 6437c478bd9Sstevel@tonic-gate Psym_info *sd_psyminfo; /* If this is partial symbol, this */ 6447c478bd9Sstevel@tonic-gate /* field holds the pointer to */ 6457c478bd9Sstevel@tonic-gate /* parsym_info */ 6467c478bd9Sstevel@tonic-gate const char *sd_name; /* symbols name */ 6477c478bd9Sstevel@tonic-gate Ifl_desc *sd_file; /* file where symbol is taken */ 6487c478bd9Sstevel@tonic-gate Is_desc *sd_isc; /* input section of symbol definition */ 6497c478bd9Sstevel@tonic-gate Sym_aux *sd_aux; /* auxiliary global symbol info. */ 6507c478bd9Sstevel@tonic-gate Word sd_symndx; /* index in output symbol table */ 6517c478bd9Sstevel@tonic-gate Word sd_shndx; /* sect. index sym is associated w/ */ 6527c478bd9Sstevel@tonic-gate Word sd_flags; /* state flags */ 6537c478bd9Sstevel@tonic-gate Half sd_flags1; /* more symbol flags */ 6547c478bd9Sstevel@tonic-gate Half sd_ref; /* reference definition of symbol */ 6557c478bd9Sstevel@tonic-gate }; 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate /* 6587c478bd9Sstevel@tonic-gate * The auxiliary symbol descriptor contains the additional information (beyond 6597c478bd9Sstevel@tonic-gate * the symbol descriptor) required to process global symbols. These symbols are 6607c478bd9Sstevel@tonic-gate * accessed via an internal symbol hash table where locality of reference is 6617c478bd9Sstevel@tonic-gate * important for performance. 6627c478bd9Sstevel@tonic-gate */ 6637c478bd9Sstevel@tonic-gate struct sym_aux { 6647c478bd9Sstevel@tonic-gate List sa_dfiles; /* files where symbol is defined */ 6657c478bd9Sstevel@tonic-gate Sym sa_sym; /* copy of symtab entry */ 6667c478bd9Sstevel@tonic-gate const char *sa_vfile; /* first unavailable definition */ 6677c478bd9Sstevel@tonic-gate Ifl_desc *sa_bindto; /* symbol to bind to - for translator */ 6687c478bd9Sstevel@tonic-gate const char *sa_rfile; /* file with first symbol referenced */ 6697c478bd9Sstevel@tonic-gate Word sa_hash; /* the pure hash value of symbol */ 6707c478bd9Sstevel@tonic-gate Word sa_PLTndx; /* index into PLT for symbol */ 6717c478bd9Sstevel@tonic-gate Word sa_PLTGOTndx; /* GOT entry indx for PLT indirection */ 6727c478bd9Sstevel@tonic-gate Word sa_linkndx; /* index of associated symbol */ 6737c478bd9Sstevel@tonic-gate Half sa_symspec; /* special symbol ids */ 6747c478bd9Sstevel@tonic-gate Half sa_overndx; /* output file versioning index */ 6757c478bd9Sstevel@tonic-gate Half sa_dverndx; /* dependency versioning index */ 6767c478bd9Sstevel@tonic-gate }; 6777c478bd9Sstevel@tonic-gate 6787c478bd9Sstevel@tonic-gate 6797c478bd9Sstevel@tonic-gate /* 6807c478bd9Sstevel@tonic-gate * Nodes used to track symbols in the global AVL symbol dictionary. 6817c478bd9Sstevel@tonic-gate */ 6827c478bd9Sstevel@tonic-gate struct sym_avlnode { 6837c478bd9Sstevel@tonic-gate avl_node_t sav_node; /* AVL node */ 6847c478bd9Sstevel@tonic-gate Word sav_hash; /* symbol hash value */ 6857c478bd9Sstevel@tonic-gate const char *sav_name; /* symbol name */ 6867c478bd9Sstevel@tonic-gate Sym_desc *sav_symdesc; /* SymDesc entry */ 6877c478bd9Sstevel@tonic-gate }; 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate /* 6907c478bd9Sstevel@tonic-gate * These are the ids for processing of `Special symbols'. They are used 6917c478bd9Sstevel@tonic-gate * to set the sym->sd_aux->sa_symspec field. 6927c478bd9Sstevel@tonic-gate */ 6937c478bd9Sstevel@tonic-gate #define SDAUX_ID_ETEXT 1 /* etext && _etext symbol */ 6947c478bd9Sstevel@tonic-gate #define SDAUX_ID_EDATA 2 /* edata && _edata symbol */ 6957c478bd9Sstevel@tonic-gate #define SDAUX_ID_END 3 /* end, _end, && _END_ symbol */ 6967c478bd9Sstevel@tonic-gate #define SDAUX_ID_DYN 4 /* DYNAMIC && _DYNAMIC symbol */ 6977c478bd9Sstevel@tonic-gate #define SDAUX_ID_PLT 5 /* _PROCEDURE_LINKAGE_TABLE_ symbol */ 6987c478bd9Sstevel@tonic-gate #define SDAUX_ID_GOT 6 /* _GLOBAL_OFFSET_TABLE_ symbol */ 6997c478bd9Sstevel@tonic-gate #define SDAUX_ID_START 7 /* START_ && _START_ symbol */ 7007c478bd9Sstevel@tonic-gate 7017c478bd9Sstevel@tonic-gate /* 7027c478bd9Sstevel@tonic-gate * Flags for sym_desc.sd_flags 7037c478bd9Sstevel@tonic-gate */ 7047c478bd9Sstevel@tonic-gate #define FLG_SY_MVTOCOMM 0x00000001 /* assign symbol to common (.bss) */ 7057c478bd9Sstevel@tonic-gate /* this is a result of a */ 7067c478bd9Sstevel@tonic-gate /* copy reloc against sym */ 7077c478bd9Sstevel@tonic-gate #define FLG_SY_GLOBREF 0x00000002 /* a global reference has been seen */ 7087c478bd9Sstevel@tonic-gate #define FLG_SY_WEAKDEF 0x00000004 /* a weak definition has been used */ 7097c478bd9Sstevel@tonic-gate #define FLG_SY_CLEAN 0x00000008 /* `Sym' entry points to original */ 7107c478bd9Sstevel@tonic-gate /* input file (read-only). */ 7117c478bd9Sstevel@tonic-gate #define FLG_SY_UPREQD 0x00000010 /* symbol value update is required, */ 7127c478bd9Sstevel@tonic-gate /* either it's used as an entry */ 7137c478bd9Sstevel@tonic-gate /* point or for relocation, but */ 7147c478bd9Sstevel@tonic-gate /* it must be updated even if */ 7157c478bd9Sstevel@tonic-gate /* the -s flag is in effect */ 7167c478bd9Sstevel@tonic-gate #define FLG_SY_NOTAVAIL 0x00000020 /* symbol is not available to the */ 7177c478bd9Sstevel@tonic-gate /* application either because it */ 7187c478bd9Sstevel@tonic-gate /* originates from an implicitly */ 7197c478bd9Sstevel@tonic-gate /* referenced shared object, or */ 7207c478bd9Sstevel@tonic-gate /* because it is not part of a */ 7217c478bd9Sstevel@tonic-gate /* specified version. */ 7227c478bd9Sstevel@tonic-gate #define FLG_SY_REDUCED 0x00000040 /* a global is reduced to local */ 7237c478bd9Sstevel@tonic-gate #define FLG_SY_VERSPROM 0x00000080 /* version definition has been */ 7247c478bd9Sstevel@tonic-gate /* promoted to output file */ 7257c478bd9Sstevel@tonic-gate #define FLG_SY_PROT 0x00000100 /* stv_protected visibility seen */ 7267c478bd9Sstevel@tonic-gate 7277c478bd9Sstevel@tonic-gate #define FLG_SY_MAPREF 0x00000200 /* symbol reference generated by user */ 7287c478bd9Sstevel@tonic-gate /* from mapfile */ 7297c478bd9Sstevel@tonic-gate #define FLG_SY_REFRSD 0x00000400 /* symbols sd_ref has been raised */ 7307c478bd9Sstevel@tonic-gate /* due to a copy-relocs */ 7317c478bd9Sstevel@tonic-gate /* weak-strong pairing */ 7327c478bd9Sstevel@tonic-gate 7337c478bd9Sstevel@tonic-gate #define FLG_SY_INVALID 0x00001000 /* unwanted/erroneous symbol */ 7347c478bd9Sstevel@tonic-gate #define FLG_SY_SMGOT 0x00002000 /* small got index assigned to symbol */ 7357c478bd9Sstevel@tonic-gate /* sparc only */ 7367c478bd9Sstevel@tonic-gate #define FLG_SY_PARENT 0x00004000 /* symbol to be found in parent */ 7377c478bd9Sstevel@tonic-gate /* only used with direct bindings */ 7387c478bd9Sstevel@tonic-gate #define FLG_SY_LAZYLD 0x00008000 /* symbol to cause lazyloading of */ 7397c478bd9Sstevel@tonic-gate /* parent object */ 7407c478bd9Sstevel@tonic-gate #define FLG_SY_ISDISC 0x00010000 /* symbol is a member of a DISCARDED */ 7417c478bd9Sstevel@tonic-gate /* section (COMDAT) */ 7427c478bd9Sstevel@tonic-gate #define FLG_SY_PAREXPN 0x00020000 /* partially init. symbol to be */ 7437c478bd9Sstevel@tonic-gate /* expanded */ 7447c478bd9Sstevel@tonic-gate #define FLG_SY_PLTPAD 0x00040000 /* pltpadding has been allocated for */ 7457c478bd9Sstevel@tonic-gate /* this symbol */ 7467c478bd9Sstevel@tonic-gate #define FLG_SY_REGSYM 0x00080000 /* REGISTER symbol (sparc only) */ 7477c478bd9Sstevel@tonic-gate #define FLG_SY_SOFOUND 0x00100000 /* compared against an SO definition */ 7487c478bd9Sstevel@tonic-gate #define FLG_SY_EXTERN 0x00200000 /* symbol is external, allows -zdefs */ 7497c478bd9Sstevel@tonic-gate /* error suppression */ 7507c478bd9Sstevel@tonic-gate #define FLG_SY_MAPUSED 0x00400000 /* mapfile symbol used (occurred */ 7517c478bd9Sstevel@tonic-gate /* within a relocatable object) */ 7527c478bd9Sstevel@tonic-gate #define FLG_SY_COMMEXP 0x00800000 /* COMMON symbol which has been */ 7537c478bd9Sstevel@tonic-gate /* allocated */ 7547c478bd9Sstevel@tonic-gate #define FLG_SY_CMDREF 0x01000000 /* symbol was referenced from the */ 7557c478bd9Sstevel@tonic-gate /* command line. (ld -u <>, */ 7567c478bd9Sstevel@tonic-gate /* ld -zrtldinfo=<>, ...) */ 7577c478bd9Sstevel@tonic-gate #define FLG_SY_SPECSEC 0x02000000 /* section index is reserved value */ 7587c478bd9Sstevel@tonic-gate /* ABS, COMMON, ... */ 7597c478bd9Sstevel@tonic-gate #define FLG_SY_TENTSYM 0x04000000 /* tentative symbol */ 7607c478bd9Sstevel@tonic-gate #define FLG_SY_VISIBLE 0x08000000 /* symbols visibility determined */ 7617c478bd9Sstevel@tonic-gate #define FLG_SY_STDFLTR 0x10000000 /* symbol is a standard filter */ 7627c478bd9Sstevel@tonic-gate #define FLG_SY_AUXFLTR 0x20000000 /* symbol is an auxiliary filter */ 7637c478bd9Sstevel@tonic-gate 7647c478bd9Sstevel@tonic-gate /* 7657c478bd9Sstevel@tonic-gate * Sym_desc.sd_flags1 7667c478bd9Sstevel@tonic-gate */ 7677c478bd9Sstevel@tonic-gate #define FLG_SY1_GLOB 0x00000001 /* global symbol, remain global */ 7687c478bd9Sstevel@tonic-gate #define FLG_SY1_PROT 0x00000002 /* global symbol, reduce to protected */ 7697c478bd9Sstevel@tonic-gate #define FLG_SY1_LOCL 0x00000004 /* global symbol, reduce to local */ 7707c478bd9Sstevel@tonic-gate #define FLG_SY1_DIR 0x00000008 /* global symbol, direct bindings */ 7717c478bd9Sstevel@tonic-gate #define FLG_SY1_NDIR 0x00000010 /* global symbol, nondirect bindings */ 7727c478bd9Sstevel@tonic-gate #define FLG_SY1_ELIM 0x00000020 /* global symbol, eliminate */ 7737c478bd9Sstevel@tonic-gate #define FLG_SY1_IGNORE 0x00000040 /* symbol should be ignored */ 7747c478bd9Sstevel@tonic-gate 7757c478bd9Sstevel@tonic-gate #define MSK_SY1_DEFINED (FLG_SY1_GLOB | FLG_SY1_PROT | FLG_SY1_LOCL) 7767c478bd9Sstevel@tonic-gate /* The above mask indicates that */ 7777c478bd9Sstevel@tonic-gate /* a symbol has been explicitly */ 7787c478bd9Sstevel@tonic-gate /* scoped, and therefore is not */ 7797c478bd9Sstevel@tonic-gate /* a candidate for auto-reduction */ 7807c478bd9Sstevel@tonic-gate 7817c478bd9Sstevel@tonic-gate /* 7827c478bd9Sstevel@tonic-gate * create a mask for (Sym.St_other & visibility) since the 7837c478bd9Sstevel@tonic-gate * gABI does not yet define a ELF*_ST_OTHER macro. 7847c478bd9Sstevel@tonic-gate */ 7857c478bd9Sstevel@tonic-gate #define MSK_SYM_VISIBILITY 0x03 7867c478bd9Sstevel@tonic-gate 7877c478bd9Sstevel@tonic-gate /* 7887c478bd9Sstevel@tonic-gate * Structure to manage the shared object definition lists. There are two lists 7897c478bd9Sstevel@tonic-gate * that use this structure: 7907c478bd9Sstevel@tonic-gate * 7917c478bd9Sstevel@tonic-gate * o ofl_soneed; maintain the list of implicitly required dependencies 7927c478bd9Sstevel@tonic-gate * (ie. shared objects needed by other shared objects). These definitions 7937c478bd9Sstevel@tonic-gate * may include RPATH's required to locate the dependencies, and any 7947c478bd9Sstevel@tonic-gate * version requirements. 7957c478bd9Sstevel@tonic-gate * 7967c478bd9Sstevel@tonic-gate * o ofl_socntl; maintains the shared object control definitions. These are 7977c478bd9Sstevel@tonic-gate * provided by the user (via a mapfile) and are used to indicate any 7987c478bd9Sstevel@tonic-gate * SONAME translations and verion control requirements. 7997c478bd9Sstevel@tonic-gate */ 8007c478bd9Sstevel@tonic-gate struct sdf_desc { 8017c478bd9Sstevel@tonic-gate const char *sdf_name; /* the shared objects file name */ 8027c478bd9Sstevel@tonic-gate const char *sdf_soname; /* the shared objects SONAME */ 8037c478bd9Sstevel@tonic-gate char *sdf_rpath; /* library search path DT_RPATH */ 8047c478bd9Sstevel@tonic-gate const char *sdf_rfile; /* referencing file for diagnostics */ 8057c478bd9Sstevel@tonic-gate Ifl_desc *sdf_file; /* the final input file descriptor */ 8067c478bd9Sstevel@tonic-gate List sdf_vers; /* list of versions that are required */ 8077c478bd9Sstevel@tonic-gate /* from this object */ 8087c478bd9Sstevel@tonic-gate List sdf_verneed; /* list of VERNEEDS to create for */ 8097c478bd9Sstevel@tonic-gate /* this object (via SPECVERS or */ 8107c478bd9Sstevel@tonic-gate /* ADDVERS) */ 8117c478bd9Sstevel@tonic-gate Word sdf_flags; 8127c478bd9Sstevel@tonic-gate }; 8137c478bd9Sstevel@tonic-gate 8147c478bd9Sstevel@tonic-gate #define FLG_SDF_SONAME 0x02 /* An alternative SONAME is supplied */ 8157c478bd9Sstevel@tonic-gate #define FLG_SDF_SELECT 0x04 /* version control selection required */ 8167c478bd9Sstevel@tonic-gate #define FLG_SDF_VERIFY 0x08 /* version definition verification */ 8177c478bd9Sstevel@tonic-gate /* required */ 8187c478bd9Sstevel@tonic-gate #define FLG_SDF_SPECVER 0x10 /* specify VERNEEDS */ 8197c478bd9Sstevel@tonic-gate #define FLG_SDF_ADDVER 0x20 /* add VERNEED references */ 8207c478bd9Sstevel@tonic-gate 8217c478bd9Sstevel@tonic-gate /* 8227c478bd9Sstevel@tonic-gate * Structure to manage shared object version usage requirements. 8237c478bd9Sstevel@tonic-gate */ 8247c478bd9Sstevel@tonic-gate struct sdv_desc { 8257c478bd9Sstevel@tonic-gate const char *sdv_name; /* version name */ 8267c478bd9Sstevel@tonic-gate const char *sdv_ref; /* versions reference */ 8277c478bd9Sstevel@tonic-gate Word sdv_flags; /* flags */ 8287c478bd9Sstevel@tonic-gate }; 8297c478bd9Sstevel@tonic-gate 8307c478bd9Sstevel@tonic-gate #define FLG_SDV_MATCHED 0x01 /* VERDEF found and matched */ 8317c478bd9Sstevel@tonic-gate 8327c478bd9Sstevel@tonic-gate /* 8337c478bd9Sstevel@tonic-gate * Structures to manage versioning information. Two versioning structures are 8347c478bd9Sstevel@tonic-gate * defined: 8357c478bd9Sstevel@tonic-gate * 8367c478bd9Sstevel@tonic-gate * o a version descriptor maintains a linked list of versions and their 8377c478bd9Sstevel@tonic-gate * associated dependencies. This is used to build the version definitions 8387c478bd9Sstevel@tonic-gate * for an image being created (see map_symbol), and to determine the 8397c478bd9Sstevel@tonic-gate * version dependency graph for any input files that are versioned. 8407c478bd9Sstevel@tonic-gate * 8417c478bd9Sstevel@tonic-gate * o a version index array contains each version of an input file that is 8427c478bd9Sstevel@tonic-gate * being processed. It informs us which versions are available for 8437c478bd9Sstevel@tonic-gate * binding, and is used to generate any version dependency information. 8447c478bd9Sstevel@tonic-gate */ 8457c478bd9Sstevel@tonic-gate struct ver_desc { 8467c478bd9Sstevel@tonic-gate const char *vd_name; /* version name */ 8477c478bd9Sstevel@tonic-gate Word vd_hash; /* hash value of name */ 8487c478bd9Sstevel@tonic-gate Ifl_desc *vd_file; /* file that defined version */ 8497c478bd9Sstevel@tonic-gate Half vd_ndx; /* coordinates with symbol index */ 8507c478bd9Sstevel@tonic-gate Half vd_flags; /* version information */ 8517c478bd9Sstevel@tonic-gate List vd_deps; /* version dependencies */ 8527c478bd9Sstevel@tonic-gate Ver_desc *vd_ref; /* dependency's first reference */ 8537c478bd9Sstevel@tonic-gate }; 8547c478bd9Sstevel@tonic-gate 8557c478bd9Sstevel@tonic-gate struct ver_index { 8567c478bd9Sstevel@tonic-gate const char *vi_name; /* dependency version name */ 8577c478bd9Sstevel@tonic-gate Half vi_flags; /* communicates availability */ 8587c478bd9Sstevel@tonic-gate Ver_desc *vi_desc; /* cross reference to descriptor */ 8597c478bd9Sstevel@tonic-gate }; 8607c478bd9Sstevel@tonic-gate 8617c478bd9Sstevel@tonic-gate /* 8627c478bd9Sstevel@tonic-gate * Define any internal version descriptor flags ([vd|vi]_flags). Note that the 8637c478bd9Sstevel@tonic-gate * first byte is reserved for user visible flags (refer VER_FLG's in link.h). 8647c478bd9Sstevel@tonic-gate */ 8657c478bd9Sstevel@tonic-gate #define MSK_VER_USER 0x0f /* mask for user visible flags */ 8667c478bd9Sstevel@tonic-gate 8677c478bd9Sstevel@tonic-gate #define FLG_VER_AVAIL 0x10 /* version is available for binding */ 8687c478bd9Sstevel@tonic-gate #define FLG_VER_REFER 0x20 /* version has been referenced */ 8697c478bd9Sstevel@tonic-gate #define FLG_VER_SELECT 0x40 /* version has been selected by user */ 8707c478bd9Sstevel@tonic-gate #define FLG_VER_CYCLIC 0x80 /* a member of cyclic dependency */ 8717c478bd9Sstevel@tonic-gate 8727c478bd9Sstevel@tonic-gate 8737c478bd9Sstevel@tonic-gate /* 8747c478bd9Sstevel@tonic-gate * isalist(1) descriptor - used to break an isalist string into its component 8757c478bd9Sstevel@tonic-gate * options. 8767c478bd9Sstevel@tonic-gate */ 8777c478bd9Sstevel@tonic-gate struct isa_opt { 8787c478bd9Sstevel@tonic-gate char *isa_name; /* individual isa option name */ 8797c478bd9Sstevel@tonic-gate size_t isa_namesz; /* and associated size */ 8807c478bd9Sstevel@tonic-gate }; 8817c478bd9Sstevel@tonic-gate 8827c478bd9Sstevel@tonic-gate struct isa_desc { 8837c478bd9Sstevel@tonic-gate char *isa_list; /* sysinfo(SI_ISALIST) list */ 8847c478bd9Sstevel@tonic-gate size_t isa_listsz; /* and associated size */ 8857c478bd9Sstevel@tonic-gate Isa_opt *isa_opt; /* table of individual isa options */ 8867c478bd9Sstevel@tonic-gate size_t isa_optno; /* and associated number */ 8877c478bd9Sstevel@tonic-gate }; 8887c478bd9Sstevel@tonic-gate 8897c478bd9Sstevel@tonic-gate /* 8907c478bd9Sstevel@tonic-gate * uname(2) descriptor - used to break a utsname structure into its component 8917c478bd9Sstevel@tonic-gate * options (at least those that we're interested in). 8927c478bd9Sstevel@tonic-gate */ 8937c478bd9Sstevel@tonic-gate struct uts_desc { 8947c478bd9Sstevel@tonic-gate char *uts_osname; /* operating system name */ 8957c478bd9Sstevel@tonic-gate size_t uts_osnamesz; /* and associated size */ 8967c478bd9Sstevel@tonic-gate char *uts_osrel; /* operating system release */ 8977c478bd9Sstevel@tonic-gate size_t uts_osrelsz; /* and associated size */ 8987c478bd9Sstevel@tonic-gate }; 8997c478bd9Sstevel@tonic-gate 9007c478bd9Sstevel@tonic-gate 9017c478bd9Sstevel@tonic-gate /* 9027c478bd9Sstevel@tonic-gate * SHT_GROUP descriptor - used to track group sections at the global 9037c478bd9Sstevel@tonic-gate * level to resolve conflicts/determine which to keep. 9047c478bd9Sstevel@tonic-gate */ 9057c478bd9Sstevel@tonic-gate struct group_desc { 9067c478bd9Sstevel@tonic-gate const char *gd_gsectname; /* group section name */ 9077c478bd9Sstevel@tonic-gate const char *gd_symname; /* symbol name */ 908cc7efc4fSrie Word *gd_data; /* data for group section */ 909cc7efc4fSrie size_t gd_scnndx; /* group section index */ 910cc7efc4fSrie size_t gd_cnt; /* number of entries in group data */ 9117c478bd9Sstevel@tonic-gate Word gd_flags; 9127c478bd9Sstevel@tonic-gate }; 9137c478bd9Sstevel@tonic-gate 9147c478bd9Sstevel@tonic-gate #define GRP_FLG_DISCARD 0x0001 /* group is to be discarded */ 9157c478bd9Sstevel@tonic-gate 9167c478bd9Sstevel@tonic-gate /* 9177c478bd9Sstevel@tonic-gate * Indexes into the ld_support_funcs[] table. 9187c478bd9Sstevel@tonic-gate */ 9197c478bd9Sstevel@tonic-gate typedef enum { 9207c478bd9Sstevel@tonic-gate LDS_VERSION = 0, 9217c478bd9Sstevel@tonic-gate LDS_INPUT_DONE, 9227c478bd9Sstevel@tonic-gate LDS_START, 9237c478bd9Sstevel@tonic-gate LDS_ATEXIT, 9247c478bd9Sstevel@tonic-gate LDS_FILE, 9257c478bd9Sstevel@tonic-gate LDS_INP_SECTION, 9267c478bd9Sstevel@tonic-gate LDS_SECTION, 9277c478bd9Sstevel@tonic-gate LDS_NUM 9287c478bd9Sstevel@tonic-gate } Support_ndx; 9297c478bd9Sstevel@tonic-gate 9307c478bd9Sstevel@tonic-gate 9317c478bd9Sstevel@tonic-gate /* 9327c478bd9Sstevel@tonic-gate * Structure to manage archive member caching. Each archive has an archive 9337c478bd9Sstevel@tonic-gate * descriptor (Ar_desc) associated with it. This contains pointers to the 9347c478bd9Sstevel@tonic-gate * archive symbol table (obtained by elf_getarsyms(3e)) and an auxiliary 9357c478bd9Sstevel@tonic-gate * structure (Ar_uax[]) that parallels this symbol table. The member element 9367c478bd9Sstevel@tonic-gate * of this auxiliary table indicates whether the archive member associated with 9377c478bd9Sstevel@tonic-gate * the symbol offset has already been extracted (AREXTRACTED) or partially 9387c478bd9Sstevel@tonic-gate * processed (refer process_member()). 9397c478bd9Sstevel@tonic-gate */ 9407c478bd9Sstevel@tonic-gate typedef struct ar_mem { 9417c478bd9Sstevel@tonic-gate Elf *am_elf; /* elf descriptor for this member */ 9427c478bd9Sstevel@tonic-gate char *am_name; /* members name */ 9437c478bd9Sstevel@tonic-gate char *am_path; /* path (ie. lib(foo.o)) */ 9447c478bd9Sstevel@tonic-gate Sym *am_syms; /* start of global symbols */ 9457c478bd9Sstevel@tonic-gate char *am_strs; /* associated string table start */ 9467c478bd9Sstevel@tonic-gate Xword am_symn; /* no. of global symbols */ 9477c478bd9Sstevel@tonic-gate } Ar_mem; 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gate typedef struct ar_aux { 9507c478bd9Sstevel@tonic-gate Sym_desc *au_syms; /* internal symbol descriptor */ 9517c478bd9Sstevel@tonic-gate Ar_mem *au_mem; /* associated member */ 9527c478bd9Sstevel@tonic-gate } Ar_aux; 9537c478bd9Sstevel@tonic-gate 9547c478bd9Sstevel@tonic-gate #define FLG_ARMEM_PROC (Ar_mem *)-1 9557c478bd9Sstevel@tonic-gate 9567c478bd9Sstevel@tonic-gate typedef struct ar_desc { 9577c478bd9Sstevel@tonic-gate const char *ad_name; /* archive file name */ 9587c478bd9Sstevel@tonic-gate Elf *ad_elf; /* elf descriptor for the archive */ 9597c478bd9Sstevel@tonic-gate Elf_Arsym *ad_start; /* archive symbol table start */ 9607c478bd9Sstevel@tonic-gate Ar_aux *ad_aux; /* auxiliary symbol information */ 9617c478bd9Sstevel@tonic-gate dev_t ad_stdev; /* device id and inode number for */ 9627c478bd9Sstevel@tonic-gate ino_t ad_stino; /* multiple inclusion checks */ 9637c478bd9Sstevel@tonic-gate Word ad_flags; /* archive specific cmd line flags */ 9647c478bd9Sstevel@tonic-gate } Ar_desc; 9657c478bd9Sstevel@tonic-gate 9667c478bd9Sstevel@tonic-gate /* 9677c478bd9Sstevel@tonic-gate * Define any archive descriptor flags. NOTE, make sure they do not clash with 9687c478bd9Sstevel@tonic-gate * any output file descriptor archive extraction flags, as these are saved in 9697c478bd9Sstevel@tonic-gate * the same entry (see MSK_OF1_ARCHIVE). 9707c478bd9Sstevel@tonic-gate */ 9717c478bd9Sstevel@tonic-gate #define FLG_ARD_EXTRACT 0x00010000 /* archive member has been extracted */ 9727c478bd9Sstevel@tonic-gate 9737c478bd9Sstevel@tonic-gate /* 9745aefb655Srie * Function Declarations. 9757c478bd9Sstevel@tonic-gate */ 9765aefb655Srie #if defined(_ELF64) 9775aefb655Srie 9785aefb655Srie #define ld_create_outfile ld64_create_outfile 9795aefb655Srie #define ld_ent_setup ld64_ent_setup 9805aefb655Srie #define ld_ofl_cleanup ld64_ofl_cleanup 9815aefb655Srie #define ld_make_sections ld64_make_sections 9825aefb655Srie #define ld_main ld64_main 9835aefb655Srie #define ld_process_open ld64_process_open 9845aefb655Srie #define ld_reloc_init ld64_reloc_init 9855aefb655Srie #define ld_reloc_process ld64_reloc_process 9865aefb655Srie #define ld_sym_add_u ld64_sym_add_u 9875aefb655Srie #define ld_sym_validate ld64_sym_validate 9885aefb655Srie #define ld_update_outfile ld64_update_outfile 9895aefb655Srie 9905aefb655Srie #else 9915aefb655Srie 9925aefb655Srie #define ld_create_outfile ld32_create_outfile 9935aefb655Srie #define ld_ent_setup ld32_ent_setup 9945aefb655Srie #define ld_ofl_cleanup ld32_ofl_cleanup 9955aefb655Srie #define ld_make_sections ld32_make_sections 9965aefb655Srie #define ld_main ld32_main 9975aefb655Srie #define ld_process_open ld32_process_open 9985aefb655Srie #define ld_reloc_init ld32_reloc_init 9995aefb655Srie #define ld_reloc_process ld32_reloc_process 10005aefb655Srie #define ld_sym_add_u ld32_sym_add_u 10015aefb655Srie #define ld_sym_validate ld32_sym_validate 10025aefb655Srie #define ld_update_outfile ld32_update_outfile 10035aefb655Srie 10045aefb655Srie #endif 10055aefb655Srie 10065aefb655Srie extern int ld32_main(int, char **); 10075aefb655Srie extern int ld64_main(int, char **); 10085aefb655Srie 10095aefb655Srie extern uintptr_t ld_create_outfile(Ofl_desc *); 10105aefb655Srie extern uintptr_t ld_ent_setup(Ofl_desc *, Xword); 10115aefb655Srie extern void ld_ofl_cleanup(Ofl_desc *); 10125aefb655Srie extern uintptr_t ld_make_sections(Ofl_desc *); 10135aefb655Srie extern Ifl_desc *ld_process_open(const char *, size_t, int, Ofl_desc *, 10147c478bd9Sstevel@tonic-gate Half, Rej_desc *); 10155aefb655Srie extern uintptr_t ld_reloc_init(Ofl_desc *); 10165aefb655Srie extern uintptr_t ld_reloc_process(Ofl_desc *); 10175aefb655Srie extern Sym_desc *ld_sym_add_u(const char *, Ofl_desc *); 10185aefb655Srie extern uintptr_t ld_sym_validate(Ofl_desc *); 10195aefb655Srie extern uintptr_t ld_update_outfile(Ofl_desc *); 10205aefb655Srie 10215aefb655Srie extern Elf64_Off _elf_getxoff(Elf_Data *); 10227c478bd9Sstevel@tonic-gate 10237c478bd9Sstevel@tonic-gate #ifdef __cplusplus 10247c478bd9Sstevel@tonic-gate } 10257c478bd9Sstevel@tonic-gate #endif 10267c478bd9Sstevel@tonic-gate 10277c478bd9Sstevel@tonic-gate #endif /* _LIBLD_H */ 1028