-/* Is the given elf program 32 or 64 bit?
- *
- * Note: This function returns -1 if 'filename' cannot
- * be opened as a valid ELF file.
- */
-static int
-elf_bits (const char *filename)
-{
- Elf *elf;
- GElf_Ehdr ehdr;
- int fd, class;
-
- fd = open (filename, O_RDONLY, 0);
- if (fd < 0)
- return -1;
-
- if (elf_version (EV_CURRENT ) == EV_NONE)
- return -1;
-
- elf = elf_begin (fd, ELF_C_READ, NULL);
- if (elf == NULL)
- return -1;
-
- if (elf_kind (elf) != ELF_K_ELF)
- return -1;
-
- if (gelf_getehdr (elf, &ehdr) == NULL)
- return -1;
-
- class = gelf_getclass (elf);
-
- switch (class) {
- case ELFCLASS32:
- return 32;
- case ELFCLASS64:
- return 64;
- default:
- return -1;
- }
-}
-