Print this page
ld: implement -ztype and rework option parsing

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/libld/common/relocate.c
          +++ new/usr/src/cmd/sgs/libld/common/relocate.c
↓ open down ↓ 68 lines elided ↑ open up ↑
  69   69  #define IS_TLS_IE(X)    RELTAB_IS_TLS_IE(X, ld_targ.t_mr.mr_reloc_table)
  70   70  #define IS_TLS_LE(X)    RELTAB_IS_TLS_LE(X, ld_targ.t_mr.mr_reloc_table)
  71   71  #define IS_LOCALBND(X)  RELTAB_IS_LOCALBND(X, ld_targ.t_mr.mr_reloc_table)
  72   72  #define IS_SIZE(X)      RELTAB_IS_SIZE(X, ld_targ.t_mr.mr_reloc_table)
  73   73  
  74   74  /*
  75   75   * Structure to hold copy relocation items.
  76   76   */
  77   77  typedef struct copy_rel {
  78   78          Sym_desc        *c_sdp;         /* symbol descriptor to be copied */
  79      -        Addr            c_val;          /* original symbol value */
       79 +        Addr            c_val;          /* original symbol value */
  80   80  } Copy_rel;
  81   81  
  82   82  /*
  83   83   * For each copy relocation symbol, determine if the symbol is:
  84      - *      1) to be *disp* relocated at runtime
       84 + *      1) to be *disp* relocated at runtime
  85   85   *      2) a reference symbol for *disp* relocation
  86   86   *      3) possibly *disp* relocated at ld time.
  87   87   *
  88   88   * The first and the second are serious errors.
  89   89   */
  90   90  static void
  91   91  is_disp_copied(Ofl_desc *ofl, Copy_rel *crp)
  92   92  {
  93   93          Ifl_desc        *ifl = crp->c_sdp->sd_file;
  94   94          Sym_desc        *sdp = crp->c_sdp;
↓ open down ↓ 1441 lines elided ↑ open up ↑
1536 1536           *  -   the section being relocated is of type SHT_SUNW_dof.  These
1537 1537           *      sections must be bound to the functions in the containing
1538 1538           *      object and can not be interposed upon.
1539 1539           *
1540 1540           *  -   the symbol has been reduced (scoped to a local or symbolic) and
1541 1541           *      reductions are being processed.
1542 1542           *
1543 1543           *  -   the -Bsymbolic flag is in use when building a shared object,
1544 1544           *      and the symbol hasn't explicitly been defined as nodirect.
1545 1545           *
1546      -         *  -   an executable (fixed address) is being created, and the symbol
     1546 +         *  -   an executable (fixed address) )is being created, and the symbol
1547 1547           *      is defined in the executable.
1548 1548           *
1549 1549           *  -   the relocation is against a segment which will not be loaded
1550 1550           *      into memory.  In this case, the relocation must be resolved
1551 1551           *      now, as ld.so.1 can not process relocations against unmapped
1552 1552           *      segments.
1553 1553           */
1554 1554          local = FALSE;
1555 1555          if (ELF_ST_BIND(sdp->sd_sym->st_info) == STB_LOCAL) {
1556 1556                  local = TRUE;
↓ open down ↓ 700 lines elided ↑ open up ↑
2257 2257   * Move Section related function
2258 2258   * Get move entry
2259 2259   */
2260 2260  static Move *
2261 2261  get_move_entry(Is_desc *rsect, Xword roffset)
2262 2262  {
2263 2263          Ifl_desc        *ifile = rsect->is_file;
2264 2264          Shdr            *rshdr = rsect->is_shdr;
2265 2265          Is_desc         *misp;
2266 2266          Shdr            *mshdr;
2267      -        Xword           midx;
     2267 +        Xword           midx;
2268 2268          Move            *mvp;
2269 2269  
2270 2270          /*
2271 2271           * Set info for the target move section
2272 2272           */
2273 2273          misp = ifile->ifl_isdesc[rshdr->sh_info];
2274 2274          mshdr = misp->is_shdr;
2275 2275  
2276 2276          if (mshdr->sh_entsize == 0)
2277 2277                  return (NULL);
↓ open down ↓ 11 lines elided ↑ open up ↑
2289 2289  }
2290 2290  
2291 2291  /*
2292 2292   * Relocation against Move Table.
2293 2293   */
2294 2294  static uintptr_t
2295 2295  process_movereloc(Ofl_desc *ofl, Is_desc *rsect)
2296 2296  {
2297 2297          Ifl_desc        *file = rsect->is_file;
2298 2298          Rel             *rend, *reloc;
2299      -        Xword           rsize, entsize;
2300      -        Rel_desc        reld;
     2299 +        Xword           rsize, entsize;
     2300 +        Rel_desc        reld;
2301 2301          Rel_aux rel_aux;
2302 2302  
2303 2303          rsize = rsect->is_shdr->sh_size;
2304 2304          reloc = (Rel *)rsect->is_indata->d_buf;
2305 2305  
2306 2306          /*
2307 2307           * Decide entry size.
2308 2308           */
2309 2309          entsize = rsect->is_shdr->sh_entsize;
2310 2310          if ((entsize == 0) ||
↓ open down ↓ 643 lines elided ↑ open up ↑
2954 2954  /*
2955 2955   * Partially Initialized Symbol Handling routines
2956 2956   * For RELA architecture, the second argument is reld->rel_raddend.  For REL
2957 2957   * architecure, the second argument is the value stored at the relocation
2958 2958   * target address.
2959 2959   */
2960 2960  Sym_desc *
2961 2961  ld_am_I_partial(Rel_desc *reld, Xword val)
2962 2962  {
2963 2963          Ifl_desc        *ifile = reld->rel_sym->sd_isc->is_file;
2964      -        int             nlocs = ifile->ifl_locscnt, i;
     2964 +        int             nlocs = ifile->ifl_locscnt, i;
2965 2965  
2966 2966          for (i = 1; i < nlocs; i++) {
2967 2967                  Sym             *osym;
2968 2968                  Sym_desc        *symd = ifile->ifl_oldndx[i];
2969 2969  
2970 2970                  if ((osym = symd->sd_osym) == 0)
2971 2971                          continue;
2972 2972                  if ((symd->sd_flags & FLG_SY_PAREXPN) == 0)
2973 2973                          continue;
2974 2974                  if ((osym->st_value <= val) &&
↓ open down ↓ 186 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX