Print this page
12399 kobj printf functions should be checked

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/amd64/krtld/kobj_reloc.c
          +++ new/usr/src/uts/intel/amd64/krtld/kobj_reloc.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + *
       26 + * Copyright 2020 Joyent, Inc.
  25   27   */
  26   28  
  27   29  /*
  28   30   * x86 relocation code.
  29   31   */
  30   32  
  31   33  #include <sys/types.h>
  32   34  #include <sys/param.h>
  33   35  #include <sys/sysmacros.h>
  34   36  #include <sys/systm.h>
↓ open down ↓ 116 lines elided ↑ open up ↑
 151  153                  off = ((Rela *)reladdr)->r_offset;
 152  154                  stndx = ELF_R_SYM(((Rela *)reladdr)->r_info);
 153  155                  if (stndx >= mp->nsyms) {
 154  156                          _kobj_printf(ops, "do_relocate: bad strndx %d\n",
 155  157                              symnum);
 156  158                          return (-1);
 157  159                  }
 158  160                  if ((rtype > R_AMD64_NUM) || IS_TLS_INS(rtype)) {
 159  161                          _kobj_printf(ops, "krtld: invalid relocation type %d",
 160  162                              rtype);
 161      -                        _kobj_printf(ops, " at 0x%llx:", off);
      163 +                        _kobj_printf(ops, " at 0x%lx:", off);
 162  164                          _kobj_printf(ops, " file=%s\n", mp->filename);
 163  165                          err = 1;
 164  166                          continue;
 165  167                  }
 166  168  
 167  169  
 168  170                  addend = (long)(((Rela *)reladdr)->r_addend);
 169  171                  reladdr += relocsize;
 170  172  
 171  173  
 172  174                  if (rtype == R_AMD64_NONE)
 173  175                          continue;
 174  176  
 175  177  #ifdef  KOBJ_DEBUG
 176  178                  if (kobj_debug & D_RELOCATIONS) {
 177  179                          Sym *   symp;
 178  180                          symp = (Sym *)
 179  181                              (mp->symtbl+(stndx * mp->symhdr->sh_entsize));
 180  182                          _kobj_printf(ops, "krtld:\t%s",
 181  183                              conv_reloc_amd64_type(rtype));
 182      -                        _kobj_printf(ops, "\t0x%8llx", off);
 183      -                        _kobj_printf(ops, " 0x%8llx", addend);
      184 +                        _kobj_printf(ops, "\t0x%8lx", off);
      185 +                        _kobj_printf(ops, " %8lld", (longlong_t)addend);
 184  186                          _kobj_printf(ops, "  %s\n",
 185  187                              (const char *)mp->strings + symp->st_name);
 186  188                  }
 187  189  #endif
 188  190  
 189  191                  if (!(mp->flags & KOBJ_EXEC))
 190  192                          off += baseaddr;
 191  193  
 192  194                  /*
 193  195                   * if R_AMD64_RELATIVE, simply add base addr
↓ open down ↓ 53 lines elided ↑ open up ↑
 247  249                  value += addend;
 248  250                  /*
 249  251                   * calculate final value -
 250  252                   * if PC-relative, subtract ref addr
 251  253                   */
 252  254                  if (IS_PC_RELATIVE(rtype))
 253  255                          value -= off;
 254  256  
 255  257  #ifdef  KOBJ_DEBUG
 256  258                  if (kobj_debug & D_RELOCATIONS) {
 257      -                        _kobj_printf(ops, "krtld:\t\t\t\t0x%8llx", off);
 258      -                        _kobj_printf(ops, " 0x%8llx\n", value);
      259 +                        _kobj_printf(ops, "krtld:\t\t\t\t0x%8lx", off);
      260 +                        _kobj_printf(ops, " 0x%8lx\n", value);
 259  261                  }
 260  262  #endif
 261  263  
 262  264                  if (do_reloc_krtld(rtype, (unsigned char *)off, &value,
 263  265                      (const char *)mp->strings + symref->st_name,
 264  266                      mp->filename) == 0)
 265  267                          err = 1;
 266  268  
 267  269          } /* end of while loop */
 268  270          if (err)
↓ open down ↓ 74 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX