Print this page
2940 elfdump should return non-null on invalid file type


 957                 }
 958                 (void) elf_version(EV_CURRENT);
 959                 if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
 960                         failure(file, MSG_ORIG(MSG_ELF_BEGIN));
 961                         (void) close(fd);
 962                         continue;
 963                 }
 964 
 965                 if (var > 1)
 966                         dbg_print(0, MSG_ORIG(MSG_FMT_NLSTRNL), file);
 967 
 968                 switch (elf_kind(elf)) {
 969                 case ELF_K_AR:
 970                         ret = archive(file, fd, elf, flags, wname, wfd, osabi);
 971                         break;
 972                 case ELF_K_ELF:
 973                         ret = decide(file, fd, elf, flags, wname, wfd, osabi);
 974                         break;
 975                 default:
 976                         (void) fprintf(stderr, MSG_INTL(MSG_ERR_BADFILE), file);

 977                         break;
 978                 }
 979 
 980                 (void) close(fd);
 981                 (void) elf_end(elf);
 982         }
 983 
 984         if (wfd)
 985                 (void) close(wfd);
 986         return (ret);
 987 
 988 usage_brief:
 989         /* Control comes here for a simple usage message and exit */
 990         (void) fprintf(stderr, MSG_INTL(MSG_USAGE_BRIEF),
 991             basename(argv[0]));
 992         return (1);
 993 
 994 }


 957                 }
 958                 (void) elf_version(EV_CURRENT);
 959                 if ((elf = elf_begin(fd, ELF_C_READ, NULL)) == NULL) {
 960                         failure(file, MSG_ORIG(MSG_ELF_BEGIN));
 961                         (void) close(fd);
 962                         continue;
 963                 }
 964 
 965                 if (var > 1)
 966                         dbg_print(0, MSG_ORIG(MSG_FMT_NLSTRNL), file);
 967 
 968                 switch (elf_kind(elf)) {
 969                 case ELF_K_AR:
 970                         ret = archive(file, fd, elf, flags, wname, wfd, osabi);
 971                         break;
 972                 case ELF_K_ELF:
 973                         ret = decide(file, fd, elf, flags, wname, wfd, osabi);
 974                         break;
 975                 default:
 976                         (void) fprintf(stderr, MSG_INTL(MSG_ERR_BADFILE), file);
 977                         ret = 1;
 978                         break;
 979                 }
 980 
 981                 (void) close(fd);
 982                 (void) elf_end(elf);
 983         }
 984 
 985         if (wfd)
 986                 (void) close(wfd);
 987         return (ret);
 988 
 989 usage_brief:
 990         /* Control comes here for a simple usage message and exit */
 991         (void) fprintf(stderr, MSG_INTL(MSG_USAGE_BRIEF),
 992             basename(argv[0]));
 993         return (1);
 994 
 995 }