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/libld/common/update.c
          +++ new/usr/src/cmd/sgs/libld/common/update.c
↓ open down ↓ 176 lines elided ↑ open up ↑
 177  177          Ifl_desc        *ifl;
 178  178          Word            bssndx, etext_ndx, edata_ndx = 0, end_ndx, start_ndx;
 179  179          Word            end_abs = 0, etext_abs = 0, edata_abs;
 180  180          Word            tlsbssndx = 0, parexpnndx;
 181  181  #if     defined(_ELF64)
 182  182          Word            lbssndx = 0;
 183  183          Addr            lbssaddr = 0;
 184  184  #endif
 185  185          Addr            bssaddr, etext = 0, edata = 0, end = 0, start = 0;
 186  186          Addr            tlsbssaddr = 0;
 187      -        Addr            parexpnbase, parexpnaddr;
      187 +        Addr            parexpnbase, parexpnaddr;
 188  188          int             start_set = 0;
 189  189          Sym             _sym = {0}, *sym, *symtab = NULL;
 190  190          Sym             *dynsym = NULL, *ldynsym = NULL;
 191  191          Word            symtab_ndx = 0;         /* index into .symtab */
 192  192          Word            symtab_gbl_bndx;        /* .symtab ndx 1st global */
 193  193          Word            ldynsym_ndx = 0;        /* index into .SUNW_ldynsym */
 194  194          Word            dynsym_ndx = 0;         /* index into .dynsym */
 195  195          Word            scopesym_ndx = 0;       /* index into scoped symbols */
 196  196          Word            scopesym_bndx = 0;      /* .symtab ndx 1st scoped sym */
 197  197          Word            ldynscopesym_ndx = 0;   /* index to ldynsym scoped */
↓ open down ↓ 1128 lines elided ↑ open up ↑
1326 1326                                          syminfo[ndx].si_flags |=
1327 1327                                              SYMINFO_FLG_DEFERRED;
1328 1328  
1329 1329                                  /*
1330 1330                                   * Enable direct symbol bindings if:
1331 1331                                   *
1332 1332                                   *  -   Symbol was identified with the DIRECT
1333 1333                                   *      keyword in a mapfile.
1334 1334                                   *
1335 1335                                   *  -   Symbol reference has been bound to a
1336      -                                 *      dependency which was specified as
     1336 +                                 *      dependency which was specified as
1337 1337                                   *      requiring direct bindings with -zdirect.
1338 1338                                   *
1339 1339                                   *  -   All symbol references are required to
1340 1340                                   *      use direct bindings via -Bdirect.
1341 1341                                   */
1342 1342                                  if (sdp->sd_flags & FLG_SY_DIR)
1343 1343                                          syminfo[ndx].si_flags |=
1344 1344                                              SYMINFO_FLG_DIRECTBIND;
1345 1345  
1346 1346                          } else if ((sdp->sd_flags & FLG_SY_EXTERN) &&
↓ open down ↓ 414 lines elided ↑ open up ↑
1761 1761                                   * stored in symbol's value during
1762 1762                                   * allocate_got().
1763 1763                                   */
1764 1764                                  sym->st_value += ofl->
1765 1765                                      ofl_osgot->os_shdr->sh_addr;
1766 1766                                  /* LINTED */
1767 1767                                  sectndx = elf_ndxscn(ofl->
1768 1768                                      ofl_osgot->os_scn);
1769 1769                                  sdp->sd_flags &= ~FLG_SY_SPECSEC;
1770 1770                                  break;
     1771 +                        case SDAUX_ID_SECBOUND_START:
     1772 +                                sym->st_value = sap->sa_boundsec->
     1773 +                                    os_shdr->sh_addr;
     1774 +                                sectndx = elf_ndxscn(sap->sa_boundsec->os_scn);
     1775 +                                sdp->sd_flags &= ~FLG_SY_SPECSEC;
     1776 +                                break;
     1777 +                        case SDAUX_ID_SECBOUND_STOP:
     1778 +                                sym->st_value = sap->sa_boundsec->
     1779 +                                    os_shdr->sh_addr +
     1780 +                                    sap->sa_boundsec->os_shdr->sh_size;
     1781 +                                sectndx = elf_ndxscn(sap->sa_boundsec->os_scn);
     1782 +                                sdp->sd_flags &= ~FLG_SY_SPECSEC;
     1783 +                                break;
1771 1784                          default:
1772 1785                                  /* NOTHING */
1773 1786                                  ;
1774 1787                          }
1775 1788                  }
1776 1789  
1777 1790                  /*
1778 1791                   * If a plt index has been assigned to an undefined function,
1779 1792                   * update the symbols value to the appropriate .plt address.
1780 1793                   */
↓ open down ↓ 791 lines elided ↑ open up ↑
2572 2585          dyn++;
2573 2586  
2574 2587          dyn->d_tag = DT_SUNW_STRPAD;
2575 2588          dyn->d_un.d_val = DYNSTR_EXTRA_PAD;
2576 2589          dyn++;
2577 2590  
2578 2591          dyn->d_tag = DT_SUNW_LDMACH;
2579 2592          dyn->d_un.d_val = ld_sunw_ldmach();
2580 2593          dyn++;
2581 2594  
     2595 +        if (ofl->ofl_flags & FLG_OF_KMOD) {
     2596 +                dyn->d_tag = DT_SUNW_KMOD;
     2597 +                dyn->d_un.d_val = 1;
     2598 +                dyn++;
     2599 +        }
     2600 +
