Print this page
10366 ld(1) should support GNU-style linker sets
10367 ld(1) tests should be a real test suite
10368 want an ld(1) regression test for i386 LD tls transition (10267)

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/include/libld.h
          +++ new/usr/src/cmd/sgs/include/libld.h
↓ open down ↓ 97 lines elided ↑ open up ↑
  98   98          REF_DYN_NEED,                   /* a .so symbol satisfies a .o symbol */
  99   99          REF_REL_NEED,                   /* a .o symbol */
 100  100          REF_NUM                         /* the number of symbol references */
 101  101  } Symref;
 102  102  
 103  103  /*
 104  104   * Relocation descriptor cache
 105  105   */
 106  106  struct rel_cache {
 107  107          APlist          *rc_list;       /* list of Rel_cachebuf */
 108      -        Word            rc_cnt;         /*      and count */
      108 +        Word            rc_cnt;         /*      and count */
 109  109  };
 110  110  
 111  111  /*
 112  112   * GOT reference models
 113  113   */
 114  114  typedef enum {
 115  115          GOT_REF_GENERIC,        /* generic symbol reference */
 116  116          GOT_REF_TLSIE,          /* TLS initial exec (gnu) reference */
 117  117          GOT_REF_TLSLD,          /* TLS local dynamic reference */
 118  118          GOT_REF_TLSGD           /* TLS general dynamic reference */
↓ open down ↓ 21 lines elided ↑ open up ↑
 140  140   * in a variable of type Rlxrel_cache. Symbols come for processing in sorted
 141  141   * order, so a single item cache suffices to eliminate duplicate lookups.
 142  142   *
 143  143   * When sloppy relocation processing fails, the Rlxrel_rej enum reports
 144  144   * the underlying reason.
 145  145   */
 146  146  typedef enum {
 147  147          RLXREL_REJ_NONE = 0,    /* Replacement symbol was found */
 148  148          RLXREL_REJ_TARGET,      /* Target sec disallows relaxed relocations */
 149  149          RLXREL_REJ_SECTION,     /* Either there is no replacement section, */
 150      -                                /*      or its attributes are incompatible */
      150 +                                /*      or its attributes are incompatible */
 151  151          RLXREL_REJ_SYMBOL,      /* Replacement symbol not found */
 152  152  } Rlxrel_rej;
 153  153  
 154  154  typedef struct sreloc_cache {
 155  155          Sym_desc        *sr_osdp;       /* Original symbol */
 156  156          Sym_desc        *sr_rsdp;       /* Replacement symbol */
 157  157          Rlxrel_rej      sr_rej;         /* Reason for failure if NULL sr_rsdp */
 158  158  } Rlxrel_cache;
 159  159  
 160  160  /*
↓ open down ↓ 93 lines elided ↑ open up ↑
 254  254          Phdr            *ofl_tlsphdr;   /* TLS phdr */
 255  255          int             ofl_fd;         /* file descriptor */
 256  256          size_t          ofl_size;       /* image size */
 257  257          APlist          *ofl_maps;      /* list of input mapfiles */
 258  258          APlist          *ofl_segs;      /* list of segments */
 259  259          APlist          *ofl_segs_order; /* SEGMENT_ORDER segments */
 260  260          avl_tree_t      ofl_segs_avl;   /* O(log N) access to named segments */
 261  261          APlist          *ofl_ents;      /* list of entrance descriptors */
 262  262          avl_tree_t      ofl_ents_avl;   /* O(log N) access to named ent. desc */
 263  263          APlist          *ofl_objs;      /* relocatable object file list */
 264      -        Word            ofl_objscnt;    /*      and count */
      264 +        Word            ofl_objscnt;    /*      and count */
 265  265          APlist          *ofl_ars;       /* archive library list */
 266      -        Word            ofl_arscnt;     /*      and count */
      266 +        Word            ofl_arscnt;     /*      and count */
 267  267          int             ofl_ars_gsandx; /* archive group argv index. 0 means */
 268  268                                          /*      no current group, < 0 means */
 269  269                                          /*      error reported. >0 is cur ndx */
 270  270          Word            ofl_ars_gsndx;  /* current -zrescan-start ofl_ars ndx */
 271  271          APlist          *ofl_sos;       /* shared object list */
 272      -        Word            ofl_soscnt;     /*      and count */
      272 +        Word            ofl_soscnt;     /*      and count */
 273  273          APlist          *ofl_soneed;    /* list of implicitly required .so's */
 274  274          APlist          *ofl_socntl;    /* list of .so control definitions */
 275  275          Rel_cache       ofl_outrels;    /* list of output relocations */
 276  276          Rel_cache       ofl_actrels;    /* list of relocations to perform */
 277  277          APlist          *ofl_relaux;    /* Rel_aux cache for outrels/actrels */
 278  278          Word            ofl_entrelscnt; /* no of relocations entered */
 279  279          Alist           *ofl_copyrels;  /* list of copy relocations */
 280  280          APlist          *ofl_ordered;   /* list of shf_ordered sections */
 281  281          APlist          *ofl_symdtent;  /* list of syminfo symbols that need */
 282  282                                          /*      to reference .dynamic entries */
 283  283          APlist          *ofl_ismove;    /* list of .SUNW_move sections */
 284  284          APlist          *ofl_ismoverel; /* list of relocation input section */
 285  285                                          /* targeting to expanded area */
 286      -        APlist          *ofl_parsyms;   /* list of partially initialized */
      286 +        APlist          *ofl_parsyms;   /* list of partially initialized */
 287  287                                          /*      symbols (ie. move symbols) */
 288  288          APlist          *ofl_extrarels; /* relocation sections which have */
 289  289                                          /*    a NULL sh_info */
 290  290          avl_tree_t      *ofl_groups;    /* pointer to head of Groups AVL tree */
 291  291          APlist          *ofl_initarray; /* list of init array func names */
 292  292          APlist          *ofl_finiarray; /* list of fini array func names */
 293  293          APlist          *ofl_preiarray; /* list of preinit array func names */
 294  294          APlist          *ofl_rtldinfo;  /* list of rtldinfo syms */
 295  295          APlist          *ofl_osgroups;  /* list of output GROUP sections */
 296  296          APlist          *ofl_ostlsseg;  /* pointer to sections in TLS segment */
↓ open down ↓ 575 lines elided ↑ open up ↑
 872  872  #define FLG_IF_NEEDSTR  0x00000040      /* dependency specified by -Nn */
 873  873                                          /*      flag */
 874  874  #define FLG_IF_IGNORE   0x00000080      /* ignore unused dependencies */
 875  875  #define FLG_IF_NODIRECT 0x00000100      /* object contains symbols that */
 876  876                                          /*      cannot be directly bound to */
 877  877  #define FLG_IF_LAZYLD   0x00000200      /* dependency should be lazy loaded */
 878  878  #define FLG_IF_GRPPRM   0x00000400      /* dependency establishes a group */
 879  879  #define FLG_IF_DISPPEND 0x00000800      /* displacement relocation done */
 880  880                                          /*      in the ld time. */
 881  881  #define FLG_IF_DISPDONE 0x00001000      /* displacement relocation done */
 882      -                                        /*      at the run time */
      882 +                                        /*      at the run time */
 883  883  #define FLG_IF_MAPFILE  0x00002000      /* file is a mapfile */
 884  884  #define FLG_IF_HSTRTAB  0x00004000      /* file has a string section */
 885  885  #define FLG_IF_FILEREF  0x00008000      /* file contains a section which */
 886  886                                          /*      is included in the output */
 887  887                                          /*      allocatable image */
 888  888  #define FLG_IF_GNUVER   0x00010000      /* file used GNU-style versioning */
 889  889  #define FLG_IF_ORDERED  0x00020000      /* ordered section processing */
 890  890                                          /*      required */
 891  891  #define FLG_IF_OTOSCAP  0x00040000      /* convert object capabilities to */
 892  892                                          /*      symbol capabilities */
↓ open down ↓ 16 lines elided ↑ open up ↑
 909  909          const char      *is_name;       /* original section name */
 910  910          const char      *is_sym_name;   /* NULL, or name string to use for */
 911  911                                          /*      related STT_SECTION symbols */
 912  912          Shdr            *is_shdr;       /* the elf section header */
 913  913          Ifl_desc        *is_file;       /* infile desc for this section */
 914  914          Os_desc         *is_osdesc;     /* new output section for this */
 915  915                                          /*      input section */
 916  916          Elf_Data        *is_indata;     /* input sections raw data */
 917  917          Is_desc         *is_symshndx;   /* related SHT_SYM_SHNDX section */
 918  918          Is_desc         *is_comdatkeep; /* If COMDAT section is discarded, */
 919      -                                        /*      this is section that was kept */
      919 +                                        /*      this is section that was kept */
 920  920          Word            is_scnndx;      /* original section index in file */
 921  921          Word            is_ordndx;      /* index for section.  Used to decide */
 922  922                                          /*      where to insert section when */
 923      -                                        /*      reordering sections */
      923 +                                        /*      reordering sections */
 924  924          Word            is_keyident;    /* key for SHF_{ORDERED|LINK_ORDER} */
 925  925                                          /*      processing and ident used for */
 926  926                                          /*       placing/ordering sections */
 927  927          Word            is_flags;       /* Various flags */
 928  928  };
 929  929  
 930  930  #define FLG_IS_ORDERED  0x0001          /* this is a SHF_ORDERED section */
 931  931  #define FLG_IS_KEY      0x0002          /* section requires sort keys */
 932  932  #define FLG_IS_DISCARD  0x0004          /* section is to be discarded */
 933  933  #define FLG_IS_RELUPD   0x0008          /* symbol defined here may have moved */
↓ open down ↓ 49 lines elided ↑ open up ↑
 983  983          APlist          *os_mstrisdescs; /* FLG_IS_INSTRMRG input sections */
 984  984          Sg_desc         *os_sgdesc;     /* segment os_desc is placed on */
 985  985          Elf_Data        *os_outdata;    /* output sections raw data */
 986  986          avl_tree_t      *os_comdats;    /* AVL tree of COMDAT input sections */
 987  987                                          /*      associated to output section */
 988  988          Word            os_identndx;    /* section identifier for input */
 989  989                                          /*      section processing, followed */
 990  990                                          /*      by section symbol index */
 991  991          Word            os_ordndx;      /* index for section.  Used to decide */
 992  992                                          /*      where to insert section when */
 993      -                                        /*      reordering sections */
      993 +                                        /*      reordering sections */
 994  994          Xword           os_szoutrels;   /* size of output relocation section */
 995  995          uint_t          os_namehash;    /* hash on section name */
 996  996          uchar_t         os_flags;       /* various flags */
 997  997  };
 998  998  
 999  999  #define FLG_OS_KEY              0x01    /* section requires sort keys */
1000 1000  #define FLG_OS_OUTREL           0x02    /* output rel against this section */
1001 1001  #define FLG_OS_SECTREF          0x04    /* isps are not affected by -zignore */
1002 1002  #define FLG_OS_EHFRAME          0x08    /* section is .eh_frame */
1003 1003  
↓ open down ↓ 56 lines elided ↑ open up ↑
1060 1060  };
1061 1061  
1062 1062  #define FLG_SG_P_VADDR          0x0001  /* p_vaddr segment attribute set */
1063 1063  #define FLG_SG_P_PADDR          0x0002  /* p_paddr segment attribute set */
1064 1064  #define FLG_SG_LENGTH           0x0004  /* length segment attribute set */
1065 1065  #define FLG_SG_P_ALIGN          0x0008  /* p_align segment attribute set */
1066 1066  #define FLG_SG_ROUND            0x0010  /* round segment attribute set */
1067 1067  #define FLG_SG_P_FLAGS          0x0020  /* p_flags segment attribute set */
1068 1068  #define FLG_SG_P_TYPE           0x0040  /* p_type segment attribute set */
1069 1069  #define FLG_SG_IS_ORDER         0x0080  /* input section ordering is required */
1070      -                                        /*      for this segment. */
     1070 +                                        /*      for this segment. */
1071 1071  #define FLG_SG_NOHDR            0x0100  /* don't map ELF or phdrs into */
1072 1072                                          /*      this segment */
1073 1073  #define FLG_SG_EMPTY            0x0200  /* an empty segment specification */
1074 1074                                          /*      no input sections will be */
1075 1075                                          /*      associated to this section */
1076 1076  #define FLG_SG_KEY              0x0400  /* segment requires sort keys */
1077 1077  #define FLG_SG_NODISABLE        0x0800  /* FLG_SG_DISABLED is not allowed on */
1078 1078                                          /*      this segment */
1079 1079  #define FLG_SG_DISABLED         0x1000  /* this segment is disabled */
1080 1080  #define FLG_SG_PHREQ            0x2000  /* this segment requires a program */
↓ open down ↓ 53 lines elided ↑ open up ↑
1134 1134  } Ent_desc_file;
1135 1135  
1136 1136  /*
1137 1137   * One structure is allocated for a move entry, and associated to the symbol
1138 1138   * against which a move is targeted.
1139 1139   */
1140 1140  typedef struct {
1141 1141          Move            *md_move;       /* original Move entry */
1142 1142          Xword           md_start;       /* start position */
1143 1143          Xword           md_len;         /* length of initialization */
1144      -        Word            md_oidx;        /* output Move entry index */
     1144 +        Word            md_oidx;        /* output Move entry index */
1145 1145  } Mv_desc;
1146 1146  
1147 1147  /*
1148 1148   * Symbol descriptor.
1149 1149   */
1150 1150  typedef Lword           sd_flag_t;
1151 1151  struct sym_desc {
1152 1152          Alist           *sd_GOTndxs;    /* list of associated GOT entries */
1153 1153          Sym             *sd_sym;        /* pointer to symbol table entry */
1154 1154          Sym             *sd_osym;       /* copy of the original symbol entry */
↓ open down ↓ 10 lines elided ↑ open up ↑
1165 1165          Half            sd_ref;         /* reference definition of symbol */
1166 1166  };
1167 1167  
1168 1168  /*
1169 1169   * The auxiliary symbol descriptor contains the additional information (beyond
1170 1170   * the symbol descriptor) required to process global symbols.  These symbols are
1171 1171   * accessed via an internal symbol hash table where locality of reference is
1172 1172   * important for performance.
1173 1173   */
1174 1174  struct sym_aux {
1175      -        APlist          *sa_dfiles;     /* files where symbol is defined */
     1175 +        APlist          *sa_dfiles;     /* files where symbol is defined */
1176 1176          Sym             sa_sym;         /* copy of symtab entry */
1177 1177          const char      *sa_vfile;      /* first unavailable definition */
1178 1178          const char      *sa_rfile;      /* file with first symbol referenced */
1179 1179          Word            sa_hash;        /* the pure hash value of symbol */
1180 1180          Word            sa_PLTndx;      /* index into PLT for symbol */
1181 1181          Word            sa_PLTGOTndx;   /* GOT entry indx for PLT indirection */
1182 1182          Word            sa_linkndx;     /* index of associated symbol from */
1183 1183                                          /*      ET_DYN file */
1184 1184          Half            sa_symspec;     /* special symbol ids */
1185 1185          Half            sa_overndx;     /* output file versioning index */
1186 1186          Half            sa_dverndx;     /* dependency versioning index */
     1187 +        Os_desc         *sa_boundsec;   /* output section of SECBOUND_ syms */
1187 1188  };
1188 1189  
1189 1190  /*
1190 1191   * Nodes used to track symbols in the global AVL symbol dictionary.
1191 1192   */
1192 1193  struct sym_avlnode {
1193 1194          avl_node_t      sav_node;       /* AVL node */
1194 1195          Word            sav_hash;       /* symbol hash value */
1195 1196          const char      *sav_name;      /* symbol name */
1196 1197          Sym_desc        *sav_sdp;       /* symbol descriptor */
1197 1198  };
1198 1199  
1199 1200  /*
1200 1201   * These are the ids for processing of `Special symbols'.  They are used
1201 1202   * to set the sym->sd_aux->sa_symspec field.
1202 1203   */
1203      -#define SDAUX_ID_ETEXT  1               /* etext && _etext symbol */
1204      -#define SDAUX_ID_EDATA  2               /* edata && _edata symbol */
1205      -#define SDAUX_ID_END    3               /* end, _end, && _END_ symbol */
1206      -#define SDAUX_ID_DYN    4               /* DYNAMIC && _DYNAMIC symbol */
1207      -#define SDAUX_ID_PLT    5               /* _PROCEDURE_LINKAGE_TABLE_ symbol */
1208      -#define SDAUX_ID_GOT    6               /* _GLOBAL_OFFSET_TABLE_ symbol */
1209      -#define SDAUX_ID_START  7               /* START_ && _START_ symbol */
     1204 +#define SDAUX_ID_ETEXT          1       /* etext && _etext symbol */
     1205 +#define SDAUX_ID_EDATA          2       /* edata && _edata symbol */
     1206 +#define SDAUX_ID_END            3       /* end, _end, && _END_ symbol */
     1207 +#define SDAUX_ID_DYN            4       /* DYNAMIC && _DYNAMIC symbol */
     1208 +#define SDAUX_ID_PLT            5       /* _PROCEDURE_LINKAGE_TABLE_ symbol */
     1209 +#define SDAUX_ID_GOT            6       /* _GLOBAL_OFFSET_TABLE_ symbol */
     1210 +#define SDAUX_ID_START          7       /* START_ && _START_ symbol */
     1211 +#define SDAUX_ID_SECBOUND_START 8       /* __start_<section> symbols */
     1212 +#define SDAUX_ID_SECBOUND_STOP  9       /* __stop_<section> symbols */
1210 1213  
1211 1214  /*
1212 1215   * Flags for sym_desc.sd_flags
1213 1216   */
1214 1217  #define FLG_SY_MVTOCOMM 0x00000001      /* assign symbol to common (.bss) */
1215 1218                                          /*      this is a result of a */
1216 1219                                          /*      copy reloc against sym */
1217 1220  #define FLG_SY_GLOBREF  0x00000002      /* a global reference has been seen */
1218 1221  #define FLG_SY_WEAKDEF  0x00000004      /* a weak definition has been used */
1219 1222  #define FLG_SY_CLEAN    0x00000008      /* `Sym' entry points to original */
1220 1223                                          /*      input file (read-only). */
1221 1224  #define FLG_SY_UPREQD   0x00000010      /* symbol value update is required, */
1222 1225                                          /*      either it's used as an entry */
1223 1226                                          /*      point or for relocation, but */
1224 1227                                          /*      it must be updated even if */
1225 1228                                          /*      the -s flag is in effect */
1226 1229  #define FLG_SY_NOTAVAIL 0x00000020      /* symbol is not available to the */
1227 1230                                          /*      application either because it */
1228 1231                                          /*      originates from an implicitly */
1229      -                                        /*      referenced shared object, or */
     1232 +                                        /*      referenced shared object, or */
