Print this page
4000 pvs can't deal with extended sections

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/pvs/common/pvs.c
          +++ new/usr/src/cmd/sgs/pvs/common/pvs.c
↓ open down ↓ 1082 lines elided ↑ open up ↑
1083 1083           */
1084 1084          if ((dflag == 0) && (rflag == 0) && (lflag == 0))
1085 1085                  dflag = rflag = DEF_DEFINED;
1086 1086  
1087 1087          /*
1088 1088           * Open the input file and initialize the elf interface.
1089 1089           */
1090 1090          for (; optind < argc; optind++) {
1091 1091                  int             derror = 0, nerror = 0, err;
1092 1092                  const char      *file = argv[optind];
     1093 +                size_t          shnum = 0;
1093 1094  
1094 1095                  if ((var = open(file, O_RDONLY)) == -1) {
1095 1096                          err = errno;
1096 1097                          (void) fprintf(stderr, MSG_INTL(MSG_SYS_OPEN),
1097 1098                              cname, file, strerror(err));
1098 1099                          error = 1;
1099 1100                          continue;
1100 1101                  }
1101 1102                  (void) elf_version(EV_CURRENT);
1102 1103                  if ((elf = elf_begin(var, ELF_C_READ, NULL)) == NULL) {
↓ open down ↓ 44 lines elided ↑ open up ↑
1147 1148  
1148 1149                  /*
1149 1150                   * Fill in the cache descriptor with information for each
1150 1151                   * section we might need.   We probably only need to save
1151 1152                   * read-only allocable sections as this is where the version
1152 1153                   * structures and their associated symbols and strings live.
1153 1154                   * However, God knows what someone can do with a mapfile, and
1154 1155                   * as elf_begin has already gone through all the overhead we
1155 1156                   * might as well set up the cache for every section.
1156 1157                   */
1157      -                if ((cache = calloc(ehdr.e_shnum, sizeof (Cache))) == NULL) {
     1158 +                if (elf_getshdrnum(elf, &shnum) == -1) {
     1159 +                        (void) fprintf(stderr, MSG_ORIG(MSG_ELF_GETSHDRNUM),
     1160 +                            cname, file, elf_errmsg(elf_errno()));
     1161 +                        exit(1);
     1162 +                }
     1163 +
     1164 +                if ((cache = calloc(shnum, sizeof (Cache))) == NULL) {
1158 1165                          int err = errno;
1159 1166                          (void) fprintf(stderr, MSG_INTL(MSG_SYS_MALLOC), cname,
1160 1167                              file, strerror(err));
1161 1168                          exit(1);
1162 1169                  }
1163 1170  
1164 1171                  _cache_def = _cache_need = _cache_sym = _cache_loc = NULL;
1165 1172                  _cache = cache;
1166 1173                  _cache++;
1167 1174                  for (scn = NULL; scn = elf_nextscn(elf, scn); _cache++) {
↓ open down ↓ 124 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX