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


1073         /*
1074          * No files specified on the command line?
1075          */
1076         if ((nfile = argc - optind) == 0) {
1077                 (void) fprintf(stderr, MSG_INTL(MSG_USAGE_BRIEF), cname);
1078                 exit(1);
1079         }
1080 
1081         /*
1082          * By default print both version definitions and needed dependencies.
1083          */
1084         if ((dflag == 0) && (rflag == 0) && (lflag == 0))
1085                 dflag = rflag = DEF_DEFINED;
1086 
1087         /*
1088          * Open the input file and initialize the elf interface.
1089          */
1090         for (; optind < argc; optind++) {
1091                 int             derror = 0, nerror = 0, err;
1092                 const char      *file = argv[optind];

1093 
1094                 if ((var = open(file, O_RDONLY)) == -1) {
1095                         err = errno;
1096                         (void) fprintf(stderr, MSG_INTL(MSG_SYS_OPEN),
1097                             cname, file, strerror(err));
1098                         error = 1;
1099                         continue;
1100                 }
1101                 (void) elf_version(EV_CURRENT);
1102                 if ((elf = elf_begin(var, ELF_C_READ, NULL)) == NULL) {
1103                         (void) fprintf(stderr, MSG_ORIG(MSG_ELF_BEGIN), cname,
1104                             file, elf_errmsg(elf_errno()));
1105                         error = 1;
1106                         (void) close(var);
1107                         continue;
1108                 }
1109                 if (elf_kind(elf) != ELF_K_ELF) {
1110                         (void) fprintf(stderr, MSG_INTL(MSG_ELF_NOTELF), cname,
1111                             file);
1112                         error = 1;


1137                 }
1138                 if ((data = elf_getdata(scn, NULL)) == NULL) {
1139                         (void) fprintf(stderr, MSG_ORIG(MSG_ELF_GETDATA), cname,
1140                             file, elf_errmsg(elf_errno()));
1141                         error = 1;
1142                         (void) close(var);
1143                         (void) elf_end(elf);
1144                         continue;
1145                 }
1146                 names = data->d_buf;
1147 
1148                 /*
1149                  * Fill in the cache descriptor with information for each
1150                  * section we might need.   We probably only need to save
1151                  * read-only allocable sections as this is where the version
1152                  * structures and their associated symbols and strings live.
1153                  * However, God knows what someone can do with a mapfile, and
1154                  * as elf_begin has already gone through all the overhead we
1155                  * might as well set up the cache for every section.
1156                  */
1157                 if ((cache = calloc(ehdr.e_shnum, sizeof (Cache))) == NULL) {






1158                         int err = errno;
1159                         (void) fprintf(stderr, MSG_INTL(MSG_SYS_MALLOC), cname,
1160                             file, strerror(err));
1161                         exit(1);
1162                 }
1163 
1164                 _cache_def = _cache_need = _cache_sym = _cache_loc = NULL;
1165                 _cache = cache;
1166                 _cache++;
1167                 for (scn = NULL; scn = elf_nextscn(elf, scn); _cache++) {
1168                         if (gelf_getshdr(scn, &shdr) == NULL) {
1169                                 (void) fprintf(stderr,
1170                                     MSG_ORIG(MSG_ELF_GETSHDR), cname, file,
1171                                     elf_errmsg(elf_errno()));
1172                                 error = 1;
1173                                 continue;
1174                         }
1175                         if ((_cache->c_data = elf_getdata(scn, NULL)) ==
1176                             NULL) {
1177                                 (void) fprintf(stderr,




1073         /*
1074          * No files specified on the command line?
1075          */
1076         if ((nfile = argc - optind) == 0) {
1077                 (void) fprintf(stderr, MSG_INTL(MSG_USAGE_BRIEF), cname);
1078                 exit(1);
1079         }
1080 
1081         /*
1082          * By default print both version definitions and needed dependencies.
1083          */
1084         if ((dflag == 0) && (rflag == 0) && (lflag == 0))
1085                 dflag = rflag = DEF_DEFINED;
1086 
1087         /*
1088          * Open the input file and initialize the elf interface.
1089          */
1090         for (; optind < argc; optind++) {
1091                 int             derror = 0, nerror = 0, err;
1092                 const char      *file = argv[optind];
1093                 size_t          shnum = 0;
1094 
1095                 if ((var = open(file, O_RDONLY)) == -1) {
1096                         err = errno;
1097                         (void) fprintf(stderr, MSG_INTL(MSG_SYS_OPEN),
1098                             cname, file, strerror(err));
1099                         error = 1;
1100                         continue;
1101                 }
1102                 (void) elf_version(EV_CURRENT);
1103                 if ((elf = elf_begin(var, ELF_C_READ, NULL)) == NULL) {
1104                         (void) fprintf(stderr, MSG_ORIG(MSG_ELF_BEGIN), cname,
1105                             file, elf_errmsg(elf_errno()));
1106                         error = 1;
1107                         (void) close(var);
1108                         continue;
1109                 }
1110                 if (elf_kind(elf) != ELF_K_ELF) {
1111                         (void) fprintf(stderr, MSG_INTL(MSG_ELF_NOTELF), cname,
1112                             file);
1113                         error = 1;


1138                 }
1139                 if ((data = elf_getdata(scn, NULL)) == NULL) {
1140                         (void) fprintf(stderr, MSG_ORIG(MSG_ELF_GETDATA), cname,
1141                             file, elf_errmsg(elf_errno()));
1142                         error = 1;
1143                         (void) close(var);
1144                         (void) elf_end(elf);
1145                         continue;
1146                 }
1147                 names = data->d_buf;
1148 
1149                 /*
1150                  * Fill in the cache descriptor with information for each
1151                  * section we might need.   We probably only need to save
1152                  * read-only allocable sections as this is where the version
1153                  * structures and their associated symbols and strings live.
1154                  * However, God knows what someone can do with a mapfile, and
1155                  * as elf_begin has already gone through all the overhead we
1156                  * might as well set up the cache for every section.
1157                  */
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) {
1165                         int err = errno;
1166                         (void) fprintf(stderr, MSG_INTL(MSG_SYS_MALLOC), cname,
1167                             file, strerror(err));
1168                         exit(1);
1169                 }
1170 
1171                 _cache_def = _cache_need = _cache_sym = _cache_loc = NULL;
1172                 _cache = cache;
1173                 _cache++;
1174                 for (scn = NULL; scn = elf_nextscn(elf, scn); _cache++) {
1175                         if (gelf_getshdr(scn, &shdr) == NULL) {
1176                                 (void) fprintf(stderr,
1177                                     MSG_ORIG(MSG_ELF_GETSHDR), cname, file,
1178                                     elf_errmsg(elf_errno()));
1179                                 error = 1;
1180                                 continue;
1181                         }
1182                         if ((_cache->c_data = elf_getdata(scn, NULL)) ==
1183                             NULL) {
1184                                 (void) fprintf(stderr,