Print this page
10346 ld(1) should not reduce symbol visibility of COMDAT symbols when producing relocatable objects

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 ↓ 808 lines elided ↑ open up ↑
1006 1006                          DBG_CALL(Dbg_syms_ignore(ofl, sdp));
1007 1007                          continue;
1008 1008                  }
1009 1009  
1010 1010                  /*
1011 1011                   * Only needed symbols are copied to the output symbol table.
1012 1012                   */
1013 1013                  if (sdp->sd_ref == REF_DYN_SEEN)
1014 1014                          continue;
1015 1015  
1016      -                if (SYM_IS_HIDDEN(sdp) && (flags & FLG_OF_PROCRED))
     1016 +                if (ld_sym_reducable(ofl, sdp))
1017 1017                          local = 1;
1018 1018                  else
1019 1019                          local = 0;
1020 1020  
1021 1021                  if (local || (ofl->ofl_hashbkts == 0)) {
1022 1022                          sorted_syms[scndx++].sl_sdp = sdp;
1023 1023                  } else {
1024 1024                          sorted_syms[ssndx].sl_hval = sdp->sd_aux->sa_hash %
1025 1025                              ofl->ofl_hashbkts;
1026 1026                          sorted_syms[ssndx].sl_sdp = sdp;
↓ open down ↓ 190 lines elided ↑ open up ↑
1217 1217                                  gottable++;
1218 1218                          }
1219 1219                  }
1220 1220  
1221 1221                  /*
1222 1222                   * If this symbol has been marked as being reduced to local
1223 1223                   * scope then it will have to be placed in the scoped portion
1224 1224                   * of the .symtab.  Retain the appropriate index for use in
1225 1225                   * version symbol indexing and relocation.
1226 1226                   */
1227      -                if (SYM_IS_HIDDEN(sdp) && (flags & FLG_OF_PROCRED)) {
     1227 +                if (ld_sym_reducable(ofl, sdp)) {
1228 1228                          local = 1;
1229 1229                          if (!(sdp->sd_flags & FLG_SY_ELIM) && !dynsym)
1230 1230                                  sdp->sd_symndx = scopesym_ndx;
1231 1231                          else
1232 1232                                  sdp->sd_symndx = 0;
1233 1233  
1234 1234                          if (sdp->sd_flags & FLG_SY_ELIM) {
1235 1235                                  enter_in_symtab = 0;
1236 1236                          } else if (ldynsym && sdp->sd_sym->st_name &&
1237 1237                              ldynsym_symtype[
↓ open down ↓ 88 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 ↓ 535 lines elided ↑ open up ↑
1882 1882                  _sym = __sym = _sdp->sd_sym;
1883 1883  
1884 1884                  sdp->sd_flags |= FLG_SY_WEAKDEF;
1885 1885  
1886 1886                  /*
1887 1887                   * If the symbol definition has been scoped then assign it to
1888 1888                   * be local, otherwise if it's from a shared object then we need
1889 1889                   * to maintain the binding of the original reference.
1890 1890                   */
1891 1891                  if (SYM_IS_HIDDEN(sdp)) {
1892      -                        if (flags & FLG_OF_PROCRED)
     1892 +                        if (ld_sym_reducable(ofl, sdp))
1893 1893                                  bind = STB_LOCAL;
1894 1894                          else
1895 1895                                  bind = STB_WEAK;
1896 1896                  } else if ((sdp->sd_ref == REF_DYN_NEED) &&
1897 1897                      (sdp->sd_flags & FLG_SY_GLOBREF))
1898 1898                          bind = STB_GLOBAL;
1899 1899                  else
1900 1900                          bind = STB_WEAK;
1901 1901  
1902 1902                  DBG_CALL(Dbg_syms_old(ofl, sdp));
↓ open down ↓ 1247 lines elided ↑ open up ↑
3150 3150                                                      osp->os_shdr->sh_addr +
3151 3151                                                      imvp->m_poffset;
3152 3152                                          }
3153 3153                                  } else {
3154 3154                                          omvp->m_info =
3155 3155                                              /* LINTED */
3156 3156                                              ELF_M_INFO(sdp->sd_symndx,
3157 3157                                              imvp->m_info);
3158 3158                                  }
3159 3159                          } else {
3160      -                                Boolean         isredloc = FALSE;
     3160 +                                Boolean         isredloc = FALSE;
3161 3161  
3162 3162                                  if ((ELF_ST_BIND(sym->st_info) == STB_LOCAL) &&
3163 3163                                      (ofl->ofl_flags & FLG_OF_REDLSYM))
3164 3164                                          isredloc = TRUE;
3165 3165  
3166 3166                                  if (isredloc && !(sdp->sd_move)) {
3167 3167                                          Os_desc *osp = sdp->sd_isc->is_osdesc;
3168 3168                                          Word    ndx = osp->os_identndx;
3169 3169  
3170 3170                                          omvp->m_info =
↓ open down ↓ 474 lines elided ↑ open up ↑
3645 3645                          vaddr = ld_targ.t_m.m_segm_origin;
3646 3646          } else
3647 3647                  vaddr = 0;
3648 3648  
3649 3649          /*
3650 3650           * Loop through the segment descriptors and pick out what we need.
3651 3651           */
3652 3652          DBG_CALL(Dbg_seg_title(ofl->ofl_lml));
3653 3653          for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) {
3654 3654                  Phdr            *phdr = &(sgp->sg_phdr);
3655      -                Xword           p_align;
     3655 +                Xword           p_align;
3656 3656                  Aliste          idx2;
3657 3657                  Sym_desc        *sdp;
3658 3658  
3659 3659                  segndx++;
3660 3660  
3661 3661                  /*
3662 3662                   * If an interpreter is required generate a PT_INTERP and
3663 3663                   * PT_PHDR program header entry.  The PT_PHDR entry describes
3664 3664                   * the program header table itself.  This information will be
3665 3665                   * passed via the aux vector to the interpreter (ld.so.1).
↓ open down ↓ 199 lines elided ↑ open up ↑
3865 3865  
3866 3866                          if (phdr->p_type != PT_LOAD)
3867 3867                                  continue;
3868 3868  
3869 3869                          v_e = vaddr + phdr->p_memsz;
3870 3870  
3871 3871                          /*
3872 3872                           * Check overlaps
3873 3873                           */
3874 3874                          for (i = 0; i < phdrndx - 1; i++) {
3875      -                                Addr    p_s = (ofl->ofl_phdr[i]).p_vaddr;
3876      -                                Addr    p_e;
     3875 +                                Addr    p_s = (ofl->ofl_phdr[i]).p_vaddr;
     3876 +                                Addr    p_e;
3877 3877  
3878 3878                                  if ((ofl->ofl_phdr[i]).p_type != PT_LOAD)
3879 3879                                          continue;
3880 3880  
3881 3881                                  p_e = p_s + (ofl->ofl_phdr[i]).p_memsz;
3882 3882                                  if (((p_s <= vaddr) && (p_e > vaddr)) ||
3883 3883                                      ((vaddr <= p_s) && (v_e > p_s)))
3884 3884                                          ld_eprintf(ofl, ERR_WARNING,
3885 3885                                              MSG_INTL(MSG_UPD_SEGOVERLAP),
3886 3886                                              ofl->ofl_name, EC_ADDR(p_e),
↓ open down ↓ 430 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX