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


 450 #define FLG_OF_COMREL   0x000400000000  /* -z combreloc set, which enables */
 451                                         /*      DT_RELACNT tracking, */
 452 #define FLG_OF_NOCOMREL 0x000800000000  /* -z nocombreloc set */
 453 #define FLG_OF_AUTOLCL  0x001000000000  /* automatically reduce unspecified */
 454                                         /*      global symbols to locals */
 455 #define FLG_OF_AUTOELM  0x002000000000  /* automatically eliminate */
 456                                         /*      unspecified global symbols */
 457 #define FLG_OF_REDLSYM  0x004000000000  /* reduce local symbols */
 458 #define FLG_OF_OS_ORDER 0x008000000000  /* output section ordering required */
 459 #define FLG_OF_OSABI    0x010000000000  /* tag object as ELFOSABI_SOLARIS */
 460 #define FLG_OF_ADJOSCNT 0x020000000000  /* adjust ofl_shdrcnt to accommodate */
 461                                         /*      discarded sections */
 462 #define FLG_OF_OTOSCAP  0x040000000000  /* convert object capabilities to */
 463                                         /*      symbol capabilities */
 464 #define FLG_OF_PTCAP    0x080000000000  /* PT_SUNWCAP required */
 465 #define FLG_OF_CAPSTRS  0x100000000000  /* capability strings are required */
 466 #define FLG_OF_EHFRAME  0x200000000000  /* output contains .eh_frame section */
 467 #define FLG_OF_FATWARN  0x400000000000  /* make warnings fatal */
 468 #define FLG_OF_ADEFLIB  0x800000000000  /* no libraries in default path */
 469 


 470 /*
 471  * In the flags1 arena, establish any options that are applicable to archive
 472  * extraction first, and associate a mask.  These values are recorded with any
 473  * archive descriptor so that they may be reset should the archive require a
 474  * rescan to try and resolve undefined symbols.
 475  */
 476 #define FLG_OF1_ALLEXRT 0x0000000001    /* extract all members from an */
 477                                         /*      archive file */
 478 #define FLG_OF1_WEAKEXT 0x0000000002    /* allow archive extraction to */
 479                                         /*      resolve weak references */
 480 #define MSK_OF1_ARCHIVE 0x0000000003    /* archive flags mask */
 481 
 482 #define FLG_OF1_NOINTRP 0x0000000008    /* -z nointerp flag set */
 483 #define FLG_OF1_ZDIRECT 0x0000000010    /* -z direct flag set */
 484 #define FLG_OF1_NDIRECT 0x0000000020    /* no-direct bindings specified */
 485 #define FLG_OF1_DEFERRED 0x0000000040   /* deferred dependency recording */
 486 
 487 #define FLG_OF1_RELDYN  0x0000000100    /* process .dynamic in rel obj */
 488 #define FLG_OF1_NRLXREL 0x0000000200    /* -z norelaxreloc flag set */
 489 #define FLG_OF1_RLXREL  0x0000000400    /* -z relaxreloc flag set */


 519 #define FLG_OF1_OVHWCAP2 0x0400000000   /* override CA_SUNW_HW_2 capabilities */
 520 #define FLG_OF1_OVMACHCAP 0x0800000000  /* override CA_SUNW_MACH capability */
 521 #define FLG_OF1_OVPLATCAP 0x1000000000  /* override CA_SUNW_PLAT capability */
 522 #define FLG_OF1_OVIDCAP 0x2000000000    /* override CA_SUNW_ID capability */
 523 
 524 /*
 525  * Guidance flags. The flags with the FLG_OFG_NO_ prefix are used to suppress
 526  * messages for a given category, and use the lower 28 bits of the word,
 527  * The upper nibble is reserved for other guidance status.
 528  */
 529 #define FLG_OFG_ENABLE          0x10000000      /* -z guidance option active */
 530 #define FLG_OFG_ISSUED          0x20000000      /* -z guidance message issued */
 531 
 532 #define FLG_OFG_NO_ALL          0x0fffffff      /* disable all guidance */
 533 #define FLG_OFG_NO_DEFS         0x00000001      /* specify all dependencies */
 534 #define FLG_OFG_NO_DB           0x00000002      /* use direct bindings */
 535 #define FLG_OFG_NO_LAZY         0x00000004      /* be explicit about lazyload */
 536 #define FLG_OFG_NO_MF           0x00000008      /* use v2 mapfile syntax */
 537 #define FLG_OFG_NO_TEXT         0x00000010      /* verify pure text segment */
 538 #define FLG_OFG_NO_UNUSED       0x00000020      /* remove unused dependency */

 539 
 540 /*
 541  * Test to see if a guidance should be given for a given category
 542  * or not. _no_flag is one of the FLG_OFG_NO_xxx flags. Returns TRUE
 543  * if the guidance should be issued, and FALSE to remain silent.
 544  */
 545 #define OFL_GUIDANCE(_ofl, _no_flag) (((_ofl)->ofl_guideflags & \
 546         (FLG_OFG_ENABLE | (_no_flag))) == FLG_OFG_ENABLE)
 547 
 548 /*
 549  * Test to see if the output file would allow the presence of
 550  * a .dynsym section.
 551  */
 552 #define OFL_ALLOW_DYNSYM(_ofl) (((_ofl)->ofl_flags & \
 553         (FLG_OF_DYNAMIC | FLG_OF_RELOBJ)) == FLG_OF_DYNAMIC)
 554 
 555 /*
 556  * Test to see if the output file would allow the presence of
 557  * a .SUNW_ldynsym section. The requirements are that a .dynsym
 558  * is allowed, and -znoldynsym has not been specified. Note that


1167 
1168 /*
1169  * The auxiliary symbol descriptor contains the additional information (beyond
1170  * the symbol descriptor) required to process global symbols.  These symbols are
1171  * accessed via an internal symbol hash table where locality of reference is
1172  * important for performance.
1173  */
1174 struct sym_aux {
1175         APlist          *sa_dfiles;     /* files where symbol is defined */
1176         Sym             sa_sym;         /* copy of symtab entry */
1177         const char      *sa_vfile;      /* first unavailable definition */
1178         const char      *sa_rfile;      /* file with first symbol referenced */
1179         Word            sa_hash;        /* the pure hash value of symbol */
1180         Word            sa_PLTndx;      /* index into PLT for symbol */
1181         Word            sa_PLTGOTndx;   /* GOT entry indx for PLT indirection */
1182         Word            sa_linkndx;     /* index of associated symbol from */
1183                                         /*      ET_DYN file */
1184         Half            sa_symspec;     /* special symbol ids */
1185         Half            sa_overndx;     /* output file versioning index */
1186         Half            sa_dverndx;     /* dependency versioning index */

1187 };
1188 
1189 /*
1190  * Nodes used to track symbols in the global AVL symbol dictionary.
1191  */
1192 struct sym_avlnode {
1193         avl_node_t      sav_node;       /* AVL node */
1194         Word            sav_hash;       /* symbol hash value */
1195         const char      *sav_name;      /* symbol name */
1196         Sym_desc        *sav_sdp;       /* symbol descriptor */
1197 };
1198 
1199 /*
1200  * These are the ids for processing of `Special symbols'.  They are used
1201  * to set the sym->sd_aux->sa_symspec field.
1202  */
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 */


1210 
1211 /*
1212  * Flags for sym_desc.sd_flags
1213  */
1214 #define FLG_SY_MVTOCOMM 0x00000001      /* assign symbol to common (.bss) */
1215                                         /*      this is a result of a */
1216                                         /*      copy reloc against sym */
1217 #define FLG_SY_GLOBREF  0x00000002      /* a global reference has been seen */
1218 #define FLG_SY_WEAKDEF  0x00000004      /* a weak definition has been used */
1219 #define FLG_SY_CLEAN    0x00000008      /* `Sym' entry points to original */
1220                                         /*      input file (read-only). */
1221 #define FLG_SY_UPREQD   0x00000010      /* symbol value update is required, */
1222                                         /*      either it's used as an entry */
1223                                         /*      point or for relocation, but */
1224                                         /*      it must be updated even if */
1225                                         /*      the -s flag is in effect */
1226 #define FLG_SY_NOTAVAIL 0x00000020      /* symbol is not available to the */
1227                                         /*      application either because it */
1228                                         /*      originates from an implicitly */
1229                                         /*      referenced shared object, or */




 450 #define FLG_OF_COMREL   0x000400000000  /* -z combreloc set, which enables */
 451                                         /*      DT_RELACNT tracking, */
 452 #define FLG_OF_NOCOMREL 0x000800000000  /* -z nocombreloc set */
 453 #define FLG_OF_AUTOLCL  0x001000000000  /* automatically reduce unspecified */
 454                                         /*      global symbols to locals */
 455 #define FLG_OF_AUTOELM  0x002000000000  /* automatically eliminate */
 456                                         /*      unspecified global symbols */
 457 #define FLG_OF_REDLSYM  0x004000000000  /* reduce local symbols */
 458 #define FLG_OF_OS_ORDER 0x008000000000  /* output section ordering required */
 459 #define FLG_OF_OSABI    0x010000000000  /* tag object as ELFOSABI_SOLARIS */
 460 #define FLG_OF_ADJOSCNT 0x020000000000  /* adjust ofl_shdrcnt to accommodate */
 461                                         /*      discarded sections */
 462 #define FLG_OF_OTOSCAP  0x040000000000  /* convert object capabilities to */
 463                                         /*      symbol capabilities */
 464 #define FLG_OF_PTCAP    0x080000000000  /* PT_SUNWCAP required */
 465 #define FLG_OF_CAPSTRS  0x100000000000  /* capability strings are required */
 466 #define FLG_OF_EHFRAME  0x200000000000  /* output contains .eh_frame section */
 467 #define FLG_OF_FATWARN  0x400000000000  /* make warnings fatal */
 468 #define FLG_OF_ADEFLIB  0x800000000000  /* no libraries in default path */
 469 
 470 #define FLG_OF_KMOD     0x1000000000000 /* output is a kernel module */
 471 
 472 /*
 473  * In the flags1 arena, establish any options that are applicable to archive
 474  * extraction first, and associate a mask.  These values are recorded with any
 475  * archive descriptor so that they may be reset should the archive require a
 476  * rescan to try and resolve undefined symbols.
 477  */
 478 #define FLG_OF1_ALLEXRT 0x0000000001    /* extract all members from an */
 479                                         /*      archive file */
 480 #define FLG_OF1_WEAKEXT 0x0000000002    /* allow archive extraction to */
 481                                         /*      resolve weak references */
 482 #define MSK_OF1_ARCHIVE 0x0000000003    /* archive flags mask */
 483 
 484 #define FLG_OF1_NOINTRP 0x0000000008    /* -z nointerp flag set */
 485 #define FLG_OF1_ZDIRECT 0x0000000010    /* -z direct flag set */
 486 #define FLG_OF1_NDIRECT 0x0000000020    /* no-direct bindings specified */
 487 #define FLG_OF1_DEFERRED 0x0000000040   /* deferred dependency recording */
 488 
 489 #define FLG_OF1_RELDYN  0x0000000100    /* process .dynamic in rel obj */
 490 #define FLG_OF1_NRLXREL 0x0000000200    /* -z norelaxreloc flag set */
 491 #define FLG_OF1_RLXREL  0x0000000400    /* -z relaxreloc flag set */


 521 #define FLG_OF1_OVHWCAP2 0x0400000000   /* override CA_SUNW_HW_2 capabilities */
 522 #define FLG_OF1_OVMACHCAP 0x0800000000  /* override CA_SUNW_MACH capability */
 523 #define FLG_OF1_OVPLATCAP 0x1000000000  /* override CA_SUNW_PLAT capability */
 524 #define FLG_OF1_OVIDCAP 0x2000000000    /* override CA_SUNW_ID capability */
 525 
 526 /*
 527  * Guidance flags. The flags with the FLG_OFG_NO_ prefix are used to suppress
 528  * messages for a given category, and use the lower 28 bits of the word,
 529  * The upper nibble is reserved for other guidance status.
 530  */
 531 #define FLG_OFG_ENABLE          0x10000000      /* -z guidance option active */
 532 #define FLG_OFG_ISSUED          0x20000000      /* -z guidance message issued */
 533 
 534 #define FLG_OFG_NO_ALL          0x0fffffff      /* disable all guidance */
 535 #define FLG_OFG_NO_DEFS         0x00000001      /* specify all dependencies */
 536 #define FLG_OFG_NO_DB           0x00000002      /* use direct bindings */
 537 #define FLG_OFG_NO_LAZY         0x00000004      /* be explicit about lazyload */
 538 #define FLG_OFG_NO_MF           0x00000008      /* use v2 mapfile syntax */
 539 #define FLG_OFG_NO_TEXT         0x00000010      /* verify pure text segment */
 540 #define FLG_OFG_NO_UNUSED       0x00000020      /* remove unused dependency */
 541 #define FLG_OFG_NO_KMOD         0x00000040      /* use -z type=kmod */
 542 
 543 /*
 544  * Test to see if a guidance should be given for a given category
 545  * or not. _no_flag is one of the FLG_OFG_NO_xxx flags. Returns TRUE
 546  * if the guidance should be issued, and FALSE to remain silent.
 547  */
 548 #define OFL_GUIDANCE(_ofl, _no_flag) (((_ofl)->ofl_guideflags & \
 549         (FLG_OFG_ENABLE | (_no_flag))) == FLG_OFG_ENABLE)
 550 
 551 /*
 552  * Test to see if the output file would allow the presence of
 553  * a .dynsym section.
 554  */
 555 #define OFL_ALLOW_DYNSYM(_ofl) (((_ofl)->ofl_flags & \
 556         (FLG_OF_DYNAMIC | FLG_OF_RELOBJ)) == FLG_OF_DYNAMIC)
 557 
 558 /*
 559  * Test to see if the output file would allow the presence of
 560  * a .SUNW_ldynsym section. The requirements are that a .dynsym
 561  * is allowed, and -znoldynsym has not been specified. Note that


1170 
1171 /*
1172  * The auxiliary symbol descriptor contains the additional information (beyond
1173  * the symbol descriptor) required to process global symbols.  These symbols are
1174  * accessed via an internal symbol hash table where locality of reference is
1175  * important for performance.
1176  */
1177 struct sym_aux {
1178         APlist          *sa_dfiles;     /* files where symbol is defined */
1179         Sym             sa_sym;         /* copy of symtab entry */
1180         const char      *sa_vfile;      /* first unavailable definition */
1181         const char      *sa_rfile;      /* file with first symbol referenced */
1182         Word            sa_hash;        /* the pure hash value of symbol */
1183         Word            sa_PLTndx;      /* index into PLT for symbol */
1184         Word            sa_PLTGOTndx;   /* GOT entry indx for PLT indirection */
1185         Word            sa_linkndx;     /* index of associated symbol from */
1186                                         /*      ET_DYN file */
1187         Half            sa_symspec;     /* special symbol ids */
1188         Half            sa_overndx;     /* output file versioning index */
1189         Half            sa_dverndx;     /* dependency versioning index */
1190         Os_desc         *sa_boundsec;   /* output section of SECBOUND_ syms */
1191 };
1192 
1193 /*
1194  * Nodes used to track symbols in the global AVL symbol dictionary.
1195  */
1196 struct sym_avlnode {
1197         avl_node_t      sav_node;       /* AVL node */
1198         Word            sav_hash;       /* symbol hash value */
1199         const char      *sav_name;      /* symbol name */
1200         Sym_desc        *sav_sdp;       /* symbol descriptor */
1201 };
1202 
1203 /*
1204  * These are the ids for processing of `Special symbols'.  They are used
1205  * to set the sym->sd_aux->sa_symspec field.
1206  */
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 */
1216 
1217 /*
1218  * Flags for sym_desc.sd_flags
1219  */
1220 #define FLG_SY_MVTOCOMM 0x00000001      /* assign symbol to common (.bss) */
1221                                         /*      this is a result of a */
1222                                         /*      copy reloc against sym */
1223 #define FLG_SY_GLOBREF  0x00000002      /* a global reference has been seen */
1224 #define FLG_SY_WEAKDEF  0x00000004      /* a weak definition has been used */
1225 #define FLG_SY_CLEAN    0x00000008      /* `Sym' entry points to original */
1226                                         /*      input file (read-only). */
1227 #define FLG_SY_UPREQD   0x00000010      /* symbol value update is required, */
1228                                         /*      either it's used as an entry */
1229                                         /*      point or for relocation, but */
1230                                         /*      it must be updated even if */
1231                                         /*      the -s flag is in effect */
1232 #define FLG_SY_NOTAVAIL 0x00000020      /* symbol is not available to the */
1233                                         /*      application either because it */
1234                                         /*      originates from an implicitly */
1235                                         /*      referenced shared object, or */