Date: Wed, 16 Aug 2006 01:32:19 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 104168 for review Message-ID: <200608160132.k7G1WJkq094618@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=104168 Change 104168 by jb@jb_freebsd2 on 2006/08/16 01:31:26 Report ELF class, data type and OS ABI. Affected files ... .. //depot/projects/dtrace/src/lib/libelf/elf_dump.c#2 edit .. //depot/projects/dtrace/src/lib/libelf/libelf_dump.c#2 edit Differences ... ==== //depot/projects/dtrace/src/lib/libelf/elf_dump.c#2 (text+ko) ==== @@ -37,6 +37,53 @@ #include "_libelf.h" static const char * +ei_class_str(u_int ei_class) +{ + switch (ei_class) { + case ELFCLASSNONE: return("ELFCLASSNONE"); + case ELFCLASS32: return("ELFCLASS32"); + case ELFCLASS64: return("ELFCLASS64"); + default: return (NULL); + } +} + +static const char * +ei_data_str(u_int ei_data) +{ + switch (ei_data) { + case ELFDATANONE: return("ELFDATANONE"); + case ELFDATA2LSB: return("ELFDATA2LSB"); + case ELFDATA2MSB: return("ELFDATA2MSB"); + default: return (NULL); + } +} + +static const char * +ei_osabi_str(u_int ei_osabi) +{ + switch (ei_osabi) { + case ELFOSABI_NONE: return("ELFOSABI_NONE"); + case ELFOSABI_86OPEN: return("ELFOSABI_86OPEN"); + case ELFOSABI_AIX: return("ELFOSABI_AIX"); + case ELFOSABI_ARM: return("ELFOSABI_ARM"); + case ELFOSABI_FREEBSD: return("ELFOSABI_FREEBSD"); + case ELFOSABI_HPUX: return("ELFOSABI_HPUX"); + case ELFOSABI_HURD: return("ELFOSABI_HURD"); + case ELFOSABI_IRIX: return("ELFOSABI_IRIX"); + case ELFOSABI_LINUX: return("ELFOSABI_LINUX"); + case ELFOSABI_MODESTO: return("ELFOSABI_MODESTO"); + case ELFOSABI_NETBSD: return("ELFOSABI_NETBSD"); + case ELFOSABI_NSK: return("ELFOSABI_NSK"); + case ELFOSABI_OPENBSD: return("ELFOSABI_OPENBSD"); + case ELFOSABI_OPENVMS: return("ELFOSABI_OPENVMS"); + case ELFOSABI_SOLARIS: return("ELFOSABI_SOLARIS"); + case ELFOSABI_STANDALONE: return("ELFOSABI_STANDALONE"); + case ELFOSABI_TRU64: return("ELFOSABI_TRU64"); + default: return (NULL); + } +} + +static const char * et_str(u_int e_type) { switch (e_type) { ==== //depot/projects/dtrace/src/lib/libelf/libelf_dump.c#2 (text+ko) ==== @@ -48,12 +48,27 @@ if ((flags & ELF_DUMP_EHDR) != 0) { printf("\nelf header:\n\n"); - printf("\te_ident: "); + printf("\te_ident:"); + if ((s = ei_class_str(ehdr->e_ident[EI_CLASS])) == NULL) { + snprintf(s1, sizeof(s1), "%u", ehdr->e_ident[EI_CLASS]); + s = s1; + } + printf(" %s", s); + if ((s = ei_data_str(ehdr->e_ident[EI_DATA])) == NULL) { + snprintf(s1, sizeof(s1), "%u", ehdr->e_ident[EI_DATA]); + s = s1; + } + printf(" %s", s); + if ((s = ei_osabi_str(ehdr->e_ident[EI_OSABI])) == NULL) { + snprintf(s1, sizeof(s1), "%u", ehdr->e_ident[EI_OSABI]); + s = s1; + } + printf(" %s\n", s); if ((s = et_str(ehdr->e_type)) == NULL) { snprintf(s1, sizeof(s1), "%hu", ehdr->e_type); s = s1; } - printf("\n\te_type: %s\n", s); + printf("\te_type: %s\n", s); if ((s = em_str(ehdr->e_machine)) == NULL) { snprintf(s1, sizeof(s1), "%hu", ehdr->e_machine); s = s1;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200608160132.k7G1WJkq094618>