2582 2601          (*ld_targ.t_mr.mr_mach_update_odynamic)(ofl, &dyn);
2583 2602  
2584 2603          for (cnt = 1 + DYNAMIC_EXTRA_ELTS; cnt--; dyn++) {
2585 2604                  dyn->d_tag = DT_NULL;
2586 2605                  dyn->d_un.d_val = 0;
2587 2606          }
2588 2607  
2589 2608          /*
2590 2609           * Ensure that we wrote the right number of entries. If not, we either
2591 2610           * miscounted in make_dynamic(), or we did something wrong in this
↓ open down ↓ 558 lines elided ↑ open up ↑
3150 3169                                                      osp->os_shdr->sh_addr +
3151 3170                                                      imvp->m_poffset;
3152 3171                                          }
3153 3172                                  } else {
3154 3173                                          omvp->m_info =
3155 3174                                              /* LINTED */
3156 3175                                              ELF_M_INFO(sdp->sd_symndx,
3157 3176                                              imvp->m_info);
3158 3177                                  }
3159 3178                          } else {
3160      -                                Boolean         isredloc = FALSE;
     3179 +                                Boolean         isredloc = FALSE;
3161 3180  
3162 3181                                  if ((ELF_ST_BIND(sym->st_info) == STB_LOCAL) &&
3163 3182                                      (ofl->ofl_flags & FLG_OF_REDLSYM))
3164 3183                                          isredloc = TRUE;
3165 3184  
3166 3185                                  if (isredloc && !(sdp->sd_move)) {
3167 3186                                          Os_desc *osp = sdp->sd_isc->is_osdesc;
3168 3187                                          Word    ndx = osp->os_identndx;
3169 3188  
3170 3189                                          omvp->m_info =
↓ open down ↓ 474 lines elided ↑ open up ↑
3645 3664                          vaddr = ld_targ.t_m.m_segm_origin;
3646 3665          } else
3647 3666                  vaddr = 0;
3648 3667  
3649 3668          /*
3650 3669           * Loop through the segment descriptors and pick out what we need.
3651 3670           */
3652 3671          DBG_CALL(Dbg_seg_title(ofl->ofl_lml));
3653 3672          for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) {
3654 3673                  Phdr            *phdr = &(sgp->sg_phdr);
3655      -                Xword           p_align;
     3674 +                Xword           p_align;
3656 3675                  Aliste          idx2;
3657 3676                  Sym_desc        *sdp;
3658 3677  
3659 3678                  segndx++;
3660 3679  
3661 3680                  /*
3662 3681                   * If an interpreter is required generate a PT_INTERP and
3663 3682                   * PT_PHDR program header entry.  The PT_PHDR entry describes
3664 3683                   * the program header table itself.  This information will be
3665 3684                   * passed via the aux vector to the interpreter (ld.so.1).
↓ open down ↓ 199 lines elided ↑ open up ↑
3865 3884  
3866 3885                          if (phdr->p_type != PT_LOAD)
3867 3886                                  continue;
3868 3887  
3869 3888                          v_e = vaddr + phdr->p_memsz;
3870 3889  
3871 3890                          /*
3872 3891                           * Check overlaps
3873 3892                           */
3874 3893                          for (i = 0; i < phdrndx - 1; i++) {
3875      -                                Addr    p_s = (ofl->ofl_phdr[i]).p_vaddr;
3876      -                                Addr    p_e;
     3894 +                                Addr    p_s = (ofl->ofl_phdr[i]).p_vaddr;
     3895 +                                Addr    p_e;
3877 3896  
3878 3897                                  if ((ofl->ofl_phdr[i]).p_type != PT_LOAD)
3879 3898                                          continue;
3880 3899  
3881 3900                                  p_e = p_s + (ofl->ofl_phdr[i]).p_memsz;
3882 3901                                  if (((p_s <= vaddr) && (p_e > vaddr)) ||
3883 3902                                      ((vaddr <= p_s) && (v_e > p_s)))
3884 3903                                          ld_eprintf(ofl, ERR_WARNING,
3885 3904                                              MSG_INTL(MSG_UPD_SEGOVERLAP),
3886 3905                                              ofl->ofl_name, EC_ADDR(p_e),
↓ open down ↓ 430 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX