Print this page
10366 ld(1) should support GNU-style linker sets
10581 ld(1) should know kernel modules are a thing

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 ↓ 163 lines elided ↑ open up ↑
 460  460  #define FLG_OF_ADJOSCNT 0x020000000000  /* adjust ofl_shdrcnt to accommodate */
 461  461                                          /*      discarded sections */
 462  462  #define FLG_OF_OTOSCAP  0x040000000000  /* convert object capabilities to */
 463  463                                          /*      symbol capabilities */
 464  464  #define FLG_OF_PTCAP    0x080000000000  /* PT_SUNWCAP required */
 465  465  #define FLG_OF_CAPSTRS  0x100000000000  /* capability strings are required */
 466  466  #define FLG_OF_EHFRAME  0x200000000000  /* output contains .eh_frame section */
 467  467  #define FLG_OF_FATWARN  0x400000000000  /* make warnings fatal */
 468  468  #define FLG_OF_ADEFLIB  0x800000000000  /* no libraries in default path */
 469  469  
      470 +#define FLG_OF_KMOD     0x1000000000000 /* output is a kernel module */
      471 +
 470  472  /*
 471  473   * In the flags1 arena, establish any options that are applicable to archive
 472  474   * extraction first, and associate a mask.  These values are recorded with any
 473  475   * archive descriptor so that they may be reset should the archive require a
 474  476   * rescan to try and resolve undefined symbols.
 475  477   */
 476  478  #define FLG_OF1_ALLEXRT 0x0000000001    /* extract all members from an */
 477  479                                          /*      archive file */
 478  480  #define FLG_OF1_WEAKEXT 0x0000000002    /* allow archive extraction to */
 479  481                                          /*      resolve weak references */
↓ open down ↓ 49 lines elided ↑ open up ↑
 529  531  #define FLG_OFG_ENABLE          0x10000000      /* -z guidance option active */
 530  532  #define FLG_OFG_ISSUED          0x20000000      /* -z guidance message issued */
 531  533  
 532  534  #define FLG_OFG_NO_ALL          0x0fffffff      /* disable all guidance */
 533  535  #define FLG_OFG_NO_DEFS         0x00000001      /* specify all dependencies */
 534  536  #define FLG_OFG_NO_DB           0x00000002      /* use direct bindings */
 535  537  #define FLG_OFG_NO_LAZY         0x00000004      /* be explicit about lazyload */
 536  538  #define FLG_OFG_NO_MF           0x00000008      /* use v2 mapfile syntax */
 537  539  #define FLG_OFG_NO_TEXT         0x00000010      /* verify pure text segment */
 538  540  #define FLG_OFG_NO_UNUSED       0x00000020      /* remove unused dependency */
      541 +#define FLG_OFG_NO_KMOD         0x00000040      /* use -z type=kmod */
 539  542  
 540  543  /*
 541  544   * Test to see if a guidance should be given for a given category
 542  545   * or not. _no_flag is one of the FLG_OFG_NO_xxx flags. Returns TRUE
 543  546   * if the guidance should be issued, and FALSE to remain silent.
 544  547   */
 545  548  #define OFL_GUIDANCE(_ofl, _no_flag) (((_ofl)->ofl_guideflags & \
 546  549          (FLG_OFG_ENABLE | (_no_flag))) == FLG_OFG_ENABLE)
 547  550  
 548  551  /*
↓ open down ↓ 323 lines elided ↑ open up ↑
 872  875  #define FLG_IF_NEEDSTR  0x00000040      /* dependency specified by -Nn */
 873  876                                          /*      flag */
 874  877  #define FLG_IF_IGNORE   0x00000080      /* ignore unused dependencies */
 875  878  #define FLG_IF_NODIRECT 0x00000100      /* object contains symbols that */
 876  879                                          /*      cannot be directly bound to */
 877  880  #define FLG_IF_LAZYLD   0x00000200      /* dependency should be lazy loaded */
 878  881  #define FLG_IF_GRPPRM   0x00000400      /* dependency establishes a group */
 879  882  #define FLG_IF_DISPPEND 0x00000800      /* displacement relocation done */
 880  883                                          /*      in the ld time. */
 881  884  #define FLG_IF_DISPDONE 0x00001000      /* displacement relocation done */
 882      -                                        /*      at the run time */
      885 +                                        /*      at the run time */
 883  886  #define FLG_IF_MAPFILE  0x00002000      /* file is a mapfile */
 884  887  #define FLG_IF_HSTRTAB  0x00004000      /* file has a string section */
 885  888  #define FLG_IF_FILEREF  0x00008000      /* file contains a section which */
 886  889                                          /*      is included in the output */
 887  890                                          /*      allocatable image */
 888  891  #define FLG_IF_GNUVER   0x00010000      /* file used GNU-style versioning */
 889  892  #define FLG_IF_ORDERED  0x00020000      /* ordered section processing */
 890  893                                          /*      required */
 891  894  #define FLG_IF_OTOSCAP  0x00040000      /* convert object capabilities to */
 892  895                                          /*      symbol capabilities */
↓ open down ↓ 16 lines elided ↑ open up ↑
 909  912          const char      *is_name;       /* original section name */
 910  913          const char      *is_sym_name;   /* NULL, or name string to use for */
 911  914                                          /*      related STT_SECTION symbols */
 912  915          Shdr            *is_shdr;       /* the elf section header */
 913  916          Ifl_desc        *is_file;       /* infile desc for this section */
 914  917          Os_desc         *is_osdesc;     /* new output section for this */
 915  918                                          /*      input section */
 916  919          Elf_Data        *is_indata;     /* input sections raw data */
 917  920          Is_desc         *is_symshndx;   /* related SHT_SYM_SHNDX section */
 918  921          Is_desc         *is_comdatkeep; /* If COMDAT section is discarded, */
 919      -                                        /*      this is section that was kept */
      922 +                                        /*      this is section that was kept */
 920  923          Word            is_scnndx;      /* original section index in file */
 921  924          Word            is_ordndx;      /* index for section.  Used to decide */
 922  925                                          /*      where to insert section when */
 923      -                                        /*      reordering sections */
      926 +                                        /*      reordering sections */
 924  927          Word            is_keyident;    /* key for SHF_{ORDERED|LINK_ORDER} */
 925  928                                          /*      processing and ident used for */
 926  929                                          /*       placing/ordering sections */
 927  930          Word            is_flags;       /* Various flags */
 928  931  };
 929  932  
 930  933  #define FLG_IS_ORDERED  0x0001          /* this is a SHF_ORDERED section */
 931  934  #define FLG_IS_KEY      0x0002          /* section requires sort keys */
 932  935  #define FLG_IS_DISCARD  0x0004          /* section is to be discarded */
 933  936  #define FLG_IS_RELUPD   0x0008          /* symbol defined here may have moved */
↓ open down ↓ 49 lines elided ↑ open up ↑
 983  986          APlist          *os_mstrisdescs; /* FLG_IS_INSTRMRG input sections */
 984  987          Sg_desc         *os_sgdesc;     /* segment os_desc is placed on */
 985  988          Elf_Data        *os_outdata;    /* output sections raw data */
 986  989          avl_tree_t      *os_comdats;    /* AVL tree of COMDAT input sections */
 987  990                                          /*      associated to output section */
 988  991          Word            os_identndx;    /* section identifier for input */
 989  992                                          /*      section processing, followed */
 990  993                                          /*      by section symbol index */
 991  994          Word            os_ordndx;      /* index for section.  Used to decide */
 992  995                                          /*      where to insert section when */
 993      -                                        /*      reordering sections */
      996 +                                        /*      reordering sections */
 994  997          Xword           os_szoutrels;   /* size of output relocation section */
 995  998          uint_t          os_namehash;    /* hash on section name */
 996  999          uchar_t         os_flags;       /* various flags */
 997 1000  };
 998 1001  
 999 1002  #define FLG_OS_KEY              0x01    /* section requires sort keys */
1000 1003  #define FLG_OS_OUTREL           0x02    /* output rel against this section */
1001 1004  #define FLG_OS_SECTREF          0x04    /* isps are not affected by -zignore */
1002 1005  #define FLG_OS_EHFRAME          0x08    /* section is .eh_frame */
1003 1006  
↓ open down ↓ 56 lines elided ↑ open up ↑
1060 1063  };
1061 1064  
1062 1065  #define FLG_SG_P_VADDR          0x0001  /* p_vaddr segment attribute set */
1063 1066  #define FLG_SG_P_PADDR          0x0002  /* p_paddr segment attribute set */
1064 1067  #define FLG_SG_LENGTH           0x0004  /* length segment attribute set */
1065 1068  #define FLG_SG_P_ALIGN          0x0008  /* p_align segment attribute set */
1066 1069  #define FLG_SG_ROUND            0x0010  /* round segment attribute set */
1067 1070  #define FLG_SG_P_FLAGS          0x0020  /* p_flags segment attribute set */
1068 1071  #define FLG_SG_P_TYPE           0x0040  /* p_type segment attribute set */
1069 1072  #define FLG_SG_IS_ORDER         0x0080  /* input section ordering is required */
1070      -                                        /*      for this segment. */
     1073 +                                        /*      for this segment. */