1230 1233                                          /*      because it is not part of a */
1231 1234                                          /*      specified version. */
1232 1235  #define FLG_SY_REDUCED  0x00000040      /* a global is reduced to local */
1233 1236  #define FLG_SY_VERSPROM 0x00000080      /* version definition has been */
1234 1237                                          /*      promoted to output file */
1235 1238  #define FLG_SY_PROT     0x00000100      /* stv_protected visibility seen */
1236 1239  #define FLG_SY_MAPREF   0x00000200      /* symbol reference generated by user */
1237 1240                                          /*      from mapfile */
1238 1241  #define FLG_SY_REFRSD   0x00000400      /* symbols sd_ref has been raised */
1239      -                                        /*      due to a copy-relocs */
     1242 +                                        /*      due to a copy-relocs */
1240 1243                                          /*      weak-strong pairing */
1241 1244  #define FLG_SY_INTPOSE  0x00000800      /* symbol defines an interposer */
1242 1245  #define FLG_SY_INVALID  0x00001000      /* unwanted/erroneous symbol */
1243 1246  #define FLG_SY_SMGOT    0x00002000      /* small got index assigned to symbol */
1244 1247                                          /*      sparc only */
1245 1248  #define FLG_SY_PARENT   0x00004000      /* symbol to be found in parent */
1246 1249                                          /*    only used with direct bindings */
1247 1250  #define FLG_SY_LAZYLD   0x00008000      /* symbol to cause lazyloading of */
1248 1251                                          /*      parent object */
1249 1252  #define FLG_SY_ISDISC   0x00010000      /* symbol is a member of a DISCARDED */
↓ open down ↓ 321 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX