libld.h revision 7e16fca05dfbcfd32c2ebc9e4d1abdac1cd8657c
2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright (c) 1988 AT&T 2N/A * All Rights Reserved 2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A * Default directory search path manipulation for the link-editor. YLDIR 2N/A * indicates which directory in LIBPATH is replaced by the -YL option to cc 2N/A * and ld. YUDIR indicates which directory is replaced by -YU. 2N/A * Define a hash value that can never be returned from elf_hash(). 2N/A * Macro that can be used to represent both ORDER flags 2N/A * in a section header. 2N/A * The linker merges (concatenates) sections with the same name and 2N/A * compatible section header flags. When comparing these flags, 2N/A * there are some that should not be included in the decision. 2N/A * The ALL_SHF_IGNORE constant defines these flags. 2N/A * NOTE: SHF_MERGE|SHF_STRINGS: * The compiler is allowed to set the SHF_MERGE|SHF_STRINGS flags in * order to tell the linker that: * 1) There is nothing in the section except null terminated strings. * 2) Those strings do not contain NULL bytes, except as termination. * 3) All references to these strings occur via standard relocation * As a result, if two compatible sections both have these flags set, it is * OK to combine the strings they contain into a single merged string table * with duplicates removed and tail strings merged. * This is a different meaning than the simple concatenating of sections * that the linker always does. It is a hint that an additional optimization * is possible, but not required. This means that sections that do not * share the same SHF_MERGE|SHF_STRINGS values can be concatenated, * but cannot have their duplicate strings combined. Hence, the * SHF_MERGE|SHF_STRINGS flags should be ignored when deciding whether * two sections can be concatenated. * Define symbol reference types for use in symbol resolution. REF_NUM /* the number of symbol references */ * Got debugging structure. The got index is defined as a signed value as we * do so much mucking around with negative and positive gots on SPARC, and sign * extension is necessary when building 64-bit objects. On intel we explicitly * cast this variable to an unsigned value. * The link-editor caches the results of sloppy relocation processing * in a variable of type Rlxrel_cache. Symbols come for processing in sorted * order, so a single item cache suffices to eliminate duplicate lookups. * When sloppy relocation processing fails, the Rlxrel_rej enum reports /* or its attributes are incompatible */ * Output file processing structure char *
ofl_sgsid;
/* link-editor identification */ const char *
ofl_name;
/* full file name */ int ofl_fd;
/* file descriptor */ /* no current group, < 0 means */ /* error reported. >0 is cur ndx */ /* for syminfo processing */ /* targeting to expanded area */ void *
ofl_entry;
/* entry point (-e and Sym_desc *) */ char *
ofl_filtees;
/* shared objects we are a filter for */ const char *
ofl_soname;
/* (-h option) output file name for */ const char *
ofl_interp;
/* interpreter name used by exec() */ char *
ofl_rpath;
/* run path to store in .dynamic */ char *
ofl_config;
/* config path to store in .dynamic */ /* Ref. at perform_outreloc() in */ char *
ofl_audit;
/* object auditing required (-p) */ /* sloppy_comdat_reloc() */ #
define FLG_OF_DYNAMIC 0x00000001 /* generate dynamic output module */#
define FLG_OF_STATIC 0x00000002 /* generate static output module */#
define FLG_OF_EXEC 0x00000004 /* generate an executable */#
define FLG_OF_RELOBJ 0x00000008 /* generate a relocatable object */#
define FLG_OF_BFLAG 0x00000020 /* do no special plt building: -b */#
define FLG_OF_IGNENV 0x00000040 /* ignore LD_LIBRARY_PATH: -i */#
define FLG_OF_NOWARN 0x00000100 /* disable symbol warnings: -t */#
define FLG_OF_NOUNDEF 0x00000200 /* allow no undefined symbols: -zdefs */#
define FLG_OF_PURETXT 0x00000400 /* allow no text relocations: -ztext */#
define FLG_OF_DYNLIBS 0x00001000 /* dynamic input allowed: -Bdynamic */#
define FLG_OF_TEXTREL 0x00040000 /* text relocations have been found */#
define FLG_OF_TLSPHDR 0x00100000 /* a TLS program header is required */#
define FLG_OF_VERDEF 0x00400000 /* record version definitions */#
define FLG_OF_KEY 0x02000000 /* file requires sort keys */#
define FLG_OF_PROCRED 0x04000000 /* process any symbol reductions by */ /* effecting the symbol table */ /* output and relocations */ #
define FLG_OF_AUX 0x10000000 /* ofl_filter is an auxiliary filter */#
define FLG_OF_FATAL 0x20000000 /* fatal error during input */#
define FLG_OF_WARN 0x40000000 /* warning during input processing. */#
define FLG_OF_MAPSYMB 0x000100000000 /* symbolic scope definition seen */#
define FLG_OF_MAPGLOB 0x000200000000 /* global scope definition seen */#
define FLG_OF_COMREL 0x000400000000 /* -z combreloc set, which enables */ /* DT_RELACNT tracking, */ #
define FLG_OF_AUTOLCL 0x001000000000 /* automatically reduce unspecified */ /* global symbols to locals */ /* unspecified global symbols */ * In the flags1 arena, establish any options that are applicable to archive * extraction first, and associate a mask. These values are recorded with any * archive descriptor so that they may be reset should the archive require a * rescan to try and resolve undefined symbols. /* resolve weak references */ #
define FLG_OF1_LAZYLD 0x00008000 /* lazy loading of objects enabled */#
define FLG_OF1_OVRFLW 0x00020000 /* size exceeds 32-bit limitation */ /* byte order than output object */ #
define FLG_OF1_RESCAN 0x04000000 /* any archives should be rescanned */#
define FLG_OF1_DONE 0x20000000 /* link-editor processing complete */ /* exported interfaces. */ * Test to see if the output file would allow the presence of * Test to see if the output file would allow the presence of * a .SUNW_ldynsym section. The requirements are that a .dynsym * is allowed, and -znoldynsym has not been specified. Note that * even if the answer is True (1), we will only generate one if there * are local symbols that require it. * Test to see if relocation processing should be done. This is normally * true, but can be disabled via the '-z noreloc' option. Note that * relocatable objects are still relocated even if '-z noreloc' is present. * Relocation (active & output) processing structure - transparent to common * Note that rel_raddend is primarily only of interest to RELA relocations, * and is set to 0 for REL. However, there is an exception: If FLG_REL_NADDEND * is set, then rel_raddend contains a replacement value for the implicit * addend found in the relocation target. const char *
rel_sname;
/* symbol name (may be "unknown") */ * common flags used on the Rel_desc structure (defined in machrel.h). #
define FLG_REL_GOT 0x00000001 /* relocation against GOT */#
define FLG_REL_PLT 0x00000002 /* relocation against PLT */#
define FLG_REL_BSS 0x00000004 /* relocation against BSS */#
define FLG_REL_SCNNDX 0x00000010 /* use section index for symbol ndx */#
define FLG_REL_CLVAL 0x00000020 /* clear VALUE for active relocation */#
define FLG_REL_ADVAL 0x00000040 /* add VALUE for output relocation, */ /* only relevant to SPARC and */ #
define FLG_REL_GOTCL 0x00000080 /* clear the GOT entry. This is */ /* relevant to RELA relocations, */ /* not REL (i386) relocations */ /* adjustments required before */ #
define FLG_REL_NOINFO 0x00000200 /* Relocation comes from a section */ /* with a null sh_info field */ #
define FLG_REL_REG 0x00000400 /* Relocation target is reg sym */#
define FLG_REL_FPTR 0x00000800 /* relocation against func. desc. */ /* static TLS GOT index */ #
define FLG_REL_DTLS 0x00010000 /* GD TLS reference relative to */ /* dynamic TLS GOT index */ #
define FLG_REL_MTLS 0x00020000 /* LD TLS reference against GOT */ /* to static tls index */ #
define FLG_REL_TLSFIX 0x00080000 /* relocation points to TLS instr. */ /* which needs updating */ #
define FLG_REL_RELA 0x00100000 /* descripter captures a Rela */#
define FLG_REL_GOTFIX 0x00200000 /* relocation points to GOTOP instr. */ /* which needs updating */ /* with value in rel_raddend */ /* Relevant to REL (i386) */ /* relocations, not to RELA. */ * Structure to hold a cache of Relocations. * Symbol value descriptor. For relocatable objects, each symbols value is * its offset within its associated section. Therefore, to uniquely define * each symbol within a reloctable object, record and sort the sh_offset and * symbol value. This information is used to seach for displacement * relocations as part of copy relocation validation. * Input file processing structures. struct ifl_desc {
/* input file descriptor */ const char *
ifl_name;
/* full file name */ #
define FLG_IF_CMDLINE 0x00000001 /* full filename specified from the */ /* command line (no -l) */ #
define FLG_IF_NEEDED 0x00000002 /* shared object should be recorded */#
define FLG_IF_DIRECT 0x00000004 /* establish direct bindings to this */#
define FLG_IF_EXTRACT 0x00000008 /* file extracted from an archive */#
define FLG_IF_VERNEED 0x00000010 /* version dependency information is */#
define FLG_IF_DEPREQD 0x00000020 /* dependency is required to satisfy */#
define FLG_IF_IGNORE 0x00000080 /* ignore unused dependencies */ /* cannot be directly bound to. */ #
define FLG_IF_LAZYLD 0x00000200 /* bindings to this object should be */#
define FLG_IF_GRPPRM 0x00000400 /* this dependency should have the */ /* DF_P1_GROUPPERM flag set */ /* is included in the output */ #
define FLG_IF_GNUVER 0x00010000 /* file used GNU-style versioning */struct is_desc {
/* input section descriptor */ const char *
is_name;
/* original section name */ /* this is section that was kept */ /* where to insert section when */ /* reordering sections */ /* and identifier used for */ #
define FLG_IS_KEY 0x0002 /* section requires sort keys */#
define FLG_IS_RELUPD 0x0008 /* symbol defined here may have moved */#
define FLG_IS_PLACE 0x0400 /* section requires to be placed */ * Map file and output file processing structures struct os_desc {
/* Output section descriptor */ const char *
os_name;
/* the section name */ /* for this output section */ /* associated to output section */ /* symbol for this section */ /* where to insert section when */ /* reordering sections */ #
define FLG_OS_KEY 0x01 /* section requires sort keys */struct sg_desc {
/* output segment descriptor */ const char *
sg_name;
/* segment name */ /* segment is not specified */ #
define FLG_SG_VADDR 0x0001 /* vaddr segment attribute set */#
define FLG_SG_PADDR 0x0002 /* paddr segment attribute set */#
define FLG_SG_ALIGN 0x0008 /* align segment attribute set */#
define FLG_SG_ROUND 0x0010 /* round segment attribute set */#
define FLG_SG_FLAGS 0x0020 /* flags segment attribute set */#
define FLG_SG_TYPE 0x0040 /* type segment attribute set */#
define FLG_SG_ORDER 0x0080 /* has ordering been turned on for */ /* i.e. ?[O] option in mapfile */ #
define FLG_SG_NOHDR 0x0100 /* don't map ELF or phdrs into */#
define FLG_SG_EMPTY 0x0200 /* an empty segment specification */ /* no input sections will be */ /* associated to this section */ #
define FLG_SG_KEY 0x0400 /* segment requires sort keys */#
define FLG_SG_PHREQ 0x1000 /* this segment requires a program */ const char *
sco_secname;
/* section name to be ordered */ struct ent_desc {
/* input section entrance criteria */ const char *
ec_name;
/* name to match (NULL if none) */ Word ec_ndx;
/* index to determine where section */ /* meeting this criteria should */ /* inserted. Used for reordering */ #
define FLG_EC_USED 0x0001 /* entrance criteria met? */ * Move supplementary structures * One structure is allocated for a move entry. * Define a move descripter used within relocation structures. Sym *
sd_sym;
/* pointer to symbol table entry */ Sym *
sd_osym;
/* copy of the original symbol entry */ /* used only for local partial */ /* pointer to parsym_info */ const char *
sd_name;
/* symbols name */ * The auxiliary symbol descriptor contains the additional information (beyond * the symbol descriptor) required to process global symbols. These symbols are * accessed via an internal symbol hash table where locality of reference is * important for performance. const char *
sa_vfile;
/* first unavailable definition */ const char *
sa_rfile;
/* file with first symbol referenced */ * Nodes used to track symbols in the global AVL symbol dictionary. * These are the ids for processing of `Special symbols'. They are used * to set the sym->sd_aux->sa_symspec field. #
define SDAUX_ID_PLT 5 /* _PROCEDURE_LINKAGE_TABLE_ symbol */ /* this is a result of a */ /* copy reloc against sym */ #
define FLG_SY_GLOBREF 0x00000002 /* a global reference has been seen */#
define FLG_SY_WEAKDEF 0x00000004 /* a weak definition has been used */#
define FLG_SY_CLEAN 0x00000008 /* `Sym' entry points to original */ /* input file (read-only). */ #
define FLG_SY_UPREQD 0x00000010 /* symbol value update is required, */ /* either it's used as an entry */ /* point or for relocation, but */ /* it must be updated even if */ /* the -s flag is in effect */ /* application either because it */ /* originates from an implicitly */ /* referenced shared object, or */ /* because it is not part of a */ /* promoted to output file */ #
define FLG_SY_PROT 0x00000100 /* stv_protected visibility seen */#
define FLG_SY_MAPREF 0x00000200 /* symbol reference generated by user */#
define FLG_SY_REFRSD 0x00000400 /* symbols sd_ref has been raised */ /* due to a copy-relocs */ /* weak-strong pairing */ #
define FLG_SY_SMGOT 0x00002000 /* small got index assigned to symbol */#
define FLG_SY_PARENT 0x00004000 /* symbol to be found in parent */ /* only used with direct bindings */ #
define FLG_SY_LAZYLD 0x00008000 /* symbol to cause lazyloading of */#
define FLG_SY_ISDISC 0x00010000 /* symbol is a member of a DISCARDED */#
define FLG_SY_PLTPAD 0x00040000 /* pltpadding has been allocated for */#
define FLG_SY_REGSYM 0x00080000 /* REGISTER symbol (sparc only) */#
define FLG_SY_SOFOUND 0x00100000 /* compared against an SO definition */#
define FLG_SY_EXTERN 0x00200000 /* symbol is external, allows -zdefs */ /* within a relocatable object) */ #
define FLG_SY_CMDREF 0x01000000 /* symbol was referenced from the */ /* command line. (ld -u <>, */ /* ld -zrtldinfo=<>, ...) */ #
define FLG_SY_SPECSEC 0x02000000 /* section index is reserved value */#
define FLG_SY_DYNSORT 0x40000000 /* req. in dyn[sym|tls]sort section */#
define FLG_SY1_SINGLE 0x00000002 /* global symbol, singleton defined */#
define FLG_SY1_EXPORT 0x00000008 /* global symbol, exported defined */ /* this mask indicates that the */ /* symbol has been explicitly */ /* defined within a mapfile */ /* definition, and is a candidate */ #
define FLG_SY1_HIDDEN 0x00000010 /* global symbol, reduce to local */#
define FLG_SY1_ELIM 0x00000020 /* global symbol, eliminate */ /* this mask allows all local state */ /* flags to be removed when the */ /* symbol is copy relocated */ /* this mask indicates that the */ /* symbol is not a candidate for */ #
define FLG_SY1_DIR 0x00000400 /* global symbol, direct bindings */#
define FLG_SY1_NDIR 0x00000800 /* global symbol, nondirect bindings */ * Create a mask for (sym.st_other & visibility) since the gABI does not yet * define a ELF*_ST_OTHER macro. * Structure to manage the shared object definition lists. There are two lists * that use this structure: * o ofl_soneed; maintain the list of implicitly required dependencies * (ie. shared objects needed by other shared objects). These definitions * may include RPATH's required to locate the dependencies, and any * o ofl_socntl; maintains the shared object control definitions. These are * provided by the user (via a mapfile) and are used to indicate any * SONAME translations and verion control requirements. const char *
sdf_name;
/* the shared objects file name */ const char *
sdf_soname;
/* the shared objects SONAME */ char *
sdf_rpath;
/* library search path DT_RPATH */ const char *
sdf_rfile;
/* referencing file for diagnostics */ /* this object (via SPECVERS or */ * Structure to manage shared object version usage requirements. const char *
sdv_name;
/* version name */ const char *
sdv_ref;
/* versions reference */ * Structures to manage versioning information. Two versioning structures are * o a version descriptor maintains a linked list of versions and their * associated dependencies. This is used to build the version definitions * for an image being created (see map_symbol), and to determine the * version dependency graph for any input files that are versioned. * o a version index array contains each version of an input file that is * being processed. It informs us which versions are available for * binding, and is used to generate any version dependency information. const char *
vd_name;
/* version name */ const char *
vi_name;
/* dependency version name */ /* output object Verneed section */ * Define any internal version descriptor flags ([vd|vi]_flags). Note that the * first byte is reserved for user visible flags (refer VER_FLG's in link.h). #
define FLG_VER_AVAIL 0x10 /* version is available for binding */ /* Cannot be normalized away */ * isalist(1) descriptor - used to break an isalist string into its component char *
isa_name;
/* individual isa option name */ char *
isa_list;
/* sysinfo(SI_ISALIST) list */ * uname(2) descriptor - used to break a utsname structure into its component * options (at least those that we're interested in). char *
uts_osrel;
/* operating system release */ * SHT_GROUP descriptor - used to track group sections at the global * level to resolve conflicts and determine which to keep. /* descriptor when discarded */ const char *
gd_name;
/* group name (signature symbol) */ * Indexes into the ld_support_funcs[] table. * Structure to manage archive member caching. Each archive has an archive * descriptor (Ar_desc) associated with it. This contains pointers to the * archive symbol table (obtained by elf_getarsyms(3e)) and an auxiliary * structure (Ar_uax[]) that parallels this symbol table. The member element * of this auxiliary table indicates whether the archive member associated with * the symbol offset has already been extracted (AREXTRACTED) or partially * processed (refer process_member()). Elf *
am_elf;
/* elf descriptor for this member */ char *
am_path;
/* path (ie. lib(foo.o)) */ char *
am_strs;
/* associated string table start */ const char *
ad_name;
/* archive file name */ Elf *
ad_elf;
/* elf descriptor for the archive */ * Define any archive descriptor flags. NOTE, make sure they do not clash with * any output file descriptor archive extraction flags, as these are saved in * the same entry (see MSK_OF1_ARCHIVE).