1071 1074  #define FLG_SG_NOHDR            0x0100  /* don't map ELF or phdrs into */
1072 1075                                          /*      this segment */
1073 1076  #define FLG_SG_EMPTY            0x0200  /* an empty segment specification */
1074 1077                                          /*      no input sections will be */
1075 1078                                          /*      associated to this section */
1076 1079  #define FLG_SG_KEY              0x0400  /* segment requires sort keys */
1077 1080  #define FLG_SG_NODISABLE        0x0800  /* FLG_SG_DISABLED is not allowed on */
1078 1081                                          /*      this segment */
1079 1082  #define FLG_SG_DISABLED         0x1000  /* this segment is disabled */
1080 1083  #define FLG_SG_PHREQ            0x2000  /* this segment requires a program */
↓ open down ↓ 53 lines elided ↑ open up ↑
1134 1137  } Ent_desc_file;
1135 1138  
1136 1139  /*
1137 1140   * One structure is allocated for a move entry, and associated to the symbol
1138 1141   * against which a move is targeted.
1139 1142   */
1140 1143  typedef struct {
1141 1144          Move            *md_move;       /* original Move entry */
1142 1145          Xword           md_start;       /* start position */
1143 1146          Xword           md_len;         /* length of initialization */
1144      -        Word            md_oidx;        /* output Move entry index */
     1147 +        Word            md_oidx;        /* output Move entry index */
1145 1148  } Mv_desc;
1146 1149  
1147 1150  /*
1148 1151   * Symbol descriptor.
1149 1152   */
1150 1153  typedef Lword           sd_flag_t;
1151 1154  struct sym_desc {
1152 1155          Alist           *sd_GOTndxs;    /* list of associated GOT entries */
1153 1156          Sym             *sd_sym;        /* pointer to symbol table entry */
1154 1157          Sym             *sd_osym;       /* copy of the original symbol entry */
↓ open down ↓ 10 lines elided ↑ open up ↑
1165 1168          Half            sd_ref;         /* reference definition of symbol */
1166 1169  };
1167 1170  
1168 1171  /*
1169 1172   * The auxiliary symbol descriptor contains the additional information (beyond
1170 1173   * the symbol descriptor) required to process global symbols.  These symbols are
1171 1174   * accessed via an internal symbol hash table where locality of reference is
1172 1175   * important for performance.
1173 1176   */
1174 1177  struct sym_aux {
1175      -        APlist          *sa_dfiles;     /* files where symbol is defined */
     1178 +        APlist          *sa_dfiles;     /* files where symbol is defined */
1176 1179          Sym             sa_sym;         /* copy of symtab entry */
1177 1180          const char      *sa_vfile;      /* first unavailable definition */
1178 1181          const char      *sa_rfile;      /* file with first symbol referenced */
1179 1182          Word            sa_hash;        /* the pure hash value of symbol */
1180 1183          Word            sa_PLTndx;      /* index into PLT for symbol */
1181 1184          Word            sa_PLTGOTndx;   /* GOT entry indx for PLT indirection */
1182 1185          Word            sa_linkndx;     /* index of associated symbol from */
1183 1186                                          /*      ET_DYN file */
1184 1187          Half            sa_symspec;     /* special symbol ids */
1185 1188          Half            sa_overndx;     /* output file versioning index */
1186 1189          Half            sa_dverndx;     /* dependency versioning index */
     1190 +        Os_desc         *sa_boundsec;   /* output section of SECBOUND_ syms */
1187 1191  };
1188 1192  
1189 1193  /*
1190 1194   * Nodes used to track symbols in the global AVL symbol dictionary.
1191 1195   */
1192 1196  struct sym_avlnode {
1193 1197          avl_node_t      sav_node;       /* AVL node */
1194 1198          Word            sav_hash;       /* symbol hash value */
1195 1199          const char      *sav_name;      /* symbol name */
1196 1200          Sym_desc        *sav_sdp;       /* symbol descriptor */
1197 1201  };
1198 1202  
1199 1203  /*
1200 1204   * These are the ids for processing of `Special symbols'.  They are used
1201 1205   * to set the sym->sd_aux->sa_symspec field.
1202 1206   */
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 */
     1207 +#define SDAUX_ID_ETEXT          1       /* etext && _etext symbol */
     1208 +#define SDAUX_ID_EDATA          2       /* edata && _edata symbol */
     1209 +#define SDAUX_ID_END            3       /* end, _end, && _END_ symbol */
     1210 +#define SDAUX_ID_DYN            4       /* DYNAMIC && _DYNAMIC symbol */
     1211 +#define SDAUX_ID_PLT            5       /* _PROCEDURE_LINKAGE_TABLE_ symbol */
     1212 +#define SDAUX_ID_GOT            6       /* _GLOBAL_OFFSET_TABLE_ symbol */
     1213 +#define SDAUX_ID_START          7       /* START_ && _START_ symbol */
     1214 +#define SDAUX_ID_SECBOUND_START 8       /* __start_<section> symbols */
     1215 +#define SDAUX_ID_SECBOUND_STOP  9       /* __stop_<section> symbols */
1210 1216  
1211 1217  /*
1212 1218   * Flags for sym_desc.sd_flags
1213 1219   */
1214 1220  #define FLG_SY_MVTOCOMM 0x00000001      /* assign symbol to common (.bss) */
1215 1221                                          /*      this is a result of a */
1216 1222                                          /*      copy reloc against sym */
1217 1223  #define FLG_SY_GLOBREF  0x00000002      /* a global reference has been seen */
1218 1224  #define FLG_SY_WEAKDEF  0x00000004      /* a weak definition has been used */
1219 1225  #define FLG_SY_CLEAN    0x00000008      /* `Sym' entry points to original */
1220 1226                                          /*      input file (read-only). */
1221 1227  #define FLG_SY_UPREQD   0x00000010      /* symbol value update is required, */
1222 1228                                          /*      either it's used as an entry */
1223 1229                                          /*      point or for relocation, but */
1224 1230                                          /*      it must be updated even if */
1225 1231                                          /*      the -s flag is in effect */
1226 1232  #define FLG_SY_NOTAVAIL 0x00000020      /* symbol is not available to the */
1227 1233                                          /*      application either because it */
1228 1234                                          /*      originates from an implicitly */
1229      -                                        /*      referenced shared object, or */
     1235 +                                        /*      referenced shared object, or */
1230 1236                                          /*      because it is not part of a */
1231 1237                                          /*      specified version. */
1232 1238  #define FLG_SY_REDUCED  0x00000040      /* a global is reduced to local */
1233 1239  #define FLG_SY_VERSPROM 0x00000080      /* version definition has been */
1234 1240                                          /*      promoted to output file */
1235 1241  #define FLG_SY_PROT     0x00000100      /* stv_protected visibility seen */
1236 1242  #define FLG_SY_MAPREF   0x00000200      /* symbol reference generated by user */
1237 1243                                          /*      from mapfile */
1238 1244  #define FLG_SY_REFRSD   0x00000400      /* symbols sd_ref has been raised */
1239      -                                        /*      due to a copy-relocs */
     1245 +                                        /*      due to a copy-relocs */
1240 1246                                          /*      weak-strong pairing */
1241 1247  #define FLG_SY_INTPOSE  0x00000800      /* symbol defines an interposer */
1242 1248  #define FLG_SY_INVALID  0x00001000      /* unwanted/erroneous symbol */
1243 1249  #define FLG_SY_SMGOT    0x00002000      /* small got index assigned to symbol */
1244 1250                                          /*      sparc only */
1245 1251  #define FLG_SY_PARENT   0x00004000      /* symbol to be found in parent */
1246 1252                                          /*    only used with direct bindings */
1247 1253  #define FLG_SY_LAZYLD   0x00008000      /* symbol to cause lazyloading of */
1248 1254                                          /*      parent object */
1249 1255  #define FLG_SY_ISDISC   0x00010000      /* symbol is a member of a DISCARDED */
↓ open down ↓ 321 